|
| 1 | +feature EDI |
| 2 | + before |
| 3 | + .test.src: "\n" sv read0 `:resources/evaluate.q; |
| 4 | + .test.evaluate: {[ctx; code; returnFormat] |
| 5 | + 0i (.test.src; ctx; code; returnFormat) |
| 6 | + }; |
| 7 | + .test.dims : system "c"; |
| 8 | + .test.precision: system "P"; |
| 9 | + .test.attrLines: ("dict: `s#`a`b`c`d`e`f`g!enlist each 7?0"; |
| 10 | + "dict[`e] : dict[`e] , 1"; |
| 11 | + "attr dict"); |
| 12 | + after |
| 13 | + delete dict from `.; |
| 14 | + |
| 15 | + after each |
| 16 | + system "c ", " " sv string .test.dims; |
| 17 | + system "P ", string .test.precision; |
| 18 | + |
| 19 | + // @TICKET KXI-9607 |
| 20 | + should ensure EDI performs display correctly for standard expressions |
| 21 | + // @TICKET KXI-12260 |
| 22 | + expect simple expression of 3+3 to return 6: |
| 23 | + .qu.compare[.test.evaluate["."; "3+3"; "serialized"]`result; 6] |
| 24 | + |
| 25 | + // This test is skipped because coverage is not handling generic null correctly in QBUILD 1.0.17 and greater |
| 26 | + // @TICKET KXI-12260 |
| 27 | + xexpect projection null to return as generic null |
| 28 | + .qu.compare[.test.evaluate["."; "last value (;;)"; "serialized"]`result; (::)] |
| 29 | + |
| 30 | + expect function definition to work: |
| 31 | + .qu.compare[.test.evaluate["."; ".test.fn333: {: 333}"; "serialized"]`result; {: 333}] |
| 32 | + |
| 33 | + expect function call to work and return 333: |
| 34 | + .qu.compare[.test.evaluate["."; ".test.fn333 []"; "serialized"]`result; 333] |
| 35 | + |
| 36 | + xexpect each right and each left of similar expressions to be equal: |
| 37 | + .com_kx_edi.dropIrrelevantRecords[.com_kx_ediNoCoverage.evaluate["1 2 3 +\\: 10"; "."]] ~ .com_kx_edi.dropIrrelevantRecords .com_kx_ediNoCoverage.evaluate["10 +/: 1 2 3"; "."] |
| 38 | + |
| 39 | + expect scan to work and return 11 13 16: |
| 40 | + .qu.compare[.test.evaluate["."; "10 +\\ 1 2 3"; "serialized"]`result; 11 13 16] |
| 41 | + |
| 42 | + expect over to work and return 16: |
| 43 | + .qu.compare[.test.evaluate["."; "10 +/ 1 2 3"; "serialized"]`result; 16] |
| 44 | + |
| 45 | + expect a list created by EDI to be equal to the list: |
| 46 | + .qu.compare[.test.evaluate["."; "1 2 3 4 5 6 7 8"; "serialized"]`result; 1 2 3 4 5 6 7 8] |
| 47 | + |
| 48 | + expect an expression that creates a list to return the correct list: |
| 49 | + .qu.compare[.test.evaluate["."; "`char$97+til 26"; "serialized"]`result; "abcdefghijklmnopqrstuvwxyz"] |
| 50 | + |
| 51 | + expect the concat of two lists to be the same: |
| 52 | + .qu.compare[.test.evaluate["."; "(til 100),(til 100)"; "serialized"]`result; (til[100], til 100)] |
| 53 | + |
| 54 | + // @TICKET KXI-9607 |
| 55 | + should ensure EDI performs display correctly for k expressions |
| 56 | + expect simple k expressions to work, 3+3=6: |
| 57 | + .qu.compare[.test.evaluate["."; "k) 3 + 3"; "serialized"]`result; 6] |
| 58 | + |
| 59 | + expect more complicated k expressions to work such as over: |
| 60 | + .qu.compare[.test.evaluate["."; "k) +/1 2 3 4"; "serialized"]`result; 10] |
| 61 | + |
| 62 | + expect more complicated k expressions to work such as dyadic function over: |
| 63 | + .qu.compare[.test.evaluate["."; "k) {x+2*y}/1 2 3 4"; "serialized"]`result; 19] |
| 64 | + |
| 65 | + expect more complicated k expressions to work such as monadic each both: |
| 66 | + .qu.compare[.test.evaluate["."; "k) (-':)1 2 3 4"; "serialized"]`result; 1 1 1 1] |
| 67 | + |
| 68 | + expect more complicated k expressions to work such as monadic each both: |
| 69 | + .qu.compare[.test.evaluate["."; "k) +\\1 2 3 4"; "serialized"]`result; 1 3 6 10] |
| 70 | + |
| 71 | + expect a string to be a string in k: |
| 72 | + .qu.compare[.test.evaluate["."; "k) \"hello\\\\there\""; "serialized"]`result; "hello\\there"] |
| 73 | + |
| 74 | + // @TICKET KXI-9607 |
| 75 | + should ensure EDI performs display correctly for system expressions |
| 76 | + expect it to return timing information: |
| 77 | + // this fails intermittently on windows for some reason ... |
| 78 | + 10 > .test.evaluate["."; "\\t count \"doug\""; "serialized"]`result |
| 79 | + |
| 80 | + expect expression in t to set zz correctly: |
| 81 | + (.test.zz ~ 4) and (10 > .test.evaluate["."; "\\t .test.zz: count \"doug\""; "serialized"]`result) |
| 82 | + |
| 83 | + expect simple expression in t to work correctly: |
| 84 | + (.test.zz ~ 4) and (10 > .test.evaluate["."; "\\t .test.zz: 1 + 1 + 1 + 1"; "serialized"]`result) |
| 85 | + |
| 86 | + expect ts to return time and space: |
| 87 | + .qu.compare[count .test.evaluate["."; "\\ts til 10000"; "serialized"]`result; 2] |
| 88 | + |
| 89 | + expect workspace information to return correctly (should usually work but may fail): |
| 90 | + (last system "w") ~ last .test.evaluate["."; "\\w"; "serialized"]`result |
| 91 | + |
| 92 | + expect ls os command to return data back as a general list equivalent to system call: |
| 93 | + $["w" ~ first string .z.o; |
| 94 | + // The /b is needed to show the simple results, |
| 95 | + // as if just "dir" is used, the results can change between the two calls |
| 96 | + (system "dir /b") ~ .test.evaluate["."; "\\dir /b"; "serialized"]`result; |
| 97 | + (system "ls") ~ .test.evaluate["."; "\\ls"; "serialized"]`result]; |
| 98 | + |
| 99 | + expect pwd os command to return the current directory equivalent to system call: |
| 100 | + (system "cd") ~ .test.evaluate["."; "\\cd"; "serialized"]`result |
| 101 | + |
| 102 | + expect a to return a list of tables: |
| 103 | + 11h ~ type .test.evaluate["."; "\\a"; "serialized"]`result |
| 104 | + |
| 105 | + expect c to return the console size: |
| 106 | + 6h ~ type .test.evaluate["."; "\\c"; "serialized"]`result |
| 107 | + |
| 108 | + expect c 100 100 to set the console to 100 100: |
| 109 | + .test.evaluate["."; "\\c 100 100"; "serialized"]`result; |
| 110 | + 100 100i ~ system "c" |
| 111 | + |
| 112 | + expect p to provide the port: |
| 113 | + system["p"] ~ .test.evaluate["."; "\\p"; "serialized"]`result |
| 114 | + |
| 115 | + expect P to provide the precision: |
| 116 | + system["P"] ~ .test.evaluate["."; "\\P"; "serialized"]`result |
| 117 | + |
| 118 | + expect setting precision to 4 for it to be set to 4: |
| 119 | + (system ["P"] ~ 4i) and (::) ~ .test.evaluate["."; "\\P 4"; "serialized"]`result |
| 120 | + |
| 121 | + expect setting the precision to 0 sets it to max (same as 16): |
| 122 | + (system ["P"] ~ 0i) and (::) ~ .test.evaluate["."; "\\P 0"; "serialized"]`result |
| 123 | + |
| 124 | + // @TICKET KXI-9607 |
| 125 | + should work for non-default contexts |
| 126 | + expect correct expression result |
| 127 | + 6 ~ .test.evaluate[".test"; "3+3"; "serialized"]`result |
| 128 | + |
| 129 | + expect function to be compiled in the correct context |
| 130 | + `foo ~ first @[;3] value .test.evaluate[".foo"; "fn:{3+3}"; "serialized"]`result |
| 131 | + |
| 132 | + // @TICKET KXI-9607 |
| 133 | + should accept alternate values to indicate "." |
| 134 | + expect correct expression result |
| 135 | + .test.ctx: system "d"; |
| 136 | + system "d .ignore"; |
| 137 | + .test.evaluate["."; "myVal1: `first"; "serialized"]`result; |
| 138 | + .test.evaluate["."; "myVal2: `second"; "serialized"]`result; |
| 139 | + system "d " , string .test.ctx; |
| 140 | + `first`second ~ get each `..myVal1`..myVal2; |
| 141 | + after |
| 142 | + delete myVal1 from `.; |
| 143 | + delete myVal2 from `.; |
| 144 | + |
| 145 | + // @TICKET KXI-9607 |
| 146 | + // @TICKET KXI-16397 |
| 147 | + should not remove things that look like comments |
| 148 | + expect the /test to not be removed |
| 149 | + // This needs the trim, because it returns "/test " on windows |
| 150 | + trim[.test.evaluate["."; "\\echo /test"; "serialized"]`result] ~ enlist "/test" |
| 151 | + |
| 152 | + // @TICKET KXI-9607 |
| 153 | + // @TICKET KXI-16397 |
| 154 | + should handle windows line endings |
| 155 | + expect this to be treated as a single expression |
| 156 | + .qu.compare[.test.evaluate["."; "(1\r\n\r\n 2 3)"; "serialized"]`result; 1 2 3] |
| 157 | + |
| 158 | + // @TICKET KXI-9607 |
| 159 | + should maintain attributes regardless of semi-colon (KXAX-16342) |
| 160 | + expect an attribute with no semi colons |
| 161 | + `s ~ .test.evaluate["."; "\n" sv .test.attrLines; "serialized"]`result |
| 162 | + expect an attribute with semi colons |
| 163 | + `s ~ .test.evaluate["."; "\n" sv .test.attrLines ,\: ";"; "serialized"]`result |
| 164 | + expect an attribute with no semi colons with two newlines |
| 165 | + `s ~ .test.evaluate["."; "\n\n" sv .test.attrLines; "serialized"]`result |
| 166 | + expect an attribute with semi colons with two newlines |
| 167 | + `s ~ .test.evaluate["."; "\n\n" sv .test.attrLines ,\: ";"; "serialized"]`result |
0 commit comments