1 |
schoenebeck |
3551 |
/* |
2 |
|
|
* Copyright (c) 2019 Christian Schoenebeck |
3 |
|
|
* |
4 |
|
|
* http://www.linuxsampler.org |
5 |
|
|
* |
6 |
|
|
* This file is part of LinuxSampler and released under the same terms. |
7 |
|
|
* See README file for details. |
8 |
|
|
*/ |
9 |
|
|
|
10 |
|
|
// This file contains automated test cases against the NKSP real-time |
11 |
|
|
// instrument script engine. |
12 |
|
|
|
13 |
|
|
#include "../../common/global.h" |
14 |
|
|
#include "../../common/optional.h" |
15 |
schoenebeck |
3575 |
#include "../../common/RTMath.h" |
16 |
schoenebeck |
3551 |
#include "../ScriptVM.h" |
17 |
|
|
#include "../common.h" |
18 |
|
|
#include <sstream> |
19 |
|
|
#include <stdlib.h> |
20 |
|
|
#include <time.h> |
21 |
|
|
#include <assert.h> |
22 |
|
|
#include <functional> |
23 |
|
|
|
24 |
|
|
#ifndef TEST_ASSERT |
25 |
|
|
# define TEST_ASSERT assert |
26 |
|
|
#endif |
27 |
|
|
|
28 |
|
|
using namespace LinuxSampler; |
29 |
|
|
using namespace std; |
30 |
|
|
|
31 |
|
|
struct RunScriptOpt { |
32 |
|
|
String code; |
33 |
|
|
bool expectParseError; |
34 |
schoenebeck |
3581 |
bool expectParseWarning; |
35 |
schoenebeck |
3551 |
bool expectRuntimeError; |
36 |
|
|
bool expectNoExitResult; |
37 |
schoenebeck |
3581 |
bool expectExitResultIsInt; |
38 |
|
|
bool expectExitResultIsReal; |
39 |
schoenebeck |
3551 |
bool prohibitExitFunctionArguments; |
40 |
schoenebeck |
3575 |
optional<vmint> expectIntExitResult; |
41 |
schoenebeck |
3551 |
optional<bool> expectBoolExitResult; |
42 |
schoenebeck |
3575 |
optional<vmfloat> expectRealExitResult; |
43 |
schoenebeck |
3551 |
optional<String> expectStringExitResult; |
44 |
schoenebeck |
3581 |
vector<MetricPrefix_t> expectExitResultUnitPrefix; |
45 |
|
|
optional<StdUnit_t> expectExitResultUnit; |
46 |
|
|
optional<bool> expectExitResultFinal; |
47 |
schoenebeck |
3551 |
}; |
48 |
|
|
|
49 |
|
|
static void runScript(const RunScriptOpt& opt) { |
50 |
|
|
ScriptVM vm; |
51 |
|
|
vm.setAutoSuspendEnabled(false); |
52 |
|
|
if (!opt.prohibitExitFunctionArguments) |
53 |
|
|
vm.setExitResultEnabled(true); |
54 |
|
|
unique_ptr<VMParserContext> parserCtx( |
55 |
|
|
vm.loadScript(opt.code) |
56 |
|
|
); |
57 |
|
|
vector<ParserIssue> errors = parserCtx->errors(); |
58 |
schoenebeck |
3581 |
vector<ParserIssue> warnings = parserCtx->warnings(); |
59 |
schoenebeck |
3551 |
if (opt.expectParseError) { |
60 |
|
|
TEST_ASSERT(!errors.empty()); |
61 |
|
|
return; |
62 |
|
|
} else { |
63 |
|
|
for (ParserIssue& err : errors) { |
64 |
|
|
err.dump(); |
65 |
|
|
} |
66 |
|
|
TEST_ASSERT(errors.empty()); |
67 |
|
|
} |
68 |
schoenebeck |
3581 |
if (opt.expectParseWarning) { |
69 |
|
|
TEST_ASSERT(!warnings.empty()); |
70 |
|
|
} else { |
71 |
|
|
for (ParserIssue& wrn : warnings) { |
72 |
|
|
wrn.dump(); |
73 |
|
|
} |
74 |
|
|
} |
75 |
schoenebeck |
3551 |
TEST_ASSERT(parserCtx->eventHandler(0)); |
76 |
|
|
unique_ptr<VMExecContext> execCtx( |
77 |
|
|
vm.createExecContext(&*parserCtx) |
78 |
|
|
); |
79 |
|
|
for (int i = 0; parserCtx->eventHandler(i); ++i) { |
80 |
|
|
VMEventHandler* handler = parserCtx->eventHandler(i); |
81 |
|
|
VMExecStatus_t result = vm.exec(&*parserCtx, &*execCtx, handler); |
82 |
|
|
if (opt.expectRuntimeError) { |
83 |
|
|
TEST_ASSERT(result & VM_EXEC_ERROR); |
84 |
|
|
} else { |
85 |
|
|
TEST_ASSERT(!(result & VM_EXEC_ERROR)); |
86 |
|
|
} |
87 |
|
|
if (opt.expectNoExitResult) { |
88 |
|
|
VMExpr* resExpr = execCtx->exitResult(); |
89 |
|
|
TEST_ASSERT(!resExpr); |
90 |
|
|
} |
91 |
schoenebeck |
3581 |
if (opt.expectExitResultIsInt) { |
92 |
|
|
VMExpr* resExpr = execCtx->exitResult(); |
93 |
|
|
TEST_ASSERT(resExpr); |
94 |
|
|
TEST_ASSERT(resExpr->exprType() == INT_EXPR); |
95 |
|
|
} |
96 |
|
|
if (opt.expectExitResultIsReal) { |
97 |
|
|
VMExpr* resExpr = execCtx->exitResult(); |
98 |
|
|
TEST_ASSERT(resExpr); |
99 |
|
|
TEST_ASSERT(resExpr->exprType() == REAL_EXPR); |
100 |
|
|
} |
101 |
schoenebeck |
3551 |
if (opt.expectIntExitResult) { |
102 |
|
|
VMExpr* resExpr = execCtx->exitResult(); |
103 |
|
|
TEST_ASSERT(resExpr); |
104 |
|
|
TEST_ASSERT(resExpr->exprType() == INT_EXPR); |
105 |
|
|
TEST_ASSERT(resExpr->asInt()->evalInt() == *opt.expectIntExitResult); |
106 |
|
|
} |
107 |
schoenebeck |
3575 |
if (opt.expectRealExitResult) { |
108 |
|
|
VMExpr* resExpr = execCtx->exitResult(); |
109 |
|
|
TEST_ASSERT(resExpr); |
110 |
|
|
TEST_ASSERT(resExpr->exprType() == REAL_EXPR); |
111 |
|
|
if (sizeof(vmfloat) == sizeof(float)) { |
112 |
|
|
TEST_ASSERT(RTMath::fEqual32(resExpr->asReal()->evalReal(), *opt.expectRealExitResult)); |
113 |
|
|
} else { |
114 |
|
|
TEST_ASSERT(RTMath::fEqual64(resExpr->asReal()->evalReal(), *opt.expectRealExitResult)); |
115 |
|
|
} |
116 |
|
|
} |
117 |
schoenebeck |
3551 |
if (opt.expectBoolExitResult) { |
118 |
|
|
VMExpr* resExpr = execCtx->exitResult(); |
119 |
|
|
TEST_ASSERT(resExpr); |
120 |
|
|
TEST_ASSERT(resExpr->exprType() == INT_EXPR); |
121 |
|
|
TEST_ASSERT(bool(resExpr->asInt()->evalInt()) == *opt.expectBoolExitResult); |
122 |
|
|
} |
123 |
|
|
if (opt.expectStringExitResult) { |
124 |
|
|
VMExpr* resExpr = execCtx->exitResult(); |
125 |
|
|
TEST_ASSERT(resExpr); |
126 |
|
|
TEST_ASSERT(resExpr->exprType() == STRING_EXPR); |
127 |
|
|
TEST_ASSERT(resExpr->asString()->evalStr() == *opt.expectStringExitResult); |
128 |
|
|
} |
129 |
schoenebeck |
3581 |
if (opt.expectExitResultUnit) { |
130 |
|
|
VMExpr* resExpr = execCtx->exitResult(); |
131 |
|
|
TEST_ASSERT(resExpr); |
132 |
schoenebeck |
3582 |
VMNumberExpr* numberExpr = resExpr->asNumber(); |
133 |
schoenebeck |
3581 |
TEST_ASSERT(numberExpr); |
134 |
|
|
TEST_ASSERT(numberExpr->unitType() == *opt.expectExitResultUnit); |
135 |
|
|
} |
136 |
|
|
if (!opt.expectExitResultUnitPrefix.empty()) { |
137 |
|
|
VMExpr* resExpr = execCtx->exitResult(); |
138 |
|
|
TEST_ASSERT(resExpr); |
139 |
schoenebeck |
3582 |
VMNumberExpr* numberExpr = resExpr->asNumber(); |
140 |
schoenebeck |
3581 |
TEST_ASSERT(numberExpr); |
141 |
|
|
auto prefixes = opt.expectExitResultUnitPrefix; |
142 |
|
|
if (*prefixes.rbegin() != VM_NO_PREFIX) |
143 |
|
|
prefixes.push_back(VM_NO_PREFIX); // VM_NO_PREFIX termination required by unitFactr() call |
144 |
|
|
vmfloat expectedFactor = VMUnit::unitFactor(&prefixes[0]); |
145 |
|
|
vmfloat actualFactor = numberExpr->unitFactor(); |
146 |
|
|
if (sizeof(vmfloat) == sizeof(float)) { |
147 |
|
|
TEST_ASSERT(RTMath::fEqual32(expectedFactor, actualFactor)); |
148 |
|
|
} else { |
149 |
|
|
TEST_ASSERT(RTMath::fEqual64(expectedFactor, actualFactor)); |
150 |
|
|
} |
151 |
|
|
} |
152 |
|
|
if (opt.expectExitResultFinal) { |
153 |
|
|
VMExpr* resExpr = execCtx->exitResult(); |
154 |
|
|
TEST_ASSERT(resExpr); |
155 |
schoenebeck |
3582 |
VMNumberExpr* numberExpr = resExpr->asNumber(); |
156 |
schoenebeck |
3581 |
TEST_ASSERT(numberExpr); |
157 |
|
|
TEST_ASSERT(numberExpr->isFinal() == *opt.expectExitResultFinal); |
158 |
|
|
} |
159 |
schoenebeck |
3551 |
} |
160 |
|
|
} |
161 |
|
|
|
162 |
|
|
static void testBuiltInExitFunction() { |
163 |
|
|
#if !SILENT_TEST |
164 |
|
|
std::cout << "UNIT TEST: built-in exit() function\n"; |
165 |
|
|
#endif |
166 |
|
|
|
167 |
|
|
runScript({ |
168 |
|
|
.code = R"NKSP_CODE( |
169 |
|
|
on init |
170 |
|
|
end on |
171 |
|
|
)NKSP_CODE", |
172 |
|
|
.expectNoExitResult = true |
173 |
|
|
}); |
174 |
|
|
|
175 |
|
|
runScript({ |
176 |
|
|
.code = R"NKSP_CODE( |
177 |
|
|
on init |
178 |
|
|
exit |
179 |
|
|
end on |
180 |
|
|
)NKSP_CODE", |
181 |
|
|
.expectNoExitResult = true |
182 |
|
|
}); |
183 |
|
|
|
184 |
|
|
runScript({ |
185 |
|
|
.code = R"NKSP_CODE( |
186 |
|
|
on init |
187 |
|
|
exit() |
188 |
|
|
end on |
189 |
|
|
)NKSP_CODE", |
190 |
|
|
.expectNoExitResult = true |
191 |
|
|
}); |
192 |
|
|
|
193 |
schoenebeck |
3575 |
// integer tests ... |
194 |
|
|
|
195 |
schoenebeck |
3551 |
runScript({ |
196 |
|
|
.code = R"NKSP_CODE( |
197 |
|
|
on init |
198 |
|
|
exit(42) |
199 |
|
|
end on |
200 |
|
|
)NKSP_CODE", |
201 |
|
|
.expectIntExitResult = 42 |
202 |
|
|
}); |
203 |
|
|
|
204 |
|
|
runScript({ |
205 |
|
|
.code = R"NKSP_CODE( |
206 |
|
|
on init |
207 |
|
|
declare $foo := 1 |
208 |
|
|
if ($foo) |
209 |
|
|
exit(21) |
210 |
|
|
end if |
211 |
|
|
end on |
212 |
|
|
)NKSP_CODE", |
213 |
|
|
.expectIntExitResult = 21 |
214 |
|
|
}); |
215 |
|
|
|
216 |
|
|
runScript({ |
217 |
|
|
.code = R"NKSP_CODE( |
218 |
|
|
on init |
219 |
|
|
declare $foo := 0 |
220 |
|
|
if ($foo) |
221 |
|
|
exit(21) |
222 |
|
|
end if |
223 |
|
|
exit(99) |
224 |
|
|
end on |
225 |
|
|
)NKSP_CODE", |
226 |
|
|
.expectIntExitResult = 99 |
227 |
|
|
}); |
228 |
|
|
|
229 |
schoenebeck |
3575 |
// string tests ... |
230 |
|
|
|
231 |
schoenebeck |
3551 |
runScript({ |
232 |
|
|
.code = R"NKSP_CODE( |
233 |
|
|
on init |
234 |
|
|
exit("fourtytwo!") |
235 |
|
|
end on |
236 |
|
|
)NKSP_CODE", |
237 |
|
|
.expectStringExitResult = "fourtytwo!" |
238 |
|
|
}); |
239 |
|
|
|
240 |
|
|
// in production environment we prohibit the built-in exit() function to |
241 |
|
|
// accept any arguments |
242 |
|
|
runScript({ |
243 |
|
|
.code = R"NKSP_CODE( |
244 |
|
|
on init |
245 |
|
|
exit(42) |
246 |
|
|
end on |
247 |
|
|
)NKSP_CODE", |
248 |
|
|
.expectParseError = true, // see comment above why |
249 |
|
|
.prohibitExitFunctionArguments = true // simulate production environment |
250 |
|
|
}); |
251 |
|
|
|
252 |
schoenebeck |
3575 |
// real number tests ... |
253 |
|
|
|
254 |
|
|
runScript({ |
255 |
|
|
.code = R"NKSP_CODE( |
256 |
|
|
on init |
257 |
|
|
exit(3.14) |
258 |
|
|
end on |
259 |
|
|
)NKSP_CODE", |
260 |
|
|
.expectRealExitResult = 3.14 |
261 |
|
|
}); |
262 |
|
|
|
263 |
|
|
runScript({ |
264 |
|
|
.code = R"NKSP_CODE( |
265 |
|
|
on init |
266 |
|
|
declare $foo := 1 |
267 |
|
|
if ($foo) |
268 |
|
|
exit(3.14) |
269 |
|
|
end if |
270 |
|
|
end on |
271 |
|
|
)NKSP_CODE", |
272 |
|
|
.expectRealExitResult = 3.14 |
273 |
|
|
}); |
274 |
|
|
|
275 |
|
|
runScript({ |
276 |
|
|
.code = R"NKSP_CODE( |
277 |
|
|
on init |
278 |
|
|
declare $foo := 0 |
279 |
|
|
if ($foo) |
280 |
|
|
exit(3.14) |
281 |
|
|
end if |
282 |
|
|
exit(6.9) |
283 |
|
|
end on |
284 |
|
|
)NKSP_CODE", |
285 |
|
|
.expectRealExitResult = 6.9 |
286 |
|
|
}); |
287 |
|
|
|
288 |
schoenebeck |
3586 |
// int array tests ... |
289 |
|
|
|
290 |
|
|
runScript({ |
291 |
|
|
.code = R"NKSP_CODE( |
292 |
|
|
on init |
293 |
|
|
declare %foo[3] |
294 |
|
|
%foo[0] := 21 |
295 |
|
|
exit(%foo[0]) |
296 |
|
|
end on |
297 |
|
|
)NKSP_CODE", |
298 |
|
|
.expectIntExitResult = 21 |
299 |
|
|
}); |
300 |
|
|
|
301 |
|
|
runScript({ |
302 |
|
|
.code = R"NKSP_CODE( |
303 |
|
|
on init |
304 |
|
|
declare %foo[3] := ( 12, 23, 34 ) |
305 |
|
|
exit(%foo[0]) |
306 |
|
|
end on |
307 |
|
|
)NKSP_CODE", |
308 |
|
|
.expectIntExitResult = 12 |
309 |
|
|
}); |
310 |
|
|
|
311 |
|
|
runScript({ |
312 |
|
|
.code = R"NKSP_CODE( |
313 |
|
|
on init |
314 |
|
|
declare %foo[3] := ( 12, 23, 34 ) |
315 |
|
|
exit(%foo[1]) |
316 |
|
|
end on |
317 |
|
|
)NKSP_CODE", |
318 |
|
|
.expectIntExitResult = 23 |
319 |
|
|
}); |
320 |
|
|
|
321 |
|
|
runScript({ |
322 |
|
|
.code = R"NKSP_CODE( |
323 |
|
|
on init |
324 |
|
|
declare %foo[3] := ( 12, 23, 34 ) |
325 |
|
|
exit(%foo[2]) |
326 |
|
|
end on |
327 |
|
|
)NKSP_CODE", |
328 |
|
|
.expectIntExitResult = 34 |
329 |
|
|
}); |
330 |
|
|
|
331 |
|
|
runScript({ // make sure array is entirely initialized with zeroes |
332 |
|
|
.code = R"NKSP_CODE( |
333 |
|
|
on init |
334 |
|
|
declare $i |
335 |
|
|
declare $result |
336 |
|
|
declare %foo[100] |
337 |
|
|
while ($i < 100) |
338 |
|
|
$result := $result .or. %foo[$i] |
339 |
|
|
inc($i) |
340 |
|
|
end while |
341 |
|
|
exit($result) |
342 |
|
|
end on |
343 |
|
|
)NKSP_CODE", |
344 |
|
|
.expectIntExitResult = 0 |
345 |
|
|
}); |
346 |
|
|
|
347 |
|
|
// real array tests ... |
348 |
|
|
|
349 |
|
|
runScript({ |
350 |
|
|
.code = R"NKSP_CODE( |
351 |
|
|
on init |
352 |
|
|
declare ?foo[3] |
353 |
|
|
?foo[0] := 34.9 |
354 |
|
|
exit(?foo[0]) |
355 |
|
|
end on |
356 |
|
|
)NKSP_CODE", |
357 |
|
|
.expectRealExitResult = 34.9 |
358 |
|
|
}); |
359 |
|
|
|
360 |
|
|
runScript({ |
361 |
|
|
.code = R"NKSP_CODE( |
362 |
|
|
on init |
363 |
|
|
declare ?foo[3] := ( 0.3, 23.5, 900.1 ) |
364 |
|
|
exit(?foo[0]) |
365 |
|
|
end on |
366 |
|
|
)NKSP_CODE", |
367 |
|
|
.expectRealExitResult = 0.3 |
368 |
|
|
}); |
369 |
|
|
|
370 |
|
|
runScript({ |
371 |
|
|
.code = R"NKSP_CODE( |
372 |
|
|
on init |
373 |
|
|
declare ?foo[3] := ( 0.3, 23.5, 900.1 ) |
374 |
|
|
exit(?foo[1]) |
375 |
|
|
end on |
376 |
|
|
)NKSP_CODE", |
377 |
|
|
.expectRealExitResult = 23.5 |
378 |
|
|
}); |
379 |
|
|
|
380 |
|
|
runScript({ |
381 |
|
|
.code = R"NKSP_CODE( |
382 |
|
|
on init |
383 |
|
|
declare ?foo[3] := ( 0.3, 23.5, 900.1 ) |
384 |
|
|
exit(?foo[2]) |
385 |
|
|
end on |
386 |
|
|
)NKSP_CODE", |
387 |
|
|
.expectRealExitResult = 900.1 |
388 |
|
|
}); |
389 |
|
|
|
390 |
|
|
runScript({ // make sure array is entirely initialized with zeroes |
391 |
|
|
.code = R"NKSP_CODE( |
392 |
|
|
on init |
393 |
|
|
declare $i |
394 |
|
|
declare ?foo[100] |
395 |
|
|
while ($i < 100) |
396 |
|
|
if (?foo[$i] # 0.0) |
397 |
|
|
exit(-1) { test failed } |
398 |
|
|
end if |
399 |
|
|
inc($i) |
400 |
|
|
end while |
401 |
|
|
exit(0) { test succeeded } |
402 |
|
|
end on |
403 |
|
|
)NKSP_CODE", |
404 |
|
|
.expectIntExitResult = 0 |
405 |
|
|
}); |
406 |
|
|
|
407 |
schoenebeck |
3581 |
// std unit tests ... |
408 |
|
|
|
409 |
|
|
runScript({ |
410 |
|
|
.code = R"NKSP_CODE( |
411 |
|
|
on init |
412 |
|
|
exit(42s) |
413 |
|
|
end on |
414 |
|
|
)NKSP_CODE", |
415 |
|
|
.expectIntExitResult = 42, |
416 |
|
|
.expectExitResultUnit = VM_SECOND |
417 |
|
|
}); |
418 |
|
|
|
419 |
|
|
runScript({ |
420 |
|
|
.code = R"NKSP_CODE( |
421 |
|
|
on init |
422 |
|
|
exit(42Hz) |
423 |
|
|
end on |
424 |
|
|
)NKSP_CODE", |
425 |
|
|
.expectIntExitResult = 42, |
426 |
|
|
.expectExitResultUnit = VM_HERTZ |
427 |
|
|
}); |
428 |
|
|
|
429 |
|
|
runScript({ |
430 |
|
|
.code = R"NKSP_CODE( |
431 |
|
|
on init |
432 |
|
|
exit(42B) |
433 |
|
|
end on |
434 |
|
|
)NKSP_CODE", |
435 |
|
|
.expectIntExitResult = 42, |
436 |
|
|
.expectExitResultUnit = VM_BEL |
437 |
|
|
}); |
438 |
|
|
|
439 |
|
|
runScript({ |
440 |
|
|
.code = R"NKSP_CODE( |
441 |
|
|
on init |
442 |
|
|
exit(42us) |
443 |
|
|
end on |
444 |
|
|
)NKSP_CODE", |
445 |
|
|
.expectIntExitResult = 42, |
446 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
447 |
|
|
.expectExitResultUnit = VM_SECOND |
448 |
|
|
}); |
449 |
|
|
|
450 |
|
|
runScript({ |
451 |
|
|
.code = R"NKSP_CODE( |
452 |
|
|
on init |
453 |
|
|
exit(42ms) |
454 |
|
|
end on |
455 |
|
|
)NKSP_CODE", |
456 |
|
|
.expectIntExitResult = 42, |
457 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
458 |
|
|
.expectExitResultUnit = VM_SECOND |
459 |
|
|
}); |
460 |
|
|
|
461 |
|
|
runScript({ |
462 |
|
|
.code = R"NKSP_CODE( |
463 |
|
|
on init |
464 |
|
|
exit(42cs) |
465 |
|
|
end on |
466 |
|
|
)NKSP_CODE", |
467 |
|
|
.expectIntExitResult = 42, |
468 |
|
|
.expectExitResultUnitPrefix = { VM_CENTI }, |
469 |
|
|
.expectExitResultUnit = VM_SECOND |
470 |
|
|
}); |
471 |
|
|
|
472 |
|
|
runScript({ |
473 |
|
|
.code = R"NKSP_CODE( |
474 |
|
|
on init |
475 |
|
|
exit(42ds) |
476 |
|
|
end on |
477 |
|
|
)NKSP_CODE", |
478 |
|
|
.expectIntExitResult = 42, |
479 |
|
|
.expectExitResultUnitPrefix = { VM_DECI }, |
480 |
|
|
.expectExitResultUnit = VM_SECOND |
481 |
|
|
}); |
482 |
|
|
|
483 |
|
|
runScript({ |
484 |
|
|
.code = R"NKSP_CODE( |
485 |
|
|
on init |
486 |
|
|
exit(42das) |
487 |
|
|
end on |
488 |
|
|
)NKSP_CODE", |
489 |
|
|
.expectIntExitResult = 42, |
490 |
|
|
.expectExitResultUnitPrefix = { VM_DECA }, |
491 |
|
|
.expectExitResultUnit = VM_SECOND |
492 |
|
|
}); |
493 |
|
|
|
494 |
|
|
runScript({ |
495 |
|
|
.code = R"NKSP_CODE( |
496 |
|
|
on init |
497 |
|
|
exit(42hs) |
498 |
|
|
end on |
499 |
|
|
)NKSP_CODE", |
500 |
|
|
.expectIntExitResult = 42, |
501 |
|
|
.expectExitResultUnitPrefix = { VM_HECTO }, |
502 |
|
|
.expectExitResultUnit = VM_SECOND |
503 |
|
|
}); |
504 |
|
|
|
505 |
|
|
runScript({ |
506 |
|
|
.code = R"NKSP_CODE( |
507 |
|
|
on init |
508 |
|
|
exit(42ks) |
509 |
|
|
end on |
510 |
|
|
)NKSP_CODE", |
511 |
|
|
.expectIntExitResult = 42, |
512 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
513 |
|
|
.expectExitResultUnit = VM_SECOND |
514 |
|
|
}); |
515 |
|
|
|
516 |
|
|
runScript({ |
517 |
|
|
.code = R"NKSP_CODE( |
518 |
|
|
on init |
519 |
|
|
exit(42s) |
520 |
|
|
end on |
521 |
|
|
)NKSP_CODE", |
522 |
|
|
.expectIntExitResult = 42, |
523 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
524 |
|
|
.expectExitResultUnit = VM_SECOND |
525 |
|
|
}); |
526 |
|
|
|
527 |
|
|
runScript({ |
528 |
|
|
.code = R"NKSP_CODE( |
529 |
|
|
on init |
530 |
|
|
exit(42uHz) |
531 |
|
|
end on |
532 |
|
|
)NKSP_CODE", |
533 |
|
|
.expectIntExitResult = 42, |
534 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
535 |
|
|
.expectExitResultUnit = VM_HERTZ |
536 |
|
|
}); |
537 |
|
|
|
538 |
|
|
runScript({ |
539 |
|
|
.code = R"NKSP_CODE( |
540 |
|
|
on init |
541 |
|
|
exit(42mHz) |
542 |
|
|
end on |
543 |
|
|
)NKSP_CODE", |
544 |
|
|
.expectIntExitResult = 42, |
545 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
546 |
|
|
.expectExitResultUnit = VM_HERTZ |
547 |
|
|
}); |
548 |
|
|
|
549 |
|
|
runScript({ |
550 |
|
|
.code = R"NKSP_CODE( |
551 |
|
|
on init |
552 |
|
|
exit(42cHz) |
553 |
|
|
end on |
554 |
|
|
)NKSP_CODE", |
555 |
|
|
.expectIntExitResult = 42, |
556 |
|
|
.expectExitResultUnitPrefix = { VM_CENTI }, |
557 |
|
|
.expectExitResultUnit = VM_HERTZ |
558 |
|
|
}); |
559 |
|
|
|
560 |
|
|
runScript({ |
561 |
|
|
.code = R"NKSP_CODE( |
562 |
|
|
on init |
563 |
|
|
exit(42dHz) |
564 |
|
|
end on |
565 |
|
|
)NKSP_CODE", |
566 |
|
|
.expectIntExitResult = 42, |
567 |
|
|
.expectExitResultUnitPrefix = { VM_DECI }, |
568 |
|
|
.expectExitResultUnit = VM_HERTZ |
569 |
|
|
}); |
570 |
|
|
|
571 |
|
|
runScript({ |
572 |
|
|
.code = R"NKSP_CODE( |
573 |
|
|
on init |
574 |
|
|
exit(42daHz) |
575 |
|
|
end on |
576 |
|
|
)NKSP_CODE", |
577 |
|
|
.expectIntExitResult = 42, |
578 |
|
|
.expectExitResultUnitPrefix = { VM_DECA }, |
579 |
|
|
.expectExitResultUnit = VM_HERTZ |
580 |
|
|
}); |
581 |
|
|
|
582 |
|
|
runScript({ |
583 |
|
|
.code = R"NKSP_CODE( |
584 |
|
|
on init |
585 |
|
|
exit(42hHz) |
586 |
|
|
end on |
587 |
|
|
)NKSP_CODE", |
588 |
|
|
.expectIntExitResult = 42, |
589 |
|
|
.expectExitResultUnitPrefix = { VM_HECTO }, |
590 |
|
|
.expectExitResultUnit = VM_HERTZ |
591 |
|
|
}); |
592 |
|
|
|
593 |
|
|
runScript({ |
594 |
|
|
.code = R"NKSP_CODE( |
595 |
|
|
on init |
596 |
|
|
exit(42kHz) |
597 |
|
|
end on |
598 |
|
|
)NKSP_CODE", |
599 |
|
|
.expectIntExitResult = 42, |
600 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
601 |
|
|
.expectExitResultUnit = VM_HERTZ |
602 |
|
|
}); |
603 |
|
|
|
604 |
|
|
runScript({ |
605 |
|
|
.code = R"NKSP_CODE( |
606 |
|
|
on init |
607 |
|
|
exit(42Hz) |
608 |
|
|
end on |
609 |
|
|
)NKSP_CODE", |
610 |
|
|
.expectIntExitResult = 42, |
611 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
612 |
|
|
.expectExitResultUnit = VM_HERTZ |
613 |
|
|
}); |
614 |
|
|
|
615 |
|
|
runScript({ |
616 |
|
|
.code = R"NKSP_CODE( |
617 |
|
|
on init |
618 |
|
|
exit(42uB) |
619 |
|
|
end on |
620 |
|
|
)NKSP_CODE", |
621 |
|
|
.expectIntExitResult = 42, |
622 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
623 |
|
|
.expectExitResultUnit = VM_BEL |
624 |
|
|
}); |
625 |
|
|
|
626 |
|
|
runScript({ |
627 |
|
|
.code = R"NKSP_CODE( |
628 |
|
|
on init |
629 |
|
|
exit(42mB) |
630 |
|
|
end on |
631 |
|
|
)NKSP_CODE", |
632 |
|
|
.expectIntExitResult = 42, |
633 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
634 |
|
|
.expectExitResultUnit = VM_BEL |
635 |
|
|
}); |
636 |
|
|
|
637 |
|
|
runScript({ |
638 |
|
|
.code = R"NKSP_CODE( |
639 |
|
|
on init |
640 |
|
|
exit(42cB) |
641 |
|
|
end on |
642 |
|
|
)NKSP_CODE", |
643 |
|
|
.expectIntExitResult = 42, |
644 |
|
|
.expectExitResultUnitPrefix = { VM_CENTI }, |
645 |
|
|
.expectExitResultUnit = VM_BEL |
646 |
|
|
}); |
647 |
|
|
|
648 |
|
|
runScript({ |
649 |
|
|
.code = R"NKSP_CODE( |
650 |
|
|
on init |
651 |
|
|
exit(42dB) |
652 |
|
|
end on |
653 |
|
|
)NKSP_CODE", |
654 |
|
|
.expectIntExitResult = 42, |
655 |
|
|
.expectExitResultUnitPrefix = { VM_DECI }, |
656 |
|
|
.expectExitResultUnit = VM_BEL |
657 |
|
|
}); |
658 |
|
|
|
659 |
|
|
runScript({ |
660 |
|
|
.code = R"NKSP_CODE( |
661 |
|
|
on init |
662 |
|
|
exit(42daB) |
663 |
|
|
end on |
664 |
|
|
)NKSP_CODE", |
665 |
|
|
.expectIntExitResult = 42, |
666 |
|
|
.expectExitResultUnitPrefix = { VM_DECA }, |
667 |
|
|
.expectExitResultUnit = VM_BEL |
668 |
|
|
}); |
669 |
|
|
|
670 |
|
|
runScript({ |
671 |
|
|
.code = R"NKSP_CODE( |
672 |
|
|
on init |
673 |
|
|
exit(42hB) |
674 |
|
|
end on |
675 |
|
|
)NKSP_CODE", |
676 |
|
|
.expectIntExitResult = 42, |
677 |
|
|
.expectExitResultUnitPrefix = { VM_HECTO }, |
678 |
|
|
.expectExitResultUnit = VM_BEL |
679 |
|
|
}); |
680 |
|
|
|
681 |
|
|
runScript({ |
682 |
|
|
.code = R"NKSP_CODE( |
683 |
|
|
on init |
684 |
|
|
exit(42kB) |
685 |
|
|
end on |
686 |
|
|
)NKSP_CODE", |
687 |
|
|
.expectIntExitResult = 42, |
688 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
689 |
|
|
.expectExitResultUnit = VM_BEL |
690 |
|
|
}); |
691 |
|
|
|
692 |
|
|
runScript({ |
693 |
|
|
.code = R"NKSP_CODE( |
694 |
|
|
on init |
695 |
|
|
exit(42B) |
696 |
|
|
end on |
697 |
|
|
)NKSP_CODE", |
698 |
|
|
.expectIntExitResult = 42, |
699 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
700 |
|
|
.expectExitResultUnit = VM_BEL |
701 |
|
|
}); |
702 |
|
|
|
703 |
|
|
runScript({ |
704 |
|
|
.code = R"NKSP_CODE( |
705 |
|
|
on init |
706 |
|
|
exit(42udB) |
707 |
|
|
end on |
708 |
|
|
)NKSP_CODE", |
709 |
|
|
.expectIntExitResult = 42, |
710 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO, VM_DECI }, |
711 |
|
|
.expectExitResultUnit = VM_BEL |
712 |
|
|
}); |
713 |
|
|
|
714 |
|
|
runScript({ |
715 |
|
|
.code = R"NKSP_CODE( |
716 |
|
|
on init |
717 |
|
|
exit(42mdB) |
718 |
|
|
end on |
719 |
|
|
)NKSP_CODE", |
720 |
|
|
.expectIntExitResult = 42, |
721 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
722 |
|
|
.expectExitResultUnit = VM_BEL |
723 |
|
|
}); |
724 |
|
|
|
725 |
|
|
runScript({ |
726 |
|
|
.code = R"NKSP_CODE( |
727 |
|
|
on init |
728 |
|
|
exit(42cdB) |
729 |
|
|
end on |
730 |
|
|
)NKSP_CODE", |
731 |
|
|
.expectIntExitResult = 42, |
732 |
|
|
.expectExitResultUnitPrefix = { VM_CENTI, VM_DECI }, |
733 |
|
|
.expectExitResultUnit = VM_BEL |
734 |
|
|
}); |
735 |
|
|
|
736 |
|
|
runScript({ |
737 |
|
|
.code = R"NKSP_CODE( |
738 |
|
|
on init |
739 |
|
|
exit(42ddB) |
740 |
|
|
end on |
741 |
|
|
)NKSP_CODE", |
742 |
|
|
.expectIntExitResult = 42, |
743 |
|
|
.expectExitResultUnitPrefix = { VM_DECI, VM_DECI }, |
744 |
|
|
.expectExitResultUnit = VM_BEL |
745 |
|
|
}); |
746 |
|
|
|
747 |
|
|
runScript({ |
748 |
|
|
.code = R"NKSP_CODE( |
749 |
|
|
on init |
750 |
|
|
exit(42dadB) |
751 |
|
|
end on |
752 |
|
|
)NKSP_CODE", |
753 |
|
|
.expectIntExitResult = 42, |
754 |
|
|
.expectExitResultUnitPrefix = { VM_DECA, VM_DECI }, |
755 |
|
|
.expectExitResultUnit = VM_BEL |
756 |
|
|
}); |
757 |
|
|
|
758 |
|
|
runScript({ |
759 |
|
|
.code = R"NKSP_CODE( |
760 |
|
|
on init |
761 |
|
|
exit(42hdB) |
762 |
|
|
end on |
763 |
|
|
)NKSP_CODE", |
764 |
|
|
.expectIntExitResult = 42, |
765 |
|
|
.expectExitResultUnitPrefix = { VM_HECTO, VM_DECI }, |
766 |
|
|
.expectExitResultUnit = VM_BEL |
767 |
|
|
}); |
768 |
|
|
|
769 |
|
|
runScript({ |
770 |
|
|
.code = R"NKSP_CODE( |
771 |
|
|
on init |
772 |
|
|
exit(42kdB) |
773 |
|
|
end on |
774 |
|
|
)NKSP_CODE", |
775 |
|
|
.expectIntExitResult = 42, |
776 |
|
|
.expectExitResultUnitPrefix = { VM_KILO, VM_DECI }, |
777 |
|
|
.expectExitResultUnit = VM_BEL |
778 |
|
|
}); |
779 |
|
|
|
780 |
|
|
runScript({ |
781 |
|
|
.code = R"NKSP_CODE( |
782 |
|
|
on init |
783 |
|
|
declare $foo := 42mdB |
784 |
|
|
exit($foo) |
785 |
|
|
end on |
786 |
|
|
)NKSP_CODE", |
787 |
|
|
.expectIntExitResult = 42, |
788 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
789 |
|
|
.expectExitResultUnit = VM_BEL |
790 |
|
|
}); |
791 |
|
|
|
792 |
|
|
runScript({ |
793 |
|
|
.code = R"NKSP_CODE( |
794 |
|
|
on init |
795 |
|
|
exit(3.14s) |
796 |
|
|
end on |
797 |
|
|
)NKSP_CODE", |
798 |
|
|
.expectRealExitResult = 3.14, |
799 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
800 |
|
|
.expectExitResultUnit = VM_SECOND |
801 |
|
|
}); |
802 |
|
|
|
803 |
|
|
runScript({ |
804 |
|
|
.code = R"NKSP_CODE( |
805 |
|
|
on init |
806 |
|
|
exit(3.14us) |
807 |
|
|
end on |
808 |
|
|
)NKSP_CODE", |
809 |
|
|
.expectRealExitResult = 3.14, |
810 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
811 |
|
|
.expectExitResultUnit = VM_SECOND |
812 |
|
|
}); |
813 |
|
|
|
814 |
|
|
runScript({ |
815 |
|
|
.code = R"NKSP_CODE( |
816 |
|
|
on init |
817 |
|
|
exit(3.14ms) |
818 |
|
|
end on |
819 |
|
|
)NKSP_CODE", |
820 |
|
|
.expectRealExitResult = 3.14, |
821 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
822 |
|
|
.expectExitResultUnit = VM_SECOND |
823 |
|
|
}); |
824 |
|
|
|
825 |
|
|
runScript({ |
826 |
|
|
.code = R"NKSP_CODE( |
827 |
|
|
on init |
828 |
|
|
exit(-0.1B) |
829 |
|
|
end on |
830 |
|
|
)NKSP_CODE", |
831 |
|
|
.expectRealExitResult = -0.1, |
832 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
833 |
|
|
.expectExitResultUnit = VM_BEL |
834 |
|
|
}); |
835 |
|
|
|
836 |
|
|
runScript({ |
837 |
|
|
.code = R"NKSP_CODE( |
838 |
|
|
on init |
839 |
|
|
exit(-0.1dB) |
840 |
|
|
end on |
841 |
|
|
)NKSP_CODE", |
842 |
|
|
.expectRealExitResult = -0.1, |
843 |
|
|
.expectExitResultUnitPrefix = { VM_DECI }, |
844 |
|
|
.expectExitResultUnit = VM_BEL |
845 |
|
|
}); |
846 |
|
|
|
847 |
|
|
runScript({ |
848 |
|
|
.code = R"NKSP_CODE( |
849 |
|
|
on init |
850 |
|
|
exit(-0.1mdB) |
851 |
|
|
end on |
852 |
|
|
)NKSP_CODE", |
853 |
|
|
.expectRealExitResult = -0.1, |
854 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
855 |
|
|
.expectExitResultUnit = VM_BEL |
856 |
|
|
}); |
857 |
|
|
|
858 |
|
|
runScript({ |
859 |
|
|
.code = R"NKSP_CODE( |
860 |
|
|
on init |
861 |
|
|
declare ~foo := -0.1mdB |
862 |
|
|
exit(~foo) |
863 |
|
|
end on |
864 |
|
|
)NKSP_CODE", |
865 |
|
|
.expectRealExitResult = -0.1, |
866 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
867 |
|
|
.expectExitResultUnit = VM_BEL |
868 |
|
|
}); |
869 |
|
|
|
870 |
|
|
runScript({ |
871 |
|
|
.code = R"NKSP_CODE( |
872 |
|
|
on init |
873 |
|
|
declare ~foo := 0.0dB |
874 |
|
|
~foo := -0.1mdB |
875 |
|
|
exit(~foo) |
876 |
|
|
end on |
877 |
|
|
)NKSP_CODE", |
878 |
|
|
.expectRealExitResult = -0.1, |
879 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
880 |
|
|
.expectExitResultUnit = VM_BEL |
881 |
|
|
}); |
882 |
|
|
|
883 |
|
|
runScript({ |
884 |
|
|
.code = R"NKSP_CODE( |
885 |
|
|
on init |
886 |
|
|
declare ~foo := 0.0dB |
887 |
|
|
~foo := -0.1Hz |
888 |
|
|
exit(~foo) |
889 |
|
|
end on |
890 |
|
|
)NKSP_CODE", |
891 |
|
|
.expectParseError = true // assigning different unit type to a variable is not allowed |
892 |
|
|
}); |
893 |
|
|
|
894 |
|
|
// 'final' ('!') operator tests ... |
895 |
|
|
|
896 |
|
|
runScript({ |
897 |
|
|
.code = R"NKSP_CODE( |
898 |
|
|
on init |
899 |
|
|
exit(!42) |
900 |
|
|
end on |
901 |
|
|
)NKSP_CODE", |
902 |
|
|
.expectIntExitResult = 42, |
903 |
|
|
.expectExitResultFinal = true |
904 |
|
|
}); |
905 |
|
|
|
906 |
|
|
runScript({ |
907 |
|
|
.code = R"NKSP_CODE( |
908 |
|
|
on init |
909 |
|
|
exit(42) |
910 |
|
|
end on |
911 |
|
|
)NKSP_CODE", |
912 |
|
|
.expectIntExitResult = 42, |
913 |
|
|
.expectExitResultFinal = false |
914 |
|
|
}); |
915 |
|
|
|
916 |
|
|
runScript({ |
917 |
|
|
.code = R"NKSP_CODE( |
918 |
|
|
on init |
919 |
|
|
declare $foo := !42 |
920 |
|
|
exit($foo) |
921 |
|
|
end on |
922 |
|
|
)NKSP_CODE", |
923 |
|
|
.expectIntExitResult = 42, |
924 |
|
|
.expectExitResultFinal = true |
925 |
|
|
}); |
926 |
|
|
|
927 |
|
|
runScript({ |
928 |
|
|
.code = R"NKSP_CODE( |
929 |
|
|
on init |
930 |
|
|
declare $foo := 42 |
931 |
|
|
exit($foo) |
932 |
|
|
end on |
933 |
|
|
)NKSP_CODE", |
934 |
|
|
.expectIntExitResult = 42, |
935 |
|
|
.expectExitResultFinal = false |
936 |
|
|
}); |
937 |
|
|
|
938 |
|
|
runScript({ |
939 |
|
|
.code = R"NKSP_CODE( |
940 |
|
|
on init |
941 |
|
|
declare ~foo := !3.14 |
942 |
|
|
exit(~foo) |
943 |
|
|
end on |
944 |
|
|
)NKSP_CODE", |
945 |
|
|
.expectRealExitResult = 3.14, |
946 |
|
|
.expectExitResultFinal = true |
947 |
|
|
}); |
948 |
|
|
|
949 |
|
|
runScript({ |
950 |
|
|
.code = R"NKSP_CODE( |
951 |
|
|
on init |
952 |
|
|
declare ~foo := 3.14 |
953 |
|
|
exit(~foo) |
954 |
|
|
end on |
955 |
|
|
)NKSP_CODE", |
956 |
|
|
.expectRealExitResult = 3.14, |
957 |
|
|
.expectExitResultFinal = false |
958 |
|
|
}); |
959 |
|
|
|
960 |
|
|
runScript({ |
961 |
|
|
.code = R"NKSP_CODE( |
962 |
|
|
on init |
963 |
|
|
declare ~foo := !3.14mdB |
964 |
|
|
exit(~foo) |
965 |
|
|
end on |
966 |
|
|
)NKSP_CODE", |
967 |
|
|
.expectRealExitResult = 3.14, |
968 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
969 |
|
|
.expectExitResultUnit = VM_BEL, |
970 |
|
|
.expectExitResultFinal = true |
971 |
|
|
}); |
972 |
|
|
|
973 |
|
|
runScript({ |
974 |
|
|
.code = R"NKSP_CODE( |
975 |
|
|
on init |
976 |
|
|
declare ~foo := !0.0mdB |
977 |
|
|
~foo := !3.14mdB |
978 |
|
|
exit(~foo) |
979 |
|
|
end on |
980 |
|
|
)NKSP_CODE", |
981 |
|
|
.expectRealExitResult = 3.14, |
982 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
983 |
|
|
.expectExitResultUnit = VM_BEL, |
984 |
|
|
.expectExitResultFinal = true |
985 |
|
|
}); |
986 |
|
|
|
987 |
|
|
runScript({ |
988 |
|
|
.code = R"NKSP_CODE( |
989 |
|
|
on init |
990 |
|
|
declare ~foo := !0.0mdB |
991 |
|
|
~foo := 3.14mdB |
992 |
|
|
exit(~foo) |
993 |
|
|
end on |
994 |
|
|
)NKSP_CODE", |
995 |
|
|
.expectParseError = true // assigning non-final to a final variable not allowed |
996 |
|
|
}); |
997 |
|
|
|
998 |
|
|
runScript({ |
999 |
|
|
.code = R"NKSP_CODE( |
1000 |
|
|
on init |
1001 |
|
|
declare ~foo := 0.0mdB |
1002 |
|
|
~foo := !3.14mdB |
1003 |
|
|
exit(~foo) |
1004 |
|
|
end on |
1005 |
|
|
)NKSP_CODE", |
1006 |
|
|
.expectParseError = true // assigning final to a non-final variable not allowed |
1007 |
|
|
}); |
1008 |
|
|
|
1009 |
schoenebeck |
3551 |
#if !SILENT_TEST |
1010 |
|
|
std::cout << std::endl; |
1011 |
|
|
#endif |
1012 |
|
|
} |
1013 |
|
|
|
1014 |
|
|
static void testStringConcatOperator() { |
1015 |
|
|
#if !SILENT_TEST |
1016 |
|
|
std::cout << "UNIT TEST: string concatenation (&) operator\n"; |
1017 |
|
|
#endif |
1018 |
|
|
|
1019 |
schoenebeck |
3581 |
// strings only tests ... |
1020 |
|
|
|
1021 |
schoenebeck |
3551 |
runScript({ |
1022 |
|
|
.code = R"NKSP_CODE( |
1023 |
|
|
on init |
1024 |
|
|
declare @s := "foo" & " bar" |
1025 |
|
|
exit(@s) |
1026 |
|
|
end on |
1027 |
|
|
)NKSP_CODE", |
1028 |
|
|
.expectStringExitResult = "foo bar" |
1029 |
|
|
}); |
1030 |
|
|
|
1031 |
schoenebeck |
3581 |
// integer tests ... |
1032 |
|
|
|
1033 |
schoenebeck |
3551 |
runScript({ |
1034 |
|
|
.code = R"NKSP_CODE( |
1035 |
|
|
on init |
1036 |
|
|
declare @s := "foo" & " bar" & " " & 123 |
1037 |
|
|
exit(@s) |
1038 |
|
|
end on |
1039 |
|
|
)NKSP_CODE", |
1040 |
|
|
.expectStringExitResult = "foo bar 123" |
1041 |
|
|
}); |
1042 |
|
|
|
1043 |
|
|
runScript({ |
1044 |
|
|
.code = R"NKSP_CODE( |
1045 |
|
|
on init |
1046 |
|
|
declare $i := 123 |
1047 |
|
|
declare @s := "foo" & " bar" & " " & $i |
1048 |
|
|
exit(@s) |
1049 |
|
|
end on |
1050 |
|
|
)NKSP_CODE", |
1051 |
|
|
.expectStringExitResult = "foo bar 123" |
1052 |
|
|
}); |
1053 |
|
|
|
1054 |
schoenebeck |
3581 |
// real number tests ... |
1055 |
|
|
|
1056 |
|
|
runScript({ |
1057 |
|
|
.code = R"NKSP_CODE( |
1058 |
|
|
on init |
1059 |
|
|
declare @s := "foo" & " bar" & " " & 1.23 |
1060 |
|
|
exit(@s) |
1061 |
|
|
end on |
1062 |
|
|
)NKSP_CODE", |
1063 |
|
|
.expectStringExitResult = "foo bar 1.23" |
1064 |
|
|
}); |
1065 |
|
|
|
1066 |
|
|
runScript({ |
1067 |
|
|
.code = R"NKSP_CODE( |
1068 |
|
|
on init |
1069 |
|
|
declare ~r := 3.14 |
1070 |
|
|
declare @s := "foo" & " bar" & " " & ~r |
1071 |
|
|
exit(@s) |
1072 |
|
|
end on |
1073 |
|
|
)NKSP_CODE", |
1074 |
|
|
.expectStringExitResult = "foo bar 3.14" |
1075 |
|
|
}); |
1076 |
|
|
|
1077 |
|
|
// std unit tests ... |
1078 |
|
|
|
1079 |
|
|
runScript({ |
1080 |
|
|
.code = R"NKSP_CODE( |
1081 |
|
|
on init |
1082 |
|
|
declare $i := 500Hz |
1083 |
|
|
declare @s := "foo" & " bar" & " " & $i |
1084 |
|
|
exit(@s) |
1085 |
|
|
end on |
1086 |
|
|
)NKSP_CODE", |
1087 |
|
|
.expectStringExitResult = "foo bar 500Hz" |
1088 |
|
|
}); |
1089 |
|
|
|
1090 |
|
|
runScript({ |
1091 |
|
|
.code = R"NKSP_CODE( |
1092 |
|
|
on init |
1093 |
|
|
declare ~r := 3.14s |
1094 |
|
|
declare @s := "foo" & " bar" & " " & ~r |
1095 |
|
|
exit(@s) |
1096 |
|
|
end on |
1097 |
|
|
)NKSP_CODE", |
1098 |
|
|
.expectStringExitResult = "foo bar 3.14s" |
1099 |
|
|
}); |
1100 |
|
|
|
1101 |
|
|
runScript({ |
1102 |
|
|
.code = R"NKSP_CODE( |
1103 |
|
|
on init |
1104 |
|
|
declare ~r := -22.3mdB |
1105 |
|
|
declare @s := "foo" & " bar" & " " & ~r |
1106 |
|
|
exit(@s) |
1107 |
|
|
end on |
1108 |
|
|
)NKSP_CODE", |
1109 |
|
|
.expectStringExitResult = "foo bar -22.3mdB" |
1110 |
|
|
}); |
1111 |
|
|
|
1112 |
|
|
runScript({ |
1113 |
|
|
.code = R"NKSP_CODE( |
1114 |
|
|
on init |
1115 |
|
|
declare $i := 20us |
1116 |
|
|
declare @s := "foo" & " bar" & " " & $i |
1117 |
|
|
exit(@s) |
1118 |
|
|
end on |
1119 |
|
|
)NKSP_CODE", |
1120 |
|
|
.expectStringExitResult = "foo bar 20us" |
1121 |
|
|
}); |
1122 |
|
|
|
1123 |
|
|
runScript({ |
1124 |
|
|
.code = R"NKSP_CODE( |
1125 |
|
|
on init |
1126 |
|
|
declare $i := 20kHz |
1127 |
|
|
declare @s := "foo" & " bar" & " " & $i |
1128 |
|
|
exit(@s) |
1129 |
|
|
end on |
1130 |
|
|
)NKSP_CODE", |
1131 |
|
|
.expectStringExitResult = "foo bar 20kHz" |
1132 |
|
|
}); |
1133 |
|
|
|
1134 |
|
|
runScript({ |
1135 |
|
|
.code = R"NKSP_CODE( |
1136 |
|
|
on init |
1137 |
|
|
declare $i := -6dB |
1138 |
|
|
declare @s := "foo" & " bar" & " " & $i |
1139 |
|
|
exit(@s) |
1140 |
|
|
end on |
1141 |
|
|
)NKSP_CODE", |
1142 |
|
|
.expectStringExitResult = "foo bar -6dB" |
1143 |
|
|
}); |
1144 |
|
|
|
1145 |
|
|
runScript({ |
1146 |
|
|
.code = R"NKSP_CODE( |
1147 |
|
|
on init |
1148 |
|
|
declare $i := 1us * 1d |
1149 |
|
|
declare @s := "foo" & " bar" & " " & $i |
1150 |
|
|
exit(@s) |
1151 |
|
|
end on |
1152 |
|
|
)NKSP_CODE", |
1153 |
|
|
.expectStringExitResult = "foo bar 1*10^-7s" |
1154 |
|
|
}); |
1155 |
|
|
|
1156 |
|
|
runScript({ |
1157 |
|
|
.code = R"NKSP_CODE( |
1158 |
|
|
on init |
1159 |
|
|
declare ~r := 12.4mc |
1160 |
|
|
declare @s := "foo" & " bar" & " " & ~r |
1161 |
|
|
exit(@s) |
1162 |
|
|
end on |
1163 |
|
|
)NKSP_CODE", |
1164 |
|
|
.expectStringExitResult = "foo bar 12.4mc" |
1165 |
|
|
}); |
1166 |
|
|
|
1167 |
schoenebeck |
3551 |
#if !SILENT_TEST |
1168 |
|
|
std::cout << std::endl; |
1169 |
|
|
#endif |
1170 |
|
|
} |
1171 |
|
|
|
1172 |
schoenebeck |
3575 |
static void testNegOperator() { |
1173 |
|
|
#if !SILENT_TEST |
1174 |
|
|
std::cout << "UNIT TEST: negate (-) operator\n"; |
1175 |
|
|
#endif |
1176 |
|
|
|
1177 |
|
|
// integer tests ... |
1178 |
|
|
|
1179 |
|
|
runScript({ |
1180 |
|
|
.code = R"NKSP_CODE( |
1181 |
|
|
on init |
1182 |
|
|
exit(-87) |
1183 |
|
|
end on |
1184 |
|
|
)NKSP_CODE", |
1185 |
|
|
.expectIntExitResult = -87 |
1186 |
|
|
}); |
1187 |
|
|
|
1188 |
|
|
runScript({ |
1189 |
|
|
.code = R"NKSP_CODE( |
1190 |
|
|
on init |
1191 |
|
|
declare $foo := -87 |
1192 |
|
|
exit(-$foo) |
1193 |
|
|
end on |
1194 |
|
|
)NKSP_CODE", |
1195 |
|
|
.expectIntExitResult = 87 |
1196 |
|
|
}); |
1197 |
|
|
|
1198 |
|
|
// real number tests ... |
1199 |
|
|
|
1200 |
|
|
runScript({ |
1201 |
|
|
.code = R"NKSP_CODE( |
1202 |
|
|
on init |
1203 |
|
|
exit(-99.3) |
1204 |
|
|
end on |
1205 |
|
|
)NKSP_CODE", |
1206 |
|
|
.expectRealExitResult = -99.3 |
1207 |
|
|
}); |
1208 |
|
|
|
1209 |
|
|
runScript({ |
1210 |
|
|
.code = R"NKSP_CODE( |
1211 |
|
|
on init |
1212 |
|
|
declare ~foo := -99.3 |
1213 |
|
|
exit(-~foo) |
1214 |
|
|
end on |
1215 |
|
|
)NKSP_CODE", |
1216 |
|
|
.expectRealExitResult = 99.3 |
1217 |
|
|
}); |
1218 |
|
|
|
1219 |
schoenebeck |
3581 |
// std unit tests |
1220 |
|
|
|
1221 |
|
|
runScript({ |
1222 |
|
|
.code = R"NKSP_CODE( |
1223 |
|
|
on init |
1224 |
|
|
declare $foo := -87mdB |
1225 |
|
|
exit(-$foo) |
1226 |
|
|
end on |
1227 |
|
|
)NKSP_CODE", |
1228 |
|
|
.expectIntExitResult = 87, |
1229 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
1230 |
|
|
.expectExitResultUnit = VM_BEL |
1231 |
|
|
}); |
1232 |
|
|
|
1233 |
|
|
// 'final' ('!') operator tests ... |
1234 |
|
|
|
1235 |
|
|
runScript({ |
1236 |
|
|
.code = R"NKSP_CODE( |
1237 |
|
|
on init |
1238 |
|
|
declare $foo := !-87 |
1239 |
|
|
exit(-$foo) |
1240 |
|
|
end on |
1241 |
|
|
)NKSP_CODE", |
1242 |
|
|
.expectIntExitResult = 87, |
1243 |
|
|
.expectExitResultFinal = true |
1244 |
|
|
}); |
1245 |
|
|
|
1246 |
|
|
runScript({ |
1247 |
|
|
.code = R"NKSP_CODE( |
1248 |
|
|
on init |
1249 |
|
|
declare $foo := -87 |
1250 |
|
|
exit(-$foo) |
1251 |
|
|
end on |
1252 |
|
|
)NKSP_CODE", |
1253 |
|
|
.expectIntExitResult = 87, |
1254 |
|
|
.expectExitResultFinal = false |
1255 |
|
|
}); |
1256 |
|
|
|
1257 |
schoenebeck |
3575 |
#if !SILENT_TEST |
1258 |
|
|
std::cout << std::endl; |
1259 |
|
|
#endif |
1260 |
|
|
} |
1261 |
|
|
|
1262 |
schoenebeck |
3551 |
static void testPlusOperator() { |
1263 |
|
|
#if !SILENT_TEST |
1264 |
|
|
std::cout << "UNIT TEST: plus (+) operator\n"; |
1265 |
|
|
#endif |
1266 |
|
|
|
1267 |
schoenebeck |
3575 |
// integer tests ... |
1268 |
|
|
|
1269 |
schoenebeck |
3551 |
runScript({ |
1270 |
|
|
.code = R"NKSP_CODE( |
1271 |
|
|
on init |
1272 |
|
|
exit(4 + 3) |
1273 |
|
|
end on |
1274 |
|
|
)NKSP_CODE", |
1275 |
|
|
.expectIntExitResult = 7 |
1276 |
|
|
}); |
1277 |
|
|
|
1278 |
|
|
runScript({ |
1279 |
|
|
.code = R"NKSP_CODE( |
1280 |
|
|
on init |
1281 |
|
|
exit(42 + 145) |
1282 |
|
|
end on |
1283 |
|
|
)NKSP_CODE", |
1284 |
|
|
.expectIntExitResult = 187 |
1285 |
|
|
}); |
1286 |
|
|
|
1287 |
|
|
runScript({ |
1288 |
|
|
.code = R"NKSP_CODE( |
1289 |
|
|
on init |
1290 |
|
|
exit(-4 + 2) |
1291 |
|
|
end on |
1292 |
|
|
)NKSP_CODE", |
1293 |
|
|
.expectIntExitResult = -2 |
1294 |
|
|
}); |
1295 |
|
|
|
1296 |
schoenebeck |
3575 |
// real number tests ... |
1297 |
|
|
|
1298 |
|
|
runScript({ |
1299 |
|
|
.code = R"NKSP_CODE( |
1300 |
|
|
on init |
1301 |
|
|
exit(4.0 + 3.0) |
1302 |
|
|
end on |
1303 |
|
|
)NKSP_CODE", |
1304 |
|
|
.expectRealExitResult = 7.0 |
1305 |
|
|
}); |
1306 |
|
|
|
1307 |
|
|
runScript({ |
1308 |
|
|
.code = R"NKSP_CODE( |
1309 |
|
|
on init |
1310 |
|
|
exit(42.3 + 145.2) |
1311 |
|
|
end on |
1312 |
|
|
)NKSP_CODE", |
1313 |
|
|
.expectRealExitResult = 187.5 |
1314 |
|
|
}); |
1315 |
|
|
|
1316 |
|
|
runScript({ |
1317 |
|
|
.code = R"NKSP_CODE( |
1318 |
|
|
on init |
1319 |
|
|
exit(-4.0 + 2.2) |
1320 |
|
|
end on |
1321 |
|
|
)NKSP_CODE", |
1322 |
|
|
.expectRealExitResult = -1.8 |
1323 |
|
|
}); |
1324 |
|
|
|
1325 |
schoenebeck |
3581 |
// std unit tests ... |
1326 |
|
|
|
1327 |
|
|
runScript({ |
1328 |
|
|
.code = R"NKSP_CODE( |
1329 |
|
|
on init |
1330 |
|
|
exit(42ms + 145ms) |
1331 |
|
|
end on |
1332 |
|
|
)NKSP_CODE", |
1333 |
|
|
.expectIntExitResult = 187, |
1334 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1335 |
|
|
.expectExitResultUnit = VM_SECOND |
1336 |
|
|
}); |
1337 |
|
|
|
1338 |
|
|
runScript({ |
1339 |
|
|
.code = R"NKSP_CODE( |
1340 |
|
|
on init |
1341 |
|
|
exit(1s + 145ms) |
1342 |
|
|
end on |
1343 |
|
|
)NKSP_CODE", |
1344 |
|
|
.expectIntExitResult = 1145, |
1345 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1346 |
|
|
.expectExitResultUnit = VM_SECOND |
1347 |
|
|
}); |
1348 |
|
|
|
1349 |
|
|
runScript({ |
1350 |
|
|
.code = R"NKSP_CODE( |
1351 |
|
|
on init |
1352 |
|
|
exit(42ms + 145) |
1353 |
|
|
end on |
1354 |
|
|
)NKSP_CODE", |
1355 |
|
|
.expectParseError = true // units must match for + operator |
1356 |
|
|
}); |
1357 |
|
|
|
1358 |
|
|
runScript({ |
1359 |
|
|
.code = R"NKSP_CODE( |
1360 |
|
|
on init |
1361 |
|
|
exit(42 + 145ms) |
1362 |
|
|
end on |
1363 |
|
|
)NKSP_CODE", |
1364 |
|
|
.expectParseError = true // units must match for + operator |
1365 |
|
|
}); |
1366 |
|
|
|
1367 |
|
|
runScript({ |
1368 |
|
|
.code = R"NKSP_CODE( |
1369 |
|
|
on init |
1370 |
|
|
exit(42Hz + 145s) |
1371 |
|
|
end on |
1372 |
|
|
)NKSP_CODE", |
1373 |
|
|
.expectParseError = true // units must match for + operator |
1374 |
|
|
}); |
1375 |
|
|
|
1376 |
|
|
runScript({ |
1377 |
|
|
.code = R"NKSP_CODE( |
1378 |
|
|
on init |
1379 |
|
|
exit(42.1ms + 145.3ms) |
1380 |
|
|
end on |
1381 |
|
|
)NKSP_CODE", |
1382 |
|
|
.expectRealExitResult = 187.4, |
1383 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1384 |
|
|
.expectExitResultUnit = VM_SECOND |
1385 |
|
|
}); |
1386 |
|
|
|
1387 |
|
|
runScript({ |
1388 |
|
|
.code = R"NKSP_CODE( |
1389 |
|
|
on init |
1390 |
|
|
exit(1.1s + 145.0ms) |
1391 |
|
|
end on |
1392 |
|
|
)NKSP_CODE", |
1393 |
|
|
.expectRealExitResult = 1245.0, |
1394 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1395 |
|
|
.expectExitResultUnit = VM_SECOND |
1396 |
|
|
}); |
1397 |
|
|
|
1398 |
|
|
runScript({ |
1399 |
|
|
.code = R"NKSP_CODE( |
1400 |
|
|
on init |
1401 |
|
|
exit(42.1ms + 145.3) |
1402 |
|
|
end on |
1403 |
|
|
)NKSP_CODE", |
1404 |
|
|
.expectParseError = true // units must match for + operator |
1405 |
|
|
}); |
1406 |
|
|
|
1407 |
|
|
runScript({ |
1408 |
|
|
.code = R"NKSP_CODE( |
1409 |
|
|
on init |
1410 |
|
|
exit(42.0 + 145.0ms) |
1411 |
|
|
end on |
1412 |
|
|
)NKSP_CODE", |
1413 |
|
|
.expectParseError = true // units must match for + operator |
1414 |
|
|
}); |
1415 |
|
|
|
1416 |
|
|
runScript({ |
1417 |
|
|
.code = R"NKSP_CODE( |
1418 |
|
|
on init |
1419 |
|
|
exit(42.0Hz + 145.0s) |
1420 |
|
|
end on |
1421 |
|
|
)NKSP_CODE", |
1422 |
|
|
.expectParseError = true // units must match for + operator |
1423 |
|
|
}); |
1424 |
|
|
|
1425 |
|
|
// 'final' ('!') operator tests ... |
1426 |
|
|
|
1427 |
|
|
runScript({ |
1428 |
|
|
.code = R"NKSP_CODE( |
1429 |
|
|
on init |
1430 |
|
|
exit(!4 + !3) |
1431 |
|
|
end on |
1432 |
|
|
)NKSP_CODE", |
1433 |
|
|
.expectIntExitResult = 7, |
1434 |
|
|
.expectExitResultFinal = true |
1435 |
|
|
}); |
1436 |
|
|
|
1437 |
|
|
runScript({ |
1438 |
|
|
.code = R"NKSP_CODE( |
1439 |
|
|
on init |
1440 |
|
|
exit(4 + 3) |
1441 |
|
|
end on |
1442 |
|
|
)NKSP_CODE", |
1443 |
|
|
.expectIntExitResult = 7, |
1444 |
|
|
.expectExitResultFinal = false |
1445 |
|
|
}); |
1446 |
|
|
|
1447 |
|
|
runScript({ |
1448 |
|
|
.code = R"NKSP_CODE( |
1449 |
|
|
on init |
1450 |
|
|
exit(!4.1 + !3.3) |
1451 |
|
|
end on |
1452 |
|
|
)NKSP_CODE", |
1453 |
|
|
.expectRealExitResult = 7.4, |
1454 |
|
|
.expectExitResultFinal = true |
1455 |
|
|
}); |
1456 |
|
|
|
1457 |
|
|
runScript({ |
1458 |
|
|
.code = R"NKSP_CODE( |
1459 |
|
|
on init |
1460 |
|
|
exit(4.1 + 3.3) |
1461 |
|
|
end on |
1462 |
|
|
)NKSP_CODE", |
1463 |
|
|
.expectRealExitResult = 7.4, |
1464 |
|
|
.expectExitResultFinal = false |
1465 |
|
|
}); |
1466 |
|
|
|
1467 |
schoenebeck |
3551 |
#if !SILENT_TEST |
1468 |
|
|
std::cout << std::endl; |
1469 |
|
|
#endif |
1470 |
|
|
} |
1471 |
|
|
|
1472 |
|
|
static void testMinusOperator() { |
1473 |
|
|
#if !SILENT_TEST |
1474 |
|
|
std::cout << "UNIT TEST: minus (-) operator\n"; |
1475 |
|
|
#endif |
1476 |
|
|
|
1477 |
schoenebeck |
3575 |
// integer tests ... |
1478 |
|
|
|
1479 |
schoenebeck |
3551 |
runScript({ |
1480 |
|
|
.code = R"NKSP_CODE( |
1481 |
|
|
on init |
1482 |
|
|
exit(4 - 3) |
1483 |
|
|
end on |
1484 |
|
|
)NKSP_CODE", |
1485 |
|
|
.expectIntExitResult = 1 |
1486 |
|
|
}); |
1487 |
|
|
|
1488 |
|
|
runScript({ |
1489 |
|
|
.code = R"NKSP_CODE( |
1490 |
|
|
on init |
1491 |
|
|
exit(139 - 74) |
1492 |
|
|
end on |
1493 |
|
|
)NKSP_CODE", |
1494 |
|
|
.expectIntExitResult = 65 |
1495 |
|
|
}); |
1496 |
|
|
|
1497 |
|
|
runScript({ |
1498 |
|
|
.code = R"NKSP_CODE( |
1499 |
|
|
on init |
1500 |
|
|
exit(3 - 9) |
1501 |
|
|
end on |
1502 |
|
|
)NKSP_CODE", |
1503 |
|
|
.expectIntExitResult = -6 |
1504 |
|
|
}); |
1505 |
|
|
|
1506 |
|
|
runScript({ |
1507 |
|
|
.code = R"NKSP_CODE( |
1508 |
|
|
on init |
1509 |
|
|
exit(-3 - 18) |
1510 |
|
|
end on |
1511 |
|
|
)NKSP_CODE", |
1512 |
|
|
.expectIntExitResult = -21 |
1513 |
|
|
}); |
1514 |
|
|
|
1515 |
schoenebeck |
3575 |
// real number tests ... |
1516 |
|
|
|
1517 |
|
|
runScript({ |
1518 |
|
|
.code = R"NKSP_CODE( |
1519 |
|
|
on init |
1520 |
|
|
exit(4.0 - 0.2) |
1521 |
|
|
end on |
1522 |
|
|
)NKSP_CODE", |
1523 |
|
|
.expectRealExitResult = 3.8 |
1524 |
|
|
}); |
1525 |
|
|
|
1526 |
|
|
runScript({ |
1527 |
|
|
.code = R"NKSP_CODE( |
1528 |
|
|
on init |
1529 |
|
|
exit(3.1 - 9.65) |
1530 |
|
|
end on |
1531 |
|
|
)NKSP_CODE", |
1532 |
|
|
.expectRealExitResult = -6.55 |
1533 |
|
|
}); |
1534 |
|
|
|
1535 |
|
|
runScript({ |
1536 |
|
|
.code = R"NKSP_CODE( |
1537 |
|
|
on init |
1538 |
|
|
exit(-3.0 - 18.1) |
1539 |
|
|
end on |
1540 |
|
|
)NKSP_CODE", |
1541 |
|
|
.expectRealExitResult = -21.1 |
1542 |
|
|
}); |
1543 |
|
|
|
1544 |
schoenebeck |
3581 |
// std unit tests ... |
1545 |
|
|
|
1546 |
|
|
runScript({ |
1547 |
|
|
.code = R"NKSP_CODE( |
1548 |
|
|
on init |
1549 |
|
|
exit(1000ms - 145ms) |
1550 |
|
|
end on |
1551 |
|
|
)NKSP_CODE", |
1552 |
|
|
.expectIntExitResult = 855, |
1553 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1554 |
|
|
.expectExitResultUnit = VM_SECOND |
1555 |
|
|
}); |
1556 |
|
|
|
1557 |
|
|
runScript({ |
1558 |
|
|
.code = R"NKSP_CODE( |
1559 |
|
|
on init |
1560 |
|
|
exit(1s - 145ms) |
1561 |
|
|
end on |
1562 |
|
|
)NKSP_CODE", |
1563 |
|
|
.expectIntExitResult = 855, |
1564 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1565 |
|
|
.expectExitResultUnit = VM_SECOND |
1566 |
|
|
}); |
1567 |
|
|
|
1568 |
|
|
runScript({ |
1569 |
|
|
.code = R"NKSP_CODE( |
1570 |
|
|
on init |
1571 |
|
|
exit(1s - 145) |
1572 |
|
|
end on |
1573 |
|
|
)NKSP_CODE", |
1574 |
|
|
.expectParseError = true // units must match for - operator |
1575 |
|
|
}); |
1576 |
|
|
|
1577 |
|
|
runScript({ |
1578 |
|
|
.code = R"NKSP_CODE( |
1579 |
|
|
on init |
1580 |
|
|
exit(1 - 145s) |
1581 |
|
|
end on |
1582 |
|
|
)NKSP_CODE", |
1583 |
|
|
.expectParseError = true // units must match for - operator |
1584 |
|
|
}); |
1585 |
|
|
|
1586 |
|
|
runScript({ |
1587 |
|
|
.code = R"NKSP_CODE( |
1588 |
|
|
on init |
1589 |
|
|
exit(1ms - 145mB) |
1590 |
|
|
end on |
1591 |
|
|
)NKSP_CODE", |
1592 |
|
|
.expectParseError = true // units must match for - operator |
1593 |
|
|
}); |
1594 |
|
|
|
1595 |
|
|
runScript({ |
1596 |
|
|
.code = R"NKSP_CODE( |
1597 |
|
|
on init |
1598 |
|
|
exit(1.0ms - 0.1ms) |
1599 |
|
|
end on |
1600 |
|
|
)NKSP_CODE", |
1601 |
|
|
.expectRealExitResult = 0.9, |
1602 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1603 |
|
|
.expectExitResultUnit = VM_SECOND |
1604 |
|
|
}); |
1605 |
|
|
|
1606 |
|
|
runScript({ |
1607 |
|
|
.code = R"NKSP_CODE( |
1608 |
|
|
on init |
1609 |
|
|
exit(1.1s - 106.0ms) |
1610 |
|
|
end on |
1611 |
|
|
)NKSP_CODE", |
1612 |
|
|
.expectRealExitResult = 994.0, |
1613 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1614 |
|
|
.expectExitResultUnit = VM_SECOND |
1615 |
|
|
}); |
1616 |
|
|
|
1617 |
|
|
runScript({ |
1618 |
|
|
.code = R"NKSP_CODE( |
1619 |
|
|
on init |
1620 |
|
|
exit(1100.0ms - 0.106s) |
1621 |
|
|
end on |
1622 |
|
|
)NKSP_CODE", |
1623 |
|
|
.expectRealExitResult = 994.0, |
1624 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1625 |
|
|
.expectExitResultUnit = VM_SECOND |
1626 |
|
|
}); |
1627 |
|
|
|
1628 |
|
|
runScript({ |
1629 |
|
|
.code = R"NKSP_CODE( |
1630 |
|
|
on init |
1631 |
|
|
exit(1.0s - 145.0) |
1632 |
|
|
end on |
1633 |
|
|
)NKSP_CODE", |
1634 |
|
|
.expectParseError = true // units must match for - operator |
1635 |
|
|
}); |
1636 |
|
|
|
1637 |
|
|
runScript({ |
1638 |
|
|
.code = R"NKSP_CODE( |
1639 |
|
|
on init |
1640 |
|
|
exit(1.0 - 145.0s) |
1641 |
|
|
end on |
1642 |
|
|
)NKSP_CODE", |
1643 |
|
|
.expectParseError = true // units must match for - operator |
1644 |
|
|
}); |
1645 |
|
|
|
1646 |
|
|
runScript({ |
1647 |
|
|
.code = R"NKSP_CODE( |
1648 |
|
|
on init |
1649 |
|
|
exit(1.0ms - 145.0mB) |
1650 |
|
|
end on |
1651 |
|
|
)NKSP_CODE", |
1652 |
|
|
.expectParseError = true // units must match for - operator |
1653 |
|
|
}); |
1654 |
|
|
|
1655 |
|
|
// 'final' ('!') operator tests ... |
1656 |
|
|
|
1657 |
|
|
runScript({ |
1658 |
|
|
.code = R"NKSP_CODE( |
1659 |
|
|
on init |
1660 |
|
|
exit(!5 - !3) |
1661 |
|
|
end on |
1662 |
|
|
)NKSP_CODE", |
1663 |
|
|
.expectIntExitResult = 2, |
1664 |
|
|
.expectExitResultFinal = true |
1665 |
|
|
}); |
1666 |
|
|
|
1667 |
|
|
runScript({ |
1668 |
|
|
.code = R"NKSP_CODE( |
1669 |
|
|
on init |
1670 |
|
|
exit(5 - 3) |
1671 |
|
|
end on |
1672 |
|
|
)NKSP_CODE", |
1673 |
|
|
.expectIntExitResult = 2, |
1674 |
|
|
.expectExitResultFinal = false |
1675 |
|
|
}); |
1676 |
|
|
|
1677 |
|
|
runScript({ |
1678 |
|
|
.code = R"NKSP_CODE( |
1679 |
|
|
on init |
1680 |
|
|
exit(!5.9 - !3.3) |
1681 |
|
|
end on |
1682 |
|
|
)NKSP_CODE", |
1683 |
|
|
.expectRealExitResult = 2.6, |
1684 |
|
|
.expectExitResultFinal = true |
1685 |
|
|
}); |
1686 |
|
|
|
1687 |
|
|
runScript({ |
1688 |
|
|
.code = R"NKSP_CODE( |
1689 |
|
|
on init |
1690 |
|
|
exit(5.9 - 3.3) |
1691 |
|
|
end on |
1692 |
|
|
)NKSP_CODE", |
1693 |
|
|
.expectRealExitResult = 2.6, |
1694 |
|
|
.expectExitResultFinal = false |
1695 |
|
|
}); |
1696 |
|
|
|
1697 |
schoenebeck |
3551 |
#if !SILENT_TEST |
1698 |
|
|
std::cout << std::endl; |
1699 |
|
|
#endif |
1700 |
|
|
} |
1701 |
|
|
|
1702 |
|
|
static void testModuloOperator() { |
1703 |
|
|
#if !SILENT_TEST |
1704 |
|
|
std::cout << "UNIT TEST: modulo (mod) operator\n"; |
1705 |
|
|
#endif |
1706 |
|
|
|
1707 |
schoenebeck |
3575 |
// integer tests ... |
1708 |
|
|
|
1709 |
schoenebeck |
3551 |
runScript({ |
1710 |
|
|
.code = R"NKSP_CODE( |
1711 |
|
|
on init |
1712 |
|
|
exit(10 mod 8) |
1713 |
|
|
end on |
1714 |
|
|
)NKSP_CODE", |
1715 |
|
|
.expectIntExitResult = 2 |
1716 |
|
|
}); |
1717 |
|
|
|
1718 |
schoenebeck |
3575 |
runScript({ |
1719 |
|
|
.code = R"NKSP_CODE( |
1720 |
|
|
on init |
1721 |
|
|
declare $a := 10 |
1722 |
|
|
declare $b := 8 |
1723 |
|
|
exit($a mod $b) |
1724 |
|
|
end on |
1725 |
|
|
)NKSP_CODE", |
1726 |
|
|
.expectIntExitResult = 2 |
1727 |
|
|
}); |
1728 |
|
|
|
1729 |
|
|
// real number tests ... |
1730 |
|
|
// (mod operator prohibits real numbers ATM) |
1731 |
|
|
|
1732 |
|
|
runScript({ |
1733 |
|
|
.code = R"NKSP_CODE( |
1734 |
|
|
on init |
1735 |
|
|
exit(10.0 mod 8.0) |
1736 |
|
|
end on |
1737 |
|
|
)NKSP_CODE", |
1738 |
|
|
.expectParseError = true // mod operator prohibits real numbers ATM |
1739 |
|
|
}); |
1740 |
|
|
|
1741 |
|
|
runScript({ |
1742 |
|
|
.code = R"NKSP_CODE( |
1743 |
|
|
on init |
1744 |
|
|
exit(10 mod 8.0) |
1745 |
|
|
end on |
1746 |
|
|
)NKSP_CODE", |
1747 |
|
|
.expectParseError = true // mod operator prohibits real numbers ATM |
1748 |
|
|
}); |
1749 |
|
|
|
1750 |
|
|
runScript({ |
1751 |
|
|
.code = R"NKSP_CODE( |
1752 |
|
|
on init |
1753 |
|
|
exit(10.0 mod 8) |
1754 |
|
|
end on |
1755 |
|
|
)NKSP_CODE", |
1756 |
|
|
.expectParseError = true // mod operator prohibits real numbers ATM |
1757 |
|
|
}); |
1758 |
|
|
|
1759 |
|
|
runScript({ |
1760 |
|
|
.code = R"NKSP_CODE( |
1761 |
|
|
on init |
1762 |
|
|
declare ~a := 10.0 |
1763 |
|
|
declare ~b := 8.0 |
1764 |
|
|
exit(~a mod ~b) |
1765 |
|
|
end on |
1766 |
|
|
)NKSP_CODE", |
1767 |
|
|
.expectParseError = true // mod operator prohibits real numbers ATM |
1768 |
|
|
}); |
1769 |
|
|
|
1770 |
schoenebeck |
3581 |
// std unit tests ... |
1771 |
|
|
|
1772 |
|
|
runScript({ |
1773 |
|
|
.code = R"NKSP_CODE( |
1774 |
|
|
on init |
1775 |
|
|
exit(10s mod 8) |
1776 |
|
|
end on |
1777 |
|
|
)NKSP_CODE", |
1778 |
|
|
.expectParseError = true // mod operator prohibits std units ATM |
1779 |
|
|
}); |
1780 |
|
|
|
1781 |
|
|
runScript({ |
1782 |
|
|
.code = R"NKSP_CODE( |
1783 |
|
|
on init |
1784 |
|
|
exit(10 mod 8s) |
1785 |
|
|
end on |
1786 |
|
|
)NKSP_CODE", |
1787 |
|
|
.expectParseError = true // mod operator prohibits std units ATM |
1788 |
|
|
}); |
1789 |
|
|
|
1790 |
|
|
runScript({ |
1791 |
|
|
.code = R"NKSP_CODE( |
1792 |
|
|
on init |
1793 |
|
|
exit(10s mod 8s) |
1794 |
|
|
end on |
1795 |
|
|
)NKSP_CODE", |
1796 |
|
|
.expectParseError = true // mod operator prohibits std units ATM |
1797 |
|
|
}); |
1798 |
|
|
|
1799 |
|
|
// 'final' ('!') operator tests ... |
1800 |
|
|
|
1801 |
|
|
runScript({ |
1802 |
|
|
.code = R"NKSP_CODE( |
1803 |
|
|
on init |
1804 |
|
|
exit(!10 mod !8) |
1805 |
|
|
end on |
1806 |
|
|
)NKSP_CODE", |
1807 |
|
|
.expectIntExitResult = 2, |
1808 |
|
|
.expectExitResultFinal = true |
1809 |
|
|
}); |
1810 |
|
|
|
1811 |
|
|
runScript({ |
1812 |
|
|
.code = R"NKSP_CODE( |
1813 |
|
|
on init |
1814 |
|
|
exit(10 mod 8) |
1815 |
|
|
end on |
1816 |
|
|
)NKSP_CODE", |
1817 |
|
|
.expectIntExitResult = 2, |
1818 |
|
|
.expectExitResultFinal = false |
1819 |
|
|
}); |
1820 |
|
|
|
1821 |
schoenebeck |
3551 |
#if !SILENT_TEST |
1822 |
|
|
std::cout << std::endl; |
1823 |
|
|
#endif |
1824 |
|
|
} |
1825 |
|
|
|
1826 |
|
|
static void testMultiplyOperator() { |
1827 |
|
|
#if !SILENT_TEST |
1828 |
|
|
std::cout << "UNIT TEST: multiply (*) operator\n"; |
1829 |
|
|
#endif |
1830 |
|
|
|
1831 |
schoenebeck |
3575 |
// integer tests ... |
1832 |
|
|
|
1833 |
schoenebeck |
3551 |
runScript({ |
1834 |
|
|
.code = R"NKSP_CODE( |
1835 |
|
|
on init |
1836 |
|
|
exit(10 * 8) |
1837 |
|
|
end on |
1838 |
|
|
)NKSP_CODE", |
1839 |
|
|
.expectIntExitResult = 80 |
1840 |
|
|
}); |
1841 |
|
|
|
1842 |
|
|
runScript({ |
1843 |
|
|
.code = R"NKSP_CODE( |
1844 |
|
|
on init |
1845 |
|
|
exit(-3 * -4) |
1846 |
|
|
end on |
1847 |
|
|
)NKSP_CODE", |
1848 |
|
|
.expectIntExitResult = 12 |
1849 |
|
|
}); |
1850 |
|
|
|
1851 |
|
|
runScript({ |
1852 |
|
|
.code = R"NKSP_CODE( |
1853 |
|
|
on init |
1854 |
|
|
exit(-52 * 63) |
1855 |
|
|
end on |
1856 |
|
|
)NKSP_CODE", |
1857 |
|
|
.expectIntExitResult = -3276 |
1858 |
|
|
}); |
1859 |
|
|
|
1860 |
|
|
runScript({ |
1861 |
|
|
.code = R"NKSP_CODE( |
1862 |
|
|
on init |
1863 |
|
|
exit(123 * -59) |
1864 |
|
|
end on |
1865 |
|
|
)NKSP_CODE", |
1866 |
|
|
.expectIntExitResult = -7257 |
1867 |
|
|
}); |
1868 |
|
|
|
1869 |
schoenebeck |
3575 |
// real number tests ... |
1870 |
|
|
|
1871 |
|
|
runScript({ |
1872 |
|
|
.code = R"NKSP_CODE( |
1873 |
|
|
on init |
1874 |
|
|
exit(10.2 * 8.4) |
1875 |
|
|
end on |
1876 |
|
|
)NKSP_CODE", |
1877 |
|
|
.expectRealExitResult = 85.68 |
1878 |
|
|
}); |
1879 |
|
|
|
1880 |
|
|
runScript({ |
1881 |
|
|
.code = R"NKSP_CODE( |
1882 |
|
|
on init |
1883 |
|
|
exit(10.0 * -3.33) |
1884 |
|
|
end on |
1885 |
|
|
)NKSP_CODE", |
1886 |
|
|
.expectRealExitResult = -33.3 |
1887 |
|
|
}); |
1888 |
|
|
|
1889 |
|
|
runScript({ |
1890 |
|
|
.code = R"NKSP_CODE( |
1891 |
|
|
on init |
1892 |
|
|
exit(-3.33 * 10.0) |
1893 |
|
|
end on |
1894 |
|
|
)NKSP_CODE", |
1895 |
|
|
.expectRealExitResult = -33.3 |
1896 |
|
|
}); |
1897 |
|
|
|
1898 |
|
|
runScript({ |
1899 |
|
|
.code = R"NKSP_CODE( |
1900 |
|
|
on init |
1901 |
|
|
exit(-3.33 * -10.0) |
1902 |
|
|
end on |
1903 |
|
|
)NKSP_CODE", |
1904 |
|
|
.expectRealExitResult = 33.3 |
1905 |
|
|
}); |
1906 |
|
|
|
1907 |
|
|
// mixed type tests ... |
1908 |
|
|
// (mixed int * real forbidden ATM) |
1909 |
|
|
|
1910 |
|
|
runScript({ |
1911 |
|
|
.code = R"NKSP_CODE( |
1912 |
|
|
on init |
1913 |
|
|
exit(2 * 3.0) |
1914 |
|
|
end on |
1915 |
|
|
)NKSP_CODE", |
1916 |
|
|
.expectParseError = true // mixed int * real forbidden ATM |
1917 |
|
|
}); |
1918 |
|
|
|
1919 |
|
|
runScript({ |
1920 |
|
|
.code = R"NKSP_CODE( |
1921 |
|
|
on init |
1922 |
|
|
exit(2.0 * 3) |
1923 |
|
|
end on |
1924 |
|
|
)NKSP_CODE", |
1925 |
|
|
.expectParseError = true // mixed int * real forbidden ATM |
1926 |
|
|
}); |
1927 |
|
|
|
1928 |
schoenebeck |
3581 |
// std unit tests ... |
1929 |
|
|
|
1930 |
|
|
runScript({ |
1931 |
|
|
.code = R"NKSP_CODE( |
1932 |
|
|
on init |
1933 |
|
|
exit(10ms * 8) |
1934 |
|
|
end on |
1935 |
|
|
)NKSP_CODE", |
1936 |
|
|
.expectIntExitResult = 80, |
1937 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1938 |
|
|
.expectExitResultUnit = VM_SECOND |
1939 |
|
|
}); |
1940 |
|
|
|
1941 |
|
|
runScript({ |
1942 |
|
|
.code = R"NKSP_CODE( |
1943 |
|
|
on init |
1944 |
|
|
exit(10 * 8ms) |
1945 |
|
|
end on |
1946 |
|
|
)NKSP_CODE", |
1947 |
|
|
.expectIntExitResult = 80, |
1948 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1949 |
|
|
.expectExitResultUnit = VM_SECOND |
1950 |
|
|
}); |
1951 |
|
|
|
1952 |
|
|
runScript({ |
1953 |
|
|
.code = R"NKSP_CODE( |
1954 |
|
|
on init |
1955 |
|
|
exit(10s * 8s) |
1956 |
|
|
end on |
1957 |
|
|
)NKSP_CODE", |
1958 |
|
|
.expectParseError = true // units on both sides not allowed for * ATM |
1959 |
|
|
}); |
1960 |
|
|
|
1961 |
|
|
runScript({ |
1962 |
|
|
.code = R"NKSP_CODE( |
1963 |
|
|
on init |
1964 |
|
|
exit(10cs * 8d) |
1965 |
|
|
end on |
1966 |
|
|
)NKSP_CODE", |
1967 |
|
|
.expectIntExitResult = 80, |
1968 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
1969 |
|
|
.expectExitResultUnit = VM_SECOND |
1970 |
|
|
}); |
1971 |
|
|
|
1972 |
|
|
runScript({ |
1973 |
|
|
.code = R"NKSP_CODE( |
1974 |
|
|
on init |
1975 |
|
|
exit(10m * 8ms) |
1976 |
|
|
end on |
1977 |
|
|
)NKSP_CODE", |
1978 |
|
|
.expectIntExitResult = 80, |
1979 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
1980 |
|
|
.expectExitResultUnit = VM_SECOND |
1981 |
|
|
}); |
1982 |
|
|
|
1983 |
|
|
runScript({ |
1984 |
|
|
.code = R"NKSP_CODE( |
1985 |
|
|
on init |
1986 |
|
|
exit(10ms * 8k) |
1987 |
|
|
end on |
1988 |
|
|
)NKSP_CODE", |
1989 |
|
|
.expectIntExitResult = 80, |
1990 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
1991 |
|
|
.expectExitResultUnit = VM_SECOND |
1992 |
|
|
}); |
1993 |
|
|
|
1994 |
|
|
runScript({ |
1995 |
|
|
.code = R"NKSP_CODE( |
1996 |
|
|
on init |
1997 |
|
|
exit(10.1ms * 8.0) |
1998 |
|
|
end on |
1999 |
|
|
)NKSP_CODE", |
2000 |
|
|
.expectRealExitResult = 80.8, |
2001 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
2002 |
|
|
.expectExitResultUnit = VM_SECOND |
2003 |
|
|
}); |
2004 |
|
|
|
2005 |
|
|
runScript({ |
2006 |
|
|
.code = R"NKSP_CODE( |
2007 |
|
|
on init |
2008 |
|
|
exit(10.1 * 8.0ms) |
2009 |
|
|
end on |
2010 |
|
|
)NKSP_CODE", |
2011 |
|
|
.expectRealExitResult = 80.8, |
2012 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
2013 |
|
|
.expectExitResultUnit = VM_SECOND |
2014 |
|
|
}); |
2015 |
|
|
|
2016 |
|
|
runScript({ |
2017 |
|
|
.code = R"NKSP_CODE( |
2018 |
|
|
on init |
2019 |
|
|
exit(10.0s * 8.0s) |
2020 |
|
|
end on |
2021 |
|
|
)NKSP_CODE", |
2022 |
|
|
.expectParseError = true // units on both sides not allowed for * ATM |
2023 |
|
|
}); |
2024 |
|
|
|
2025 |
|
|
runScript({ |
2026 |
|
|
.code = R"NKSP_CODE( |
2027 |
|
|
on init |
2028 |
|
|
exit(10.1ds * 8.0c) |
2029 |
|
|
end on |
2030 |
|
|
)NKSP_CODE", |
2031 |
|
|
.expectRealExitResult = 80.8, |
2032 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
2033 |
|
|
.expectExitResultUnit = VM_SECOND |
2034 |
|
|
}); |
2035 |
|
|
|
2036 |
|
|
runScript({ |
2037 |
|
|
.code = R"NKSP_CODE( |
2038 |
|
|
on init |
2039 |
|
|
exit(10.1m * 8.0ms) |
2040 |
|
|
end on |
2041 |
|
|
)NKSP_CODE", |
2042 |
|
|
.expectRealExitResult = 80.8, |
2043 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
2044 |
|
|
.expectExitResultUnit = VM_SECOND |
2045 |
|
|
}); |
2046 |
|
|
|
2047 |
|
|
runScript({ |
2048 |
|
|
.code = R"NKSP_CODE( |
2049 |
|
|
on init |
2050 |
|
|
exit(10.1m * 8.0ks) |
2051 |
|
|
end on |
2052 |
|
|
)NKSP_CODE", |
2053 |
|
|
.expectRealExitResult = 80.8, |
2054 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
2055 |
|
|
.expectExitResultUnit = VM_SECOND |
2056 |
|
|
}); |
2057 |
|
|
|
2058 |
|
|
// 'final' ('!') operator tests ... |
2059 |
|
|
|
2060 |
|
|
runScript({ |
2061 |
|
|
.code = R"NKSP_CODE( |
2062 |
|
|
on init |
2063 |
|
|
exit(!10 * !8) |
2064 |
|
|
end on |
2065 |
|
|
)NKSP_CODE", |
2066 |
|
|
.expectIntExitResult = 80, |
2067 |
|
|
.expectExitResultFinal = true |
2068 |
|
|
}); |
2069 |
|
|
|
2070 |
|
|
runScript({ |
2071 |
|
|
.code = R"NKSP_CODE( |
2072 |
|
|
on init |
2073 |
|
|
exit(10 * 8) |
2074 |
|
|
end on |
2075 |
|
|
)NKSP_CODE", |
2076 |
|
|
.expectIntExitResult = 80, |
2077 |
|
|
.expectExitResultFinal = false |
2078 |
|
|
}); |
2079 |
|
|
|
2080 |
|
|
runScript({ |
2081 |
|
|
.code = R"NKSP_CODE( |
2082 |
|
|
on init |
2083 |
|
|
exit(!10 * 8) |
2084 |
|
|
end on |
2085 |
|
|
)NKSP_CODE", |
2086 |
|
|
.expectIntExitResult = 80, |
2087 |
|
|
.expectExitResultFinal = true, |
2088 |
|
|
.expectParseWarning = true // since final only on one side, result will be final though |
2089 |
|
|
}); |
2090 |
|
|
|
2091 |
|
|
runScript({ |
2092 |
|
|
.code = R"NKSP_CODE( |
2093 |
|
|
on init |
2094 |
|
|
exit(10 * !8) |
2095 |
|
|
end on |
2096 |
|
|
)NKSP_CODE", |
2097 |
|
|
.expectIntExitResult = 80, |
2098 |
|
|
.expectExitResultFinal = true, |
2099 |
|
|
.expectParseWarning = true // since final only on one side, result will be final though |
2100 |
|
|
}); |
2101 |
|
|
|
2102 |
|
|
runScript({ |
2103 |
|
|
.code = R"NKSP_CODE( |
2104 |
|
|
on init |
2105 |
|
|
exit(!10.1 * !8.0) |
2106 |
|
|
end on |
2107 |
|
|
)NKSP_CODE", |
2108 |
|
|
.expectRealExitResult = 80.8, |
2109 |
|
|
.expectExitResultFinal = true |
2110 |
|
|
}); |
2111 |
|
|
|
2112 |
|
|
runScript({ |
2113 |
|
|
.code = R"NKSP_CODE( |
2114 |
|
|
on init |
2115 |
|
|
exit(10.1 * 8.0) |
2116 |
|
|
end on |
2117 |
|
|
)NKSP_CODE", |
2118 |
|
|
.expectRealExitResult = 80.8, |
2119 |
|
|
.expectExitResultFinal = false |
2120 |
|
|
}); |
2121 |
|
|
|
2122 |
|
|
runScript({ |
2123 |
|
|
.code = R"NKSP_CODE( |
2124 |
|
|
on init |
2125 |
|
|
exit(!10.1 * 8.0) |
2126 |
|
|
end on |
2127 |
|
|
)NKSP_CODE", |
2128 |
|
|
.expectRealExitResult = 80.8, |
2129 |
|
|
.expectExitResultFinal = true, |
2130 |
|
|
.expectParseWarning = true // since final only on one side, result will be final though |
2131 |
|
|
}); |
2132 |
|
|
|
2133 |
|
|
runScript({ |
2134 |
|
|
.code = R"NKSP_CODE( |
2135 |
|
|
on init |
2136 |
|
|
exit(10.1 * !8.0) |
2137 |
|
|
end on |
2138 |
|
|
)NKSP_CODE", |
2139 |
|
|
.expectRealExitResult = 80.8, |
2140 |
|
|
.expectExitResultFinal = true, |
2141 |
|
|
.expectParseWarning = true // since final only on one side, result will be final though |
2142 |
|
|
}); |
2143 |
|
|
|
2144 |
schoenebeck |
3551 |
#if !SILENT_TEST |
2145 |
|
|
std::cout << std::endl; |
2146 |
|
|
#endif |
2147 |
|
|
} |
2148 |
|
|
|
2149 |
|
|
static void testDivideOperator() { |
2150 |
|
|
#if !SILENT_TEST |
2151 |
|
|
std::cout << "UNIT TEST: divide (/) operator\n"; |
2152 |
|
|
#endif |
2153 |
|
|
|
2154 |
schoenebeck |
3575 |
// integer tests ... |
2155 |
|
|
|
2156 |
schoenebeck |
3551 |
runScript({ |
2157 |
|
|
.code = R"NKSP_CODE( |
2158 |
|
|
on init |
2159 |
|
|
exit(9 / 3) |
2160 |
|
|
end on |
2161 |
|
|
)NKSP_CODE", |
2162 |
|
|
.expectIntExitResult = 3 |
2163 |
|
|
}); |
2164 |
|
|
|
2165 |
|
|
runScript({ |
2166 |
|
|
.code = R"NKSP_CODE( |
2167 |
|
|
on init |
2168 |
|
|
exit(-27 / 3) |
2169 |
|
|
end on |
2170 |
|
|
)NKSP_CODE", |
2171 |
|
|
.expectIntExitResult = -9 |
2172 |
|
|
}); |
2173 |
|
|
|
2174 |
|
|
runScript({ |
2175 |
|
|
.code = R"NKSP_CODE( |
2176 |
|
|
on init |
2177 |
|
|
exit(35 / -5) |
2178 |
|
|
end on |
2179 |
|
|
)NKSP_CODE", |
2180 |
|
|
.expectIntExitResult = -7 |
2181 |
|
|
}); |
2182 |
|
|
|
2183 |
|
|
runScript({ |
2184 |
|
|
.code = R"NKSP_CODE( |
2185 |
|
|
on init |
2186 |
|
|
exit(39 / -5) |
2187 |
|
|
end on |
2188 |
|
|
)NKSP_CODE", |
2189 |
|
|
.expectIntExitResult = -7 |
2190 |
|
|
}); |
2191 |
|
|
|
2192 |
schoenebeck |
3575 |
// real number tests ... |
2193 |
|
|
|
2194 |
|
|
runScript({ |
2195 |
|
|
.code = R"NKSP_CODE( |
2196 |
|
|
on init |
2197 |
|
|
exit(9.0 / 10.0) |
2198 |
|
|
end on |
2199 |
|
|
)NKSP_CODE", |
2200 |
|
|
.expectRealExitResult = 0.9 |
2201 |
|
|
}); |
2202 |
|
|
|
2203 |
|
|
runScript({ |
2204 |
|
|
.code = R"NKSP_CODE( |
2205 |
|
|
on init |
2206 |
|
|
exit(-9.0 / 10.0) |
2207 |
|
|
end on |
2208 |
|
|
)NKSP_CODE", |
2209 |
|
|
.expectRealExitResult = -0.9 |
2210 |
|
|
}); |
2211 |
|
|
|
2212 |
|
|
runScript({ |
2213 |
|
|
.code = R"NKSP_CODE( |
2214 |
|
|
on init |
2215 |
|
|
exit(9.0 / -10.0) |
2216 |
|
|
end on |
2217 |
|
|
)NKSP_CODE", |
2218 |
|
|
.expectRealExitResult = -0.9 |
2219 |
|
|
}); |
2220 |
|
|
|
2221 |
|
|
runScript({ |
2222 |
|
|
.code = R"NKSP_CODE( |
2223 |
|
|
on init |
2224 |
|
|
exit(-9.0 / -10.0) |
2225 |
|
|
end on |
2226 |
|
|
)NKSP_CODE", |
2227 |
|
|
.expectRealExitResult = 0.9 |
2228 |
|
|
}); |
2229 |
|
|
|
2230 |
|
|
// mixed type tests ... |
2231 |
|
|
// (mixed int / real forbidden ATM) |
2232 |
|
|
|
2233 |
|
|
runScript({ |
2234 |
|
|
.code = R"NKSP_CODE( |
2235 |
|
|
on init |
2236 |
|
|
exit(9 / 10.0) |
2237 |
|
|
end on |
2238 |
|
|
)NKSP_CODE", |
2239 |
|
|
.expectParseError = true // mixed int / real forbidden ATM |
2240 |
|
|
}); |
2241 |
|
|
|
2242 |
|
|
runScript({ |
2243 |
|
|
.code = R"NKSP_CODE( |
2244 |
|
|
on init |
2245 |
|
|
exit(9.0 / 10) |
2246 |
|
|
end on |
2247 |
|
|
)NKSP_CODE", |
2248 |
|
|
.expectParseError = true // mixed int / real forbidden ATM |
2249 |
|
|
}); |
2250 |
|
|
|
2251 |
schoenebeck |
3581 |
// std unit tests ... |
2252 |
|
|
|
2253 |
|
|
runScript({ |
2254 |
|
|
.code = R"NKSP_CODE( |
2255 |
|
|
on init |
2256 |
|
|
exit(-27us / 3) |
2257 |
|
|
end on |
2258 |
|
|
)NKSP_CODE", |
2259 |
|
|
.expectIntExitResult = -9, |
2260 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
2261 |
|
|
.expectExitResultUnit = VM_SECOND |
2262 |
|
|
}); |
2263 |
|
|
|
2264 |
|
|
runScript({ |
2265 |
|
|
.code = R"NKSP_CODE( |
2266 |
|
|
on init |
2267 |
|
|
exit(-27mdB / 3mdB) |
2268 |
|
|
end on |
2269 |
|
|
)NKSP_CODE", |
2270 |
|
|
.expectIntExitResult = -9, |
2271 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
2272 |
|
|
.expectExitResultUnit = VM_NO_UNIT |
2273 |
|
|
}); |
2274 |
|
|
|
2275 |
|
|
runScript({ |
2276 |
|
|
.code = R"NKSP_CODE( |
2277 |
|
|
on init |
2278 |
|
|
exit(-27s / 3m) |
2279 |
|
|
end on |
2280 |
|
|
)NKSP_CODE", |
2281 |
|
|
.expectIntExitResult = -9, |
2282 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
2283 |
|
|
.expectExitResultUnit = VM_SECOND |
2284 |
|
|
}); |
2285 |
|
|
|
2286 |
|
|
runScript({ |
2287 |
|
|
.code = R"NKSP_CODE( |
2288 |
|
|
on init |
2289 |
|
|
exit(-27us / 3m) |
2290 |
|
|
end on |
2291 |
|
|
)NKSP_CODE", |
2292 |
|
|
.expectIntExitResult = -9, |
2293 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
2294 |
|
|
.expectExitResultUnit = VM_SECOND |
2295 |
|
|
}); |
2296 |
|
|
|
2297 |
|
|
runScript({ |
2298 |
|
|
.code = R"NKSP_CODE( |
2299 |
|
|
on init |
2300 |
|
|
exit(-27 / 3s) |
2301 |
|
|
end on |
2302 |
|
|
)NKSP_CODE", |
2303 |
|
|
.expectParseError = true // illegal unit type arrangement for divisions |
2304 |
|
|
}); |
2305 |
|
|
|
2306 |
|
|
runScript({ |
2307 |
|
|
.code = R"NKSP_CODE( |
2308 |
|
|
on init |
2309 |
|
|
exit(-27s / 3Hz) |
2310 |
|
|
end on |
2311 |
|
|
)NKSP_CODE", |
2312 |
|
|
.expectParseError = true // unit types are not matching |
2313 |
|
|
}); |
2314 |
|
|
|
2315 |
|
|
// 'final' ('!') operator tests ... |
2316 |
|
|
|
2317 |
|
|
runScript({ |
2318 |
|
|
.code = R"NKSP_CODE( |
2319 |
|
|
on init |
2320 |
|
|
exit(!-27 / !3) |
2321 |
|
|
end on |
2322 |
|
|
)NKSP_CODE", |
2323 |
|
|
.expectIntExitResult = -9, |
2324 |
|
|
.expectExitResultFinal = true |
2325 |
|
|
}); |
2326 |
|
|
|
2327 |
|
|
runScript({ |
2328 |
|
|
.code = R"NKSP_CODE( |
2329 |
|
|
on init |
2330 |
|
|
exit(-27 / 3) |
2331 |
|
|
end on |
2332 |
|
|
)NKSP_CODE", |
2333 |
|
|
.expectIntExitResult = -9, |
2334 |
|
|
.expectExitResultFinal = false |
2335 |
|
|
}); |
2336 |
|
|
|
2337 |
|
|
runScript({ |
2338 |
|
|
.code = R"NKSP_CODE( |
2339 |
|
|
on init |
2340 |
|
|
exit(!-27 / 3) |
2341 |
|
|
end on |
2342 |
|
|
)NKSP_CODE", |
2343 |
|
|
.expectIntExitResult = -9, |
2344 |
|
|
.expectExitResultFinal = true, |
2345 |
|
|
.expectParseWarning = true // final only on one side, result will be final though |
2346 |
|
|
}); |
2347 |
|
|
|
2348 |
|
|
runScript({ |
2349 |
|
|
.code = R"NKSP_CODE( |
2350 |
|
|
on init |
2351 |
|
|
exit(-27 / !3) |
2352 |
|
|
end on |
2353 |
|
|
)NKSP_CODE", |
2354 |
|
|
.expectIntExitResult = -9, |
2355 |
|
|
.expectExitResultFinal = true, |
2356 |
|
|
.expectParseWarning = true // final only on one side, result will be final though |
2357 |
|
|
}); |
2358 |
|
|
|
2359 |
schoenebeck |
3551 |
#if !SILENT_TEST |
2360 |
|
|
std::cout << std::endl; |
2361 |
|
|
#endif |
2362 |
|
|
} |
2363 |
|
|
|
2364 |
|
|
static void testSmallerThanOperator() { |
2365 |
|
|
#if !SILENT_TEST |
2366 |
|
|
std::cout << "UNIT TEST: smaller than (<) operator\n"; |
2367 |
|
|
#endif |
2368 |
|
|
|
2369 |
schoenebeck |
3575 |
// integer tests ... |
2370 |
|
|
|
2371 |
schoenebeck |
3551 |
runScript({ |
2372 |
|
|
.code = R"NKSP_CODE( |
2373 |
|
|
on init |
2374 |
|
|
exit(3 < 4) |
2375 |
|
|
end on |
2376 |
|
|
)NKSP_CODE", |
2377 |
|
|
.expectBoolExitResult = true |
2378 |
|
|
}); |
2379 |
|
|
|
2380 |
|
|
runScript({ |
2381 |
|
|
.code = R"NKSP_CODE( |
2382 |
|
|
on init |
2383 |
|
|
exit(4 < 3) |
2384 |
|
|
end on |
2385 |
|
|
)NKSP_CODE", |
2386 |
|
|
.expectBoolExitResult = false |
2387 |
|
|
}); |
2388 |
|
|
|
2389 |
|
|
runScript({ |
2390 |
|
|
.code = R"NKSP_CODE( |
2391 |
|
|
on init |
2392 |
|
|
exit(-4 < 3) |
2393 |
|
|
end on |
2394 |
|
|
)NKSP_CODE", |
2395 |
|
|
.expectBoolExitResult = true |
2396 |
|
|
}); |
2397 |
|
|
|
2398 |
|
|
runScript({ |
2399 |
|
|
.code = R"NKSP_CODE( |
2400 |
|
|
on init |
2401 |
|
|
exit(3 < -4) |
2402 |
|
|
end on |
2403 |
|
|
)NKSP_CODE", |
2404 |
|
|
.expectBoolExitResult = false |
2405 |
|
|
}); |
2406 |
|
|
|
2407 |
|
|
runScript({ |
2408 |
|
|
.code = R"NKSP_CODE( |
2409 |
|
|
on init |
2410 |
|
|
exit(123 < -45) |
2411 |
|
|
end on |
2412 |
|
|
)NKSP_CODE", |
2413 |
|
|
.expectBoolExitResult = false |
2414 |
|
|
}); |
2415 |
|
|
|
2416 |
|
|
runScript({ |
2417 |
|
|
.code = R"NKSP_CODE( |
2418 |
|
|
on init |
2419 |
|
|
exit(-45 < 123) |
2420 |
|
|
end on |
2421 |
|
|
)NKSP_CODE", |
2422 |
|
|
.expectBoolExitResult = true |
2423 |
|
|
}); |
2424 |
|
|
|
2425 |
schoenebeck |
3575 |
// real number tests ... |
2426 |
|
|
|
2427 |
|
|
runScript({ |
2428 |
|
|
.code = R"NKSP_CODE( |
2429 |
|
|
on init |
2430 |
|
|
exit(3.0 < 4.0) |
2431 |
|
|
end on |
2432 |
|
|
)NKSP_CODE", |
2433 |
|
|
.expectBoolExitResult = true |
2434 |
|
|
}); |
2435 |
|
|
|
2436 |
|
|
runScript({ |
2437 |
|
|
.code = R"NKSP_CODE( |
2438 |
|
|
on init |
2439 |
|
|
exit(4.0 < 3.0) |
2440 |
|
|
end on |
2441 |
|
|
)NKSP_CODE", |
2442 |
|
|
.expectBoolExitResult = false |
2443 |
|
|
}); |
2444 |
|
|
|
2445 |
|
|
runScript({ |
2446 |
|
|
.code = R"NKSP_CODE( |
2447 |
|
|
on init |
2448 |
|
|
exit(1.2 < 1.23) |
2449 |
|
|
end on |
2450 |
|
|
)NKSP_CODE", |
2451 |
|
|
.expectBoolExitResult = true |
2452 |
|
|
}); |
2453 |
|
|
|
2454 |
|
|
runScript({ |
2455 |
|
|
.code = R"NKSP_CODE( |
2456 |
|
|
on init |
2457 |
|
|
exit(1.23 < 1.2) |
2458 |
|
|
end on |
2459 |
|
|
)NKSP_CODE", |
2460 |
|
|
.expectBoolExitResult = false |
2461 |
|
|
}); |
2462 |
|
|
|
2463 |
|
|
runScript({ |
2464 |
|
|
.code = R"NKSP_CODE( |
2465 |
|
|
on init |
2466 |
|
|
exit(-4.0 < 3.0) |
2467 |
|
|
end on |
2468 |
|
|
)NKSP_CODE", |
2469 |
|
|
.expectBoolExitResult = true |
2470 |
|
|
}); |
2471 |
|
|
|
2472 |
|
|
runScript({ |
2473 |
|
|
.code = R"NKSP_CODE( |
2474 |
|
|
on init |
2475 |
|
|
exit(3.0 < -4.0) |
2476 |
|
|
end on |
2477 |
|
|
)NKSP_CODE", |
2478 |
|
|
.expectBoolExitResult = false |
2479 |
|
|
}); |
2480 |
|
|
|
2481 |
|
|
runScript({ |
2482 |
|
|
.code = R"NKSP_CODE( |
2483 |
|
|
on init |
2484 |
|
|
exit(123.0 < -45.0) |
2485 |
|
|
end on |
2486 |
|
|
)NKSP_CODE", |
2487 |
|
|
.expectBoolExitResult = false |
2488 |
|
|
}); |
2489 |
|
|
|
2490 |
|
|
runScript({ |
2491 |
|
|
.code = R"NKSP_CODE( |
2492 |
|
|
on init |
2493 |
|
|
exit(-45.0 < 123.0) |
2494 |
|
|
end on |
2495 |
|
|
)NKSP_CODE", |
2496 |
|
|
.expectBoolExitResult = true |
2497 |
|
|
}); |
2498 |
|
|
|
2499 |
|
|
// mixed type tests ... |
2500 |
|
|
|
2501 |
|
|
runScript({ |
2502 |
|
|
.code = R"NKSP_CODE( |
2503 |
|
|
on init |
2504 |
|
|
exit(9 < 9.1) |
2505 |
|
|
end on |
2506 |
|
|
)NKSP_CODE", |
2507 |
|
|
.expectBoolExitResult = true |
2508 |
|
|
}); |
2509 |
|
|
|
2510 |
|
|
runScript({ |
2511 |
|
|
.code = R"NKSP_CODE( |
2512 |
|
|
on init |
2513 |
|
|
exit(9.1 < 9) |
2514 |
|
|
end on |
2515 |
|
|
)NKSP_CODE", |
2516 |
|
|
.expectBoolExitResult = false |
2517 |
|
|
}); |
2518 |
|
|
|
2519 |
schoenebeck |
3581 |
// std unit tests ... |
2520 |
|
|
|
2521 |
|
|
runScript({ |
2522 |
|
|
.code = R"NKSP_CODE( |
2523 |
|
|
on init |
2524 |
|
|
exit(13ms < 14ms) |
2525 |
|
|
end on |
2526 |
|
|
)NKSP_CODE", |
2527 |
|
|
.expectBoolExitResult = true |
2528 |
|
|
}); |
2529 |
|
|
|
2530 |
|
|
runScript({ |
2531 |
|
|
.code = R"NKSP_CODE( |
2532 |
|
|
on init |
2533 |
|
|
exit(14ms < 13ms) |
2534 |
|
|
end on |
2535 |
|
|
)NKSP_CODE", |
2536 |
|
|
.expectBoolExitResult = false |
2537 |
|
|
}); |
2538 |
|
|
|
2539 |
|
|
runScript({ |
2540 |
|
|
.code = R"NKSP_CODE( |
2541 |
|
|
on init |
2542 |
|
|
exit(1s < 990ms) |
2543 |
|
|
end on |
2544 |
|
|
)NKSP_CODE", |
2545 |
|
|
.expectBoolExitResult = false |
2546 |
|
|
}); |
2547 |
|
|
|
2548 |
|
|
runScript({ |
2549 |
|
|
.code = R"NKSP_CODE( |
2550 |
|
|
on init |
2551 |
|
|
exit(990ms < 1s) |
2552 |
|
|
end on |
2553 |
|
|
)NKSP_CODE", |
2554 |
|
|
.expectBoolExitResult = true |
2555 |
|
|
}); |
2556 |
|
|
|
2557 |
|
|
runScript({ |
2558 |
|
|
.code = R"NKSP_CODE( |
2559 |
|
|
on init |
2560 |
|
|
exit(1000ms < 1s) |
2561 |
|
|
end on |
2562 |
|
|
)NKSP_CODE", |
2563 |
|
|
.expectBoolExitResult = false |
2564 |
|
|
}); |
2565 |
|
|
|
2566 |
|
|
runScript({ |
2567 |
|
|
.code = R"NKSP_CODE( |
2568 |
|
|
on init |
2569 |
|
|
exit(1s < 1000ms) |
2570 |
|
|
end on |
2571 |
|
|
)NKSP_CODE", |
2572 |
|
|
.expectBoolExitResult = false |
2573 |
|
|
}); |
2574 |
|
|
|
2575 |
|
|
runScript({ |
2576 |
|
|
.code = R"NKSP_CODE( |
2577 |
|
|
on init |
2578 |
|
|
exit(1s < 1) |
2579 |
|
|
end on |
2580 |
|
|
)NKSP_CODE", |
2581 |
|
|
.expectParseError = true // units on both sides must match |
2582 |
|
|
}); |
2583 |
|
|
|
2584 |
|
|
runScript({ |
2585 |
|
|
.code = R"NKSP_CODE( |
2586 |
|
|
on init |
2587 |
|
|
exit(1 < 1s) |
2588 |
|
|
end on |
2589 |
|
|
)NKSP_CODE", |
2590 |
|
|
.expectParseError = true // units on both sides must match |
2591 |
|
|
}); |
2592 |
|
|
|
2593 |
|
|
runScript({ |
2594 |
|
|
.code = R"NKSP_CODE( |
2595 |
|
|
on init |
2596 |
|
|
exit(1Hz < 1B) |
2597 |
|
|
end on |
2598 |
|
|
)NKSP_CODE", |
2599 |
|
|
.expectParseError = true // units on both sides must match |
2600 |
|
|
}); |
2601 |
|
|
|
2602 |
|
|
runScript({ |
2603 |
|
|
.code = R"NKSP_CODE( |
2604 |
|
|
on init |
2605 |
|
|
exit(13.0ms < 13.1ms) |
2606 |
|
|
end on |
2607 |
|
|
)NKSP_CODE", |
2608 |
|
|
.expectBoolExitResult = true |
2609 |
|
|
}); |
2610 |
|
|
|
2611 |
|
|
runScript({ |
2612 |
|
|
.code = R"NKSP_CODE( |
2613 |
|
|
on init |
2614 |
|
|
exit(13.1ms < 13.0ms) |
2615 |
|
|
end on |
2616 |
|
|
)NKSP_CODE", |
2617 |
|
|
.expectBoolExitResult = false |
2618 |
|
|
}); |
2619 |
|
|
|
2620 |
|
|
runScript({ |
2621 |
|
|
.code = R"NKSP_CODE( |
2622 |
|
|
on init |
2623 |
|
|
exit(0.9s < 600.0ms) |
2624 |
|
|
end on |
2625 |
|
|
)NKSP_CODE", |
2626 |
|
|
.expectBoolExitResult = false |
2627 |
|
|
}); |
2628 |
|
|
|
2629 |
|
|
runScript({ |
2630 |
|
|
.code = R"NKSP_CODE( |
2631 |
|
|
on init |
2632 |
|
|
exit(600.0ms < 0.9s) |
2633 |
|
|
end on |
2634 |
|
|
)NKSP_CODE", |
2635 |
|
|
.expectBoolExitResult = true |
2636 |
|
|
}); |
2637 |
|
|
|
2638 |
|
|
runScript({ |
2639 |
|
|
.code = R"NKSP_CODE( |
2640 |
|
|
on init |
2641 |
|
|
exit(5.1kHz < 5100.0Hz) |
2642 |
|
|
end on |
2643 |
|
|
)NKSP_CODE", |
2644 |
|
|
.expectBoolExitResult = false |
2645 |
|
|
}); |
2646 |
|
|
|
2647 |
|
|
runScript({ |
2648 |
|
|
.code = R"NKSP_CODE( |
2649 |
|
|
on init |
2650 |
|
|
exit(5100.0Hz < 5.1kHz) |
2651 |
|
|
end on |
2652 |
|
|
)NKSP_CODE", |
2653 |
|
|
.expectBoolExitResult = false |
2654 |
|
|
}); |
2655 |
|
|
|
2656 |
|
|
runScript({ |
2657 |
|
|
.code = R"NKSP_CODE( |
2658 |
|
|
on init |
2659 |
|
|
exit(1.0Hz < 1.1) |
2660 |
|
|
end on |
2661 |
|
|
)NKSP_CODE", |
2662 |
|
|
.expectParseError = true // units on both sides must match |
2663 |
|
|
}); |
2664 |
|
|
|
2665 |
|
|
runScript({ |
2666 |
|
|
.code = R"NKSP_CODE( |
2667 |
|
|
on init |
2668 |
|
|
exit(1.2 < 1.34mdB) |
2669 |
|
|
end on |
2670 |
|
|
)NKSP_CODE", |
2671 |
|
|
.expectParseError = true // units on both sides must match |
2672 |
|
|
}); |
2673 |
|
|
|
2674 |
|
|
runScript({ |
2675 |
|
|
.code = R"NKSP_CODE( |
2676 |
|
|
on init |
2677 |
|
|
exit(9.23us < 3.14kHz) |
2678 |
|
|
end on |
2679 |
|
|
)NKSP_CODE", |
2680 |
|
|
.expectParseError = true // units on both sides must match |
2681 |
|
|
}); |
2682 |
|
|
|
2683 |
|
|
// 'final' ('!') operator tests ... |
2684 |
|
|
// (should always yield in false for relation operators) |
2685 |
|
|
|
2686 |
|
|
runScript({ |
2687 |
|
|
.code = R"NKSP_CODE( |
2688 |
|
|
on init |
2689 |
|
|
exit(!-4 < !3) |
2690 |
|
|
end on |
2691 |
|
|
)NKSP_CODE", |
2692 |
|
|
.expectBoolExitResult = true, |
2693 |
|
|
.expectExitResultFinal = false |
2694 |
|
|
}); |
2695 |
|
|
|
2696 |
|
|
runScript({ |
2697 |
|
|
.code = R"NKSP_CODE( |
2698 |
|
|
on init |
2699 |
|
|
exit(-4 < 3) |
2700 |
|
|
end on |
2701 |
|
|
)NKSP_CODE", |
2702 |
|
|
.expectBoolExitResult = true, |
2703 |
|
|
.expectExitResultFinal = false |
2704 |
|
|
}); |
2705 |
|
|
|
2706 |
schoenebeck |
3551 |
#if !SILENT_TEST |
2707 |
|
|
std::cout << std::endl; |
2708 |
|
|
#endif |
2709 |
|
|
} |
2710 |
|
|
|
2711 |
|
|
static void testGreaterThanOperator() { |
2712 |
|
|
#if !SILENT_TEST |
2713 |
|
|
std::cout << "UNIT TEST: greater than (>) operator\n"; |
2714 |
|
|
#endif |
2715 |
|
|
|
2716 |
schoenebeck |
3575 |
// integer tests ... |
2717 |
|
|
|
2718 |
schoenebeck |
3551 |
runScript({ |
2719 |
|
|
.code = R"NKSP_CODE( |
2720 |
|
|
on init |
2721 |
|
|
exit(3 > 4) |
2722 |
|
|
end on |
2723 |
|
|
)NKSP_CODE", |
2724 |
|
|
.expectBoolExitResult = false |
2725 |
|
|
}); |
2726 |
|
|
|
2727 |
|
|
runScript({ |
2728 |
|
|
.code = R"NKSP_CODE( |
2729 |
|
|
on init |
2730 |
|
|
exit(4 > 3) |
2731 |
|
|
end on |
2732 |
|
|
)NKSP_CODE", |
2733 |
|
|
.expectBoolExitResult = true |
2734 |
|
|
}); |
2735 |
|
|
|
2736 |
|
|
runScript({ |
2737 |
|
|
.code = R"NKSP_CODE( |
2738 |
|
|
on init |
2739 |
|
|
exit(-4 > 3) |
2740 |
|
|
end on |
2741 |
|
|
)NKSP_CODE", |
2742 |
|
|
.expectBoolExitResult = false |
2743 |
|
|
}); |
2744 |
|
|
|
2745 |
|
|
runScript({ |
2746 |
|
|
.code = R"NKSP_CODE( |
2747 |
|
|
on init |
2748 |
|
|
exit(3 > -4) |
2749 |
|
|
end on |
2750 |
|
|
)NKSP_CODE", |
2751 |
|
|
.expectBoolExitResult = true |
2752 |
|
|
}); |
2753 |
|
|
|
2754 |
|
|
runScript({ |
2755 |
|
|
.code = R"NKSP_CODE( |
2756 |
|
|
on init |
2757 |
|
|
exit(123 > -45) |
2758 |
|
|
end on |
2759 |
|
|
)NKSP_CODE", |
2760 |
|
|
.expectBoolExitResult = true |
2761 |
|
|
}); |
2762 |
|
|
|
2763 |
|
|
runScript({ |
2764 |
|
|
.code = R"NKSP_CODE( |
2765 |
|
|
on init |
2766 |
|
|
exit(-45 > 123) |
2767 |
|
|
end on |
2768 |
|
|
)NKSP_CODE", |
2769 |
|
|
.expectBoolExitResult = false |
2770 |
|
|
}); |
2771 |
|
|
|
2772 |
schoenebeck |
3575 |
// real number tests ... |
2773 |
|
|
|
2774 |
|
|
runScript({ |
2775 |
|
|
.code = R"NKSP_CODE( |
2776 |
|
|
on init |
2777 |
|
|
exit(3.0 > 4.0) |
2778 |
|
|
end on |
2779 |
|
|
)NKSP_CODE", |
2780 |
|
|
.expectBoolExitResult = false |
2781 |
|
|
}); |
2782 |
|
|
|
2783 |
|
|
runScript({ |
2784 |
|
|
.code = R"NKSP_CODE( |
2785 |
|
|
on init |
2786 |
|
|
exit(4.0 > 3.0) |
2787 |
|
|
end on |
2788 |
|
|
)NKSP_CODE", |
2789 |
|
|
.expectBoolExitResult = true |
2790 |
|
|
}); |
2791 |
|
|
|
2792 |
|
|
runScript({ |
2793 |
|
|
.code = R"NKSP_CODE( |
2794 |
|
|
on init |
2795 |
|
|
exit(1.2 > 1.23) |
2796 |
|
|
end on |
2797 |
|
|
)NKSP_CODE", |
2798 |
|
|
.expectBoolExitResult = false |
2799 |
|
|
}); |
2800 |
|
|
|
2801 |
|
|
runScript({ |
2802 |
|
|
.code = R"NKSP_CODE( |
2803 |
|
|
on init |
2804 |
|
|
exit(1.23 > 1.2) |
2805 |
|
|
end on |
2806 |
|
|
)NKSP_CODE", |
2807 |
|
|
.expectBoolExitResult = true |
2808 |
|
|
}); |
2809 |
|
|
|
2810 |
|
|
runScript({ |
2811 |
|
|
.code = R"NKSP_CODE( |
2812 |
|
|
on init |
2813 |
|
|
exit(-4.0 > 3.0) |
2814 |
|
|
end on |
2815 |
|
|
)NKSP_CODE", |
2816 |
|
|
.expectBoolExitResult = false |
2817 |
|
|
}); |
2818 |
|
|
|
2819 |
|
|
runScript({ |
2820 |
|
|
.code = R"NKSP_CODE( |
2821 |
|
|
on init |
2822 |
|
|
exit(3.0 > -4.0) |
2823 |
|
|
end on |
2824 |
|
|
)NKSP_CODE", |
2825 |
|
|
.expectBoolExitResult = true |
2826 |
|
|
}); |
2827 |
|
|
|
2828 |
|
|
runScript({ |
2829 |
|
|
.code = R"NKSP_CODE( |
2830 |
|
|
on init |
2831 |
|
|
exit(123.0 > -45.0) |
2832 |
|
|
end on |
2833 |
|
|
)NKSP_CODE", |
2834 |
|
|
.expectBoolExitResult = true |
2835 |
|
|
}); |
2836 |
|
|
|
2837 |
|
|
runScript({ |
2838 |
|
|
.code = R"NKSP_CODE( |
2839 |
|
|
on init |
2840 |
|
|
exit(-45.0 > 123.0) |
2841 |
|
|
end on |
2842 |
|
|
)NKSP_CODE", |
2843 |
|
|
.expectBoolExitResult = false |
2844 |
|
|
}); |
2845 |
|
|
|
2846 |
|
|
// mixed type tests ... |
2847 |
|
|
|
2848 |
|
|
runScript({ |
2849 |
|
|
.code = R"NKSP_CODE( |
2850 |
|
|
on init |
2851 |
|
|
exit(9 > 9.1) |
2852 |
|
|
end on |
2853 |
|
|
)NKSP_CODE", |
2854 |
|
|
.expectBoolExitResult = false |
2855 |
|
|
}); |
2856 |
|
|
|
2857 |
|
|
runScript({ |
2858 |
|
|
.code = R"NKSP_CODE( |
2859 |
|
|
on init |
2860 |
|
|
exit(9.1 > 9) |
2861 |
|
|
end on |
2862 |
|
|
)NKSP_CODE", |
2863 |
|
|
.expectBoolExitResult = true |
2864 |
|
|
}); |
2865 |
|
|
|
2866 |
schoenebeck |
3581 |
// std unit tests ... |
2867 |
|
|
|
2868 |
|
|
runScript({ |
2869 |
|
|
.code = R"NKSP_CODE( |
2870 |
|
|
on init |
2871 |
|
|
exit(13ms > 14ms) |
2872 |
|
|
end on |
2873 |
|
|
)NKSP_CODE", |
2874 |
|
|
.expectBoolExitResult = false |
2875 |
|
|
}); |
2876 |
|
|
|
2877 |
|
|
runScript({ |
2878 |
|
|
.code = R"NKSP_CODE( |
2879 |
|
|
on init |
2880 |
|
|
exit(14ms > 13ms) |
2881 |
|
|
end on |
2882 |
|
|
)NKSP_CODE", |
2883 |
|
|
.expectBoolExitResult = true |
2884 |
|
|
}); |
2885 |
|
|
|
2886 |
|
|
runScript({ |
2887 |
|
|
.code = R"NKSP_CODE( |
2888 |
|
|
on init |
2889 |
|
|
exit(1s > 990ms) |
2890 |
|
|
end on |
2891 |
|
|
)NKSP_CODE", |
2892 |
|
|
.expectBoolExitResult = true |
2893 |
|
|
}); |
2894 |
|
|
|
2895 |
|
|
runScript({ |
2896 |
|
|
.code = R"NKSP_CODE( |
2897 |
|
|
on init |
2898 |
|
|
exit(990ms > 1s) |
2899 |
|
|
end on |
2900 |
|
|
)NKSP_CODE", |
2901 |
|
|
.expectBoolExitResult = false |
2902 |
|
|
}); |
2903 |
|
|
|
2904 |
|
|
runScript({ |
2905 |
|
|
.code = R"NKSP_CODE( |
2906 |
|
|
on init |
2907 |
|
|
exit(1000ms > 1s) |
2908 |
|
|
end on |
2909 |
|
|
)NKSP_CODE", |
2910 |
|
|
.expectBoolExitResult = false |
2911 |
|
|
}); |
2912 |
|
|
|
2913 |
|
|
runScript({ |
2914 |
|
|
.code = R"NKSP_CODE( |
2915 |
|
|
on init |
2916 |
|
|
exit(1s > 1000ms) |
2917 |
|
|
end on |
2918 |
|
|
)NKSP_CODE", |
2919 |
|
|
.expectBoolExitResult = false |
2920 |
|
|
}); |
2921 |
|
|
|
2922 |
|
|
runScript({ |
2923 |
|
|
.code = R"NKSP_CODE( |
2924 |
|
|
on init |
2925 |
|
|
exit(1s > 1) |
2926 |
|
|
end on |
2927 |
|
|
)NKSP_CODE", |
2928 |
|
|
.expectParseError = true // units on both sides must match |
2929 |
|
|
}); |
2930 |
|
|
|
2931 |
|
|
runScript({ |
2932 |
|
|
.code = R"NKSP_CODE( |
2933 |
|
|
on init |
2934 |
|
|
exit(1 > 1s) |
2935 |
|
|
end on |
2936 |
|
|
)NKSP_CODE", |
2937 |
|
|
.expectParseError = true // units on both sides must match |
2938 |
|
|
}); |
2939 |
|
|
|
2940 |
|
|
runScript({ |
2941 |
|
|
.code = R"NKSP_CODE( |
2942 |
|
|
on init |
2943 |
|
|
exit(1Hz > 1B) |
2944 |
|
|
end on |
2945 |
|
|
)NKSP_CODE", |
2946 |
|
|
.expectParseError = true // units on both sides must match |
2947 |
|
|
}); |
2948 |
|
|
|
2949 |
|
|
runScript({ |
2950 |
|
|
.code = R"NKSP_CODE( |
2951 |
|
|
on init |
2952 |
|
|
exit(13.0ms > 13.1ms) |
2953 |
|
|
end on |
2954 |
|
|
)NKSP_CODE", |
2955 |
|
|
.expectBoolExitResult = false |
2956 |
|
|
}); |
2957 |
|
|
|
2958 |
|
|
runScript({ |
2959 |
|
|
.code = R"NKSP_CODE( |
2960 |
|
|
on init |
2961 |
|
|
exit(13.1ms > 13.0ms) |
2962 |
|
|
end on |
2963 |
|
|
)NKSP_CODE", |
2964 |
|
|
.expectBoolExitResult = true |
2965 |
|
|
}); |
2966 |
|
|
|
2967 |
|
|
runScript({ |
2968 |
|
|
.code = R"NKSP_CODE( |
2969 |
|
|
on init |
2970 |
|
|
exit(0.9s > 600.0ms) |
2971 |
|
|
end on |
2972 |
|
|
)NKSP_CODE", |
2973 |
|
|
.expectBoolExitResult = true |
2974 |
|
|
}); |
2975 |
|
|
|
2976 |
|
|
runScript({ |
2977 |
|
|
.code = R"NKSP_CODE( |
2978 |
|
|
on init |
2979 |
|
|
exit(600.0ms > 0.9s) |
2980 |
|
|
end on |
2981 |
|
|
)NKSP_CODE", |
2982 |
|
|
.expectBoolExitResult = false |
2983 |
|
|
}); |
2984 |
|
|
|
2985 |
|
|
runScript({ |
2986 |
|
|
.code = R"NKSP_CODE( |
2987 |
|
|
on init |
2988 |
|
|
exit(5.1kHz > 5100.0Hz) |
2989 |
|
|
end on |
2990 |
|
|
)NKSP_CODE", |
2991 |
|
|
.expectBoolExitResult = false |
2992 |
|
|
}); |
2993 |
|
|
|
2994 |
|
|
runScript({ |
2995 |
|
|
.code = R"NKSP_CODE( |
2996 |
|
|
on init |
2997 |
|
|
exit(5100.0Hz > 5.1kHz) |
2998 |
|
|
end on |
2999 |
|
|
)NKSP_CODE", |
3000 |
|
|
.expectBoolExitResult = false |
3001 |
|
|
}); |
3002 |
|
|
|
3003 |
|
|
runScript({ |
3004 |
|
|
.code = R"NKSP_CODE( |
3005 |
|
|
on init |
3006 |
|
|
exit(1.0Hz > 1.1) |
3007 |
|
|
end on |
3008 |
|
|
)NKSP_CODE", |
3009 |
|
|
.expectParseError = true // units on both sides must match |
3010 |
|
|
}); |
3011 |
|
|
|
3012 |
|
|
runScript({ |
3013 |
|
|
.code = R"NKSP_CODE( |
3014 |
|
|
on init |
3015 |
|
|
exit(1.2 > 1.34mdB) |
3016 |
|
|
end on |
3017 |
|
|
)NKSP_CODE", |
3018 |
|
|
.expectParseError = true // units on both sides must match |
3019 |
|
|
}); |
3020 |
|
|
|
3021 |
|
|
runScript({ |
3022 |
|
|
.code = R"NKSP_CODE( |
3023 |
|
|
on init |
3024 |
|
|
exit(9.23us > 3.14kHz) |
3025 |
|
|
end on |
3026 |
|
|
)NKSP_CODE", |
3027 |
|
|
.expectParseError = true // units on both sides must match |
3028 |
|
|
}); |
3029 |
|
|
|
3030 |
|
|
// 'final' ('!') operator tests ... |
3031 |
|
|
// (should always yield in false for relation operators) |
3032 |
|
|
|
3033 |
|
|
runScript({ |
3034 |
|
|
.code = R"NKSP_CODE( |
3035 |
|
|
on init |
3036 |
|
|
exit(!-4 > !3) |
3037 |
|
|
end on |
3038 |
|
|
)NKSP_CODE", |
3039 |
|
|
.expectBoolExitResult = false, |
3040 |
|
|
.expectExitResultFinal = false |
3041 |
|
|
}); |
3042 |
|
|
|
3043 |
|
|
runScript({ |
3044 |
|
|
.code = R"NKSP_CODE( |
3045 |
|
|
on init |
3046 |
|
|
exit(-4 > 3) |
3047 |
|
|
end on |
3048 |
|
|
)NKSP_CODE", |
3049 |
|
|
.expectBoolExitResult = false, |
3050 |
|
|
.expectExitResultFinal = false |
3051 |
|
|
}); |
3052 |
|
|
|
3053 |
schoenebeck |
3551 |
#if !SILENT_TEST |
3054 |
|
|
std::cout << std::endl; |
3055 |
|
|
#endif |
3056 |
|
|
} |
3057 |
|
|
|
3058 |
|
|
static void testSmallerOrEqualOperator() { |
3059 |
|
|
#if !SILENT_TEST |
3060 |
|
|
std::cout << "UNIT TEST: smaller-or-equal (<=) operator\n"; |
3061 |
|
|
#endif |
3062 |
|
|
|
3063 |
schoenebeck |
3575 |
// integer tests ... |
3064 |
|
|
|
3065 |
schoenebeck |
3551 |
runScript({ |
3066 |
|
|
.code = R"NKSP_CODE( |
3067 |
|
|
on init |
3068 |
|
|
exit(3 <= 3) |
3069 |
|
|
end on |
3070 |
|
|
)NKSP_CODE", |
3071 |
|
|
.expectBoolExitResult = true |
3072 |
|
|
}); |
3073 |
|
|
|
3074 |
|
|
runScript({ |
3075 |
|
|
.code = R"NKSP_CODE( |
3076 |
|
|
on init |
3077 |
|
|
exit(4 <= 4) |
3078 |
|
|
end on |
3079 |
|
|
)NKSP_CODE", |
3080 |
|
|
.expectBoolExitResult = true |
3081 |
|
|
}); |
3082 |
|
|
|
3083 |
|
|
runScript({ |
3084 |
|
|
.code = R"NKSP_CODE( |
3085 |
|
|
on init |
3086 |
|
|
exit(-23 <= -23) |
3087 |
|
|
end on |
3088 |
|
|
)NKSP_CODE", |
3089 |
|
|
.expectBoolExitResult = true |
3090 |
|
|
}); |
3091 |
|
|
|
3092 |
|
|
runScript({ |
3093 |
|
|
.code = R"NKSP_CODE( |
3094 |
|
|
on init |
3095 |
|
|
exit(23 <= -23) |
3096 |
|
|
end on |
3097 |
|
|
)NKSP_CODE", |
3098 |
|
|
.expectBoolExitResult = false |
3099 |
|
|
}); |
3100 |
|
|
|
3101 |
|
|
runScript({ |
3102 |
|
|
.code = R"NKSP_CODE( |
3103 |
|
|
on init |
3104 |
|
|
exit(3 <= 4) |
3105 |
|
|
end on |
3106 |
|
|
)NKSP_CODE", |
3107 |
|
|
.expectBoolExitResult = true |
3108 |
|
|
}); |
3109 |
|
|
|
3110 |
|
|
runScript({ |
3111 |
|
|
.code = R"NKSP_CODE( |
3112 |
|
|
on init |
3113 |
|
|
exit(4 <= 3) |
3114 |
|
|
end on |
3115 |
|
|
)NKSP_CODE", |
3116 |
|
|
.expectBoolExitResult = false |
3117 |
|
|
}); |
3118 |
|
|
|
3119 |
|
|
runScript({ |
3120 |
|
|
.code = R"NKSP_CODE( |
3121 |
|
|
on init |
3122 |
|
|
exit(-4 <= 3) |
3123 |
|
|
end on |
3124 |
|
|
)NKSP_CODE", |
3125 |
|
|
.expectBoolExitResult = true |
3126 |
|
|
}); |
3127 |
|
|
|
3128 |
|
|
runScript({ |
3129 |
|
|
.code = R"NKSP_CODE( |
3130 |
|
|
on init |
3131 |
|
|
exit(3 <= -4) |
3132 |
|
|
end on |
3133 |
|
|
)NKSP_CODE", |
3134 |
|
|
.expectBoolExitResult = false |
3135 |
|
|
}); |
3136 |
|
|
|
3137 |
|
|
runScript({ |
3138 |
|
|
.code = R"NKSP_CODE( |
3139 |
|
|
on init |
3140 |
|
|
exit(123 <= -45) |
3141 |
|
|
end on |
3142 |
|
|
)NKSP_CODE", |
3143 |
|
|
.expectBoolExitResult = false |
3144 |
|
|
}); |
3145 |
|
|
|
3146 |
|
|
runScript({ |
3147 |
|
|
.code = R"NKSP_CODE( |
3148 |
|
|
on init |
3149 |
|
|
exit(-45 <= 123) |
3150 |
|
|
end on |
3151 |
|
|
)NKSP_CODE", |
3152 |
|
|
.expectBoolExitResult = true |
3153 |
|
|
}); |
3154 |
|
|
|
3155 |
schoenebeck |
3575 |
// real number tests ... |
3156 |
|
|
|
3157 |
|
|
runScript({ |
3158 |
|
|
.code = R"NKSP_CODE( |
3159 |
|
|
on init |
3160 |
|
|
exit(3.0 <= 3.0) |
3161 |
|
|
end on |
3162 |
|
|
)NKSP_CODE", |
3163 |
|
|
.expectBoolExitResult = true |
3164 |
|
|
}); |
3165 |
|
|
|
3166 |
|
|
runScript({ |
3167 |
|
|
.code = R"NKSP_CODE( |
3168 |
|
|
on init |
3169 |
|
|
exit(4.33 <= 4.33) |
3170 |
|
|
end on |
3171 |
|
|
)NKSP_CODE", |
3172 |
|
|
.expectBoolExitResult = true |
3173 |
|
|
}); |
3174 |
|
|
|
3175 |
|
|
runScript({ |
3176 |
|
|
.code = R"NKSP_CODE( |
3177 |
|
|
on init |
3178 |
|
|
exit(-23.1 <= -23.1) |
3179 |
|
|
end on |
3180 |
|
|
)NKSP_CODE", |
3181 |
|
|
.expectBoolExitResult = true |
3182 |
|
|
}); |
3183 |
|
|
|
3184 |
|
|
runScript({ |
3185 |
|
|
.code = R"NKSP_CODE( |
3186 |
|
|
on init |
3187 |
|
|
exit(23.3 <= -23.3) |
3188 |
|
|
end on |
3189 |
|
|
)NKSP_CODE", |
3190 |
|
|
.expectBoolExitResult = false |
3191 |
|
|
}); |
3192 |
|
|
|
3193 |
|
|
runScript({ |
3194 |
|
|
.code = R"NKSP_CODE( |
3195 |
|
|
on init |
3196 |
|
|
exit(3.0 <= 4.0) |
3197 |
|
|
end on |
3198 |
|
|
)NKSP_CODE", |
3199 |
|
|
.expectBoolExitResult = true |
3200 |
|
|
}); |
3201 |
|
|
|
3202 |
|
|
runScript({ |
3203 |
|
|
.code = R"NKSP_CODE( |
3204 |
|
|
on init |
3205 |
|
|
exit(4.0 <= 3.0) |
3206 |
|
|
end on |
3207 |
|
|
)NKSP_CODE", |
3208 |
|
|
.expectBoolExitResult = false |
3209 |
|
|
}); |
3210 |
|
|
|
3211 |
|
|
runScript({ |
3212 |
|
|
.code = R"NKSP_CODE( |
3213 |
|
|
on init |
3214 |
|
|
exit(-4.0 <= 3.0) |
3215 |
|
|
end on |
3216 |
|
|
)NKSP_CODE", |
3217 |
|
|
.expectBoolExitResult = true |
3218 |
|
|
}); |
3219 |
|
|
|
3220 |
|
|
runScript({ |
3221 |
|
|
.code = R"NKSP_CODE( |
3222 |
|
|
on init |
3223 |
|
|
exit(3.0 <= -4.0) |
3224 |
|
|
end on |
3225 |
|
|
)NKSP_CODE", |
3226 |
|
|
.expectBoolExitResult = false |
3227 |
|
|
}); |
3228 |
|
|
|
3229 |
|
|
runScript({ |
3230 |
|
|
.code = R"NKSP_CODE( |
3231 |
|
|
on init |
3232 |
|
|
exit(123.0 <= -45.0) |
3233 |
|
|
end on |
3234 |
|
|
)NKSP_CODE", |
3235 |
|
|
.expectBoolExitResult = false |
3236 |
|
|
}); |
3237 |
|
|
|
3238 |
|
|
runScript({ |
3239 |
|
|
.code = R"NKSP_CODE( |
3240 |
|
|
on init |
3241 |
|
|
exit(-45.0 <= 123.0) |
3242 |
|
|
end on |
3243 |
|
|
)NKSP_CODE", |
3244 |
|
|
.expectBoolExitResult = true |
3245 |
|
|
}); |
3246 |
|
|
|
3247 |
|
|
// mixed type tests ... |
3248 |
|
|
|
3249 |
|
|
runScript({ |
3250 |
|
|
.code = R"NKSP_CODE( |
3251 |
|
|
on init |
3252 |
|
|
exit(9 <= 9.1) |
3253 |
|
|
end on |
3254 |
|
|
)NKSP_CODE", |
3255 |
|
|
.expectBoolExitResult = true |
3256 |
|
|
}); |
3257 |
|
|
|
3258 |
|
|
runScript({ |
3259 |
|
|
.code = R"NKSP_CODE( |
3260 |
|
|
on init |
3261 |
|
|
exit(9.1 <= 9) |
3262 |
|
|
end on |
3263 |
|
|
)NKSP_CODE", |
3264 |
|
|
.expectBoolExitResult = false |
3265 |
|
|
}); |
3266 |
|
|
|
3267 |
|
|
runScript({ |
3268 |
|
|
.code = R"NKSP_CODE( |
3269 |
|
|
on init |
3270 |
|
|
exit(9 <= 9.0) |
3271 |
|
|
end on |
3272 |
|
|
)NKSP_CODE", |
3273 |
|
|
.expectBoolExitResult = true |
3274 |
|
|
}); |
3275 |
|
|
|
3276 |
|
|
runScript({ |
3277 |
|
|
.code = R"NKSP_CODE( |
3278 |
|
|
on init |
3279 |
|
|
exit(9.0 <= 9) |
3280 |
|
|
end on |
3281 |
|
|
)NKSP_CODE", |
3282 |
|
|
.expectBoolExitResult = true |
3283 |
|
|
}); |
3284 |
|
|
|
3285 |
schoenebeck |
3581 |
// std unit tests ... |
3286 |
|
|
|
3287 |
|
|
runScript({ |
3288 |
|
|
.code = R"NKSP_CODE( |
3289 |
|
|
on init |
3290 |
|
|
exit(13ms <= 14ms) |
3291 |
|
|
end on |
3292 |
|
|
)NKSP_CODE", |
3293 |
|
|
.expectBoolExitResult = true |
3294 |
|
|
}); |
3295 |
|
|
|
3296 |
|
|
runScript({ |
3297 |
|
|
.code = R"NKSP_CODE( |
3298 |
|
|
on init |
3299 |
|
|
exit(14ms <= 13ms) |
3300 |
|
|
end on |
3301 |
|
|
)NKSP_CODE", |
3302 |
|
|
.expectBoolExitResult = false |
3303 |
|
|
}); |
3304 |
|
|
|
3305 |
|
|
runScript({ |
3306 |
|
|
.code = R"NKSP_CODE( |
3307 |
|
|
on init |
3308 |
|
|
exit(1s <= 990ms) |
3309 |
|
|
end on |
3310 |
|
|
)NKSP_CODE", |
3311 |
|
|
.expectBoolExitResult = false |
3312 |
|
|
}); |
3313 |
|
|
|
3314 |
|
|
runScript({ |
3315 |
|
|
.code = R"NKSP_CODE( |
3316 |
|
|
on init |
3317 |
|
|
exit(990ms <= 1s) |
3318 |
|
|
end on |
3319 |
|
|
)NKSP_CODE", |
3320 |
|
|
.expectBoolExitResult = true |
3321 |
|
|
}); |
3322 |
|
|
|
3323 |
|
|
runScript({ |
3324 |
|
|
.code = R"NKSP_CODE( |
3325 |
|
|
on init |
3326 |
|
|
exit(1000ms <= 1s) |
3327 |
|
|
end on |
3328 |
|
|
)NKSP_CODE", |
3329 |
|
|
.expectBoolExitResult = true |
3330 |
|
|
}); |
3331 |
|
|
|
3332 |
|
|
runScript({ |
3333 |
|
|
.code = R"NKSP_CODE( |
3334 |
|
|
on init |
3335 |
|
|
exit(1s <= 1000ms) |
3336 |
|
|
end on |
3337 |
|
|
)NKSP_CODE", |
3338 |
|
|
.expectBoolExitResult = true |
3339 |
|
|
}); |
3340 |
|
|
|
3341 |
|
|
runScript({ |
3342 |
|
|
.code = R"NKSP_CODE( |
3343 |
|
|
on init |
3344 |
|
|
exit(1s <= 1) |
3345 |
|
|
end on |
3346 |
|
|
)NKSP_CODE", |
3347 |
|
|
.expectParseError = true // units on both sides must match |
3348 |
|
|
}); |
3349 |
|
|
|
3350 |
|
|
runScript({ |
3351 |
|
|
.code = R"NKSP_CODE( |
3352 |
|
|
on init |
3353 |
|
|
exit(1 <= 1s) |
3354 |
|
|
end on |
3355 |
|
|
)NKSP_CODE", |
3356 |
|
|
.expectParseError = true // units on both sides must match |
3357 |
|
|
}); |
3358 |
|
|
|
3359 |
|
|
runScript({ |
3360 |
|
|
.code = R"NKSP_CODE( |
3361 |
|
|
on init |
3362 |
|
|
exit(1Hz <= 1B) |
3363 |
|
|
end on |
3364 |
|
|
)NKSP_CODE", |
3365 |
|
|
.expectParseError = true // units on both sides must match |
3366 |
|
|
}); |
3367 |
|
|
|
3368 |
|
|
runScript({ |
3369 |
|
|
.code = R"NKSP_CODE( |
3370 |
|
|
on init |
3371 |
|
|
exit(13.0ms <= 13.1ms) |
3372 |
|
|
end on |
3373 |
|
|
)NKSP_CODE", |
3374 |
|
|
.expectBoolExitResult = true |
3375 |
|
|
}); |
3376 |
|
|
|
3377 |
|
|
runScript({ |
3378 |
|
|
.code = R"NKSP_CODE( |
3379 |
|
|
on init |
3380 |
|
|
exit(13.1ms <= 13.0ms) |
3381 |
|
|
end on |
3382 |
|
|
)NKSP_CODE", |
3383 |
|
|
.expectBoolExitResult = false |
3384 |
|
|
}); |
3385 |
|
|
|
3386 |
|
|
runScript({ |
3387 |
|
|
.code = R"NKSP_CODE( |
3388 |
|
|
on init |
3389 |
|
|
exit(0.9s <= 600.0ms) |
3390 |
|
|
end on |
3391 |
|
|
)NKSP_CODE", |
3392 |
|
|
.expectBoolExitResult = false |
3393 |
|
|
}); |
3394 |
|
|
|
3395 |
|
|
runScript({ |
3396 |
|
|
.code = R"NKSP_CODE( |
3397 |
|
|
on init |
3398 |
|
|
exit(600.0ms <= 0.9s) |
3399 |
|
|
end on |
3400 |
|
|
)NKSP_CODE", |
3401 |
|
|
.expectBoolExitResult = true |
3402 |
|
|
}); |
3403 |
|
|
|
3404 |
|
|
runScript({ |
3405 |
|
|
.code = R"NKSP_CODE( |
3406 |
|
|
on init |
3407 |
|
|
exit(5.1kHz <= 5100.0Hz) |
3408 |
|
|
end on |
3409 |
|
|
)NKSP_CODE", |
3410 |
|
|
.expectBoolExitResult = true |
3411 |
|
|
}); |
3412 |
|
|
|
3413 |
|
|
runScript({ |
3414 |
|
|
.code = R"NKSP_CODE( |
3415 |
|
|
on init |
3416 |
|
|
exit(5100.0Hz <= 5.1kHz) |
3417 |
|
|
end on |
3418 |
|
|
)NKSP_CODE", |
3419 |
|
|
.expectBoolExitResult = true |
3420 |
|
|
}); |
3421 |
|
|
|
3422 |
|
|
runScript({ |
3423 |
|
|
.code = R"NKSP_CODE( |
3424 |
|
|
on init |
3425 |
|
|
exit(1.0Hz <= 1.1) |
3426 |
|
|
end on |
3427 |
|
|
)NKSP_CODE", |
3428 |
|
|
.expectParseError = true // units on both sides must match |
3429 |
|
|
}); |
3430 |
|
|
|
3431 |
|
|
runScript({ |
3432 |
|
|
.code = R"NKSP_CODE( |
3433 |
|
|
on init |
3434 |
|
|
exit(1.2 <= 1.34mdB) |
3435 |
|
|
end on |
3436 |
|
|
)NKSP_CODE", |
3437 |
|
|
.expectParseError = true // units on both sides must match |
3438 |
|
|
}); |
3439 |
|
|
|
3440 |
|
|
runScript({ |
3441 |
|
|
.code = R"NKSP_CODE( |
3442 |
|
|
on init |
3443 |
|
|
exit(9.23us <= 3.14kHz) |
3444 |
|
|
end on |
3445 |
|
|
)NKSP_CODE", |
3446 |
|
|
.expectParseError = true // units on both sides must match |
3447 |
|
|
}); |
3448 |
|
|
|
3449 |
|
|
// 'final' ('!') operator tests ... |
3450 |
|
|
// (should always yield in false for relation operators) |
3451 |
|
|
|
3452 |
|
|
runScript({ |
3453 |
|
|
.code = R"NKSP_CODE( |
3454 |
|
|
on init |
3455 |
|
|
exit(!-4 <= !3) |
3456 |
|
|
end on |
3457 |
|
|
)NKSP_CODE", |
3458 |
|
|
.expectBoolExitResult = true, |
3459 |
|
|
.expectExitResultFinal = false |
3460 |
|
|
}); |
3461 |
|
|
|
3462 |
|
|
runScript({ |
3463 |
|
|
.code = R"NKSP_CODE( |
3464 |
|
|
on init |
3465 |
|
|
exit(-4 <= 3) |
3466 |
|
|
end on |
3467 |
|
|
)NKSP_CODE", |
3468 |
|
|
.expectBoolExitResult = true, |
3469 |
|
|
.expectExitResultFinal = false |
3470 |
|
|
}); |
3471 |
|
|
|
3472 |
schoenebeck |
3551 |
#if !SILENT_TEST |
3473 |
|
|
std::cout << std::endl; |
3474 |
|
|
#endif |
3475 |
|
|
} |
3476 |
|
|
|
3477 |
|
|
static void testGreaterOrEqualOperator() { |
3478 |
|
|
#if !SILENT_TEST |
3479 |
|
|
std::cout << "UNIT TEST: greater-or-equal (>=) operator\n"; |
3480 |
|
|
#endif |
3481 |
|
|
|
3482 |
schoenebeck |
3575 |
// integer tests ... |
3483 |
|
|
|
3484 |
schoenebeck |
3551 |
runScript({ |
3485 |
|
|
.code = R"NKSP_CODE( |
3486 |
|
|
on init |
3487 |
|
|
exit(3 >= 3) |
3488 |
|
|
end on |
3489 |
|
|
)NKSP_CODE", |
3490 |
|
|
.expectBoolExitResult = true |
3491 |
|
|
}); |
3492 |
|
|
|
3493 |
|
|
runScript({ |
3494 |
|
|
.code = R"NKSP_CODE( |
3495 |
|
|
on init |
3496 |
|
|
exit(4 >= 4) |
3497 |
|
|
end on |
3498 |
|
|
)NKSP_CODE", |
3499 |
|
|
.expectBoolExitResult = true |
3500 |
|
|
}); |
3501 |
|
|
|
3502 |
|
|
runScript({ |
3503 |
|
|
.code = R"NKSP_CODE( |
3504 |
|
|
on init |
3505 |
|
|
exit(-23 >= -23) |
3506 |
|
|
end on |
3507 |
|
|
)NKSP_CODE", |
3508 |
|
|
.expectBoolExitResult = true |
3509 |
|
|
}); |
3510 |
|
|
|
3511 |
|
|
runScript({ |
3512 |
|
|
.code = R"NKSP_CODE( |
3513 |
|
|
on init |
3514 |
|
|
exit(23 >= -23) |
3515 |
|
|
end on |
3516 |
|
|
)NKSP_CODE", |
3517 |
|
|
.expectBoolExitResult = true |
3518 |
|
|
}); |
3519 |
|
|
|
3520 |
|
|
runScript({ |
3521 |
|
|
.code = R"NKSP_CODE( |
3522 |
|
|
on init |
3523 |
|
|
exit(3 >= 4) |
3524 |
|
|
end on |
3525 |
|
|
)NKSP_CODE", |
3526 |
|
|
.expectBoolExitResult = false |
3527 |
|
|
}); |
3528 |
|
|
|
3529 |
|
|
runScript({ |
3530 |
|
|
.code = R"NKSP_CODE( |
3531 |
|
|
on init |
3532 |
|
|
exit(4 >= 3) |
3533 |
|
|
end on |
3534 |
|
|
)NKSP_CODE", |
3535 |
|
|
.expectBoolExitResult = true |
3536 |
|
|
}); |
3537 |
|
|
|
3538 |
|
|
runScript({ |
3539 |
|
|
.code = R"NKSP_CODE( |
3540 |
|
|
on init |
3541 |
|
|
exit(-4 >= 3) |
3542 |
|
|
end on |
3543 |
|
|
)NKSP_CODE", |
3544 |
|
|
.expectBoolExitResult = false |
3545 |
|
|
}); |
3546 |
|
|
|
3547 |
|
|
runScript({ |
3548 |
|
|
.code = R"NKSP_CODE( |
3549 |
|
|
on init |
3550 |
|
|
exit(3 >= -4) |
3551 |
|
|
end on |
3552 |
|
|
)NKSP_CODE", |
3553 |
|
|
.expectBoolExitResult = true |
3554 |
|
|
}); |
3555 |
|
|
|
3556 |
|
|
runScript({ |
3557 |
|
|
.code = R"NKSP_CODE( |
3558 |
|
|
on init |
3559 |
|
|
exit(123 >= -45) |
3560 |
|
|
end on |
3561 |
|
|
)NKSP_CODE", |
3562 |
|
|
.expectBoolExitResult = true |
3563 |
|
|
}); |
3564 |
|
|
|
3565 |
|
|
runScript({ |
3566 |
|
|
.code = R"NKSP_CODE( |
3567 |
|
|
on init |
3568 |
|
|
exit(-45 >= 123) |
3569 |
|
|
end on |
3570 |
|
|
)NKSP_CODE", |
3571 |
|
|
.expectBoolExitResult = false |
3572 |
|
|
}); |
3573 |
|
|
|
3574 |
schoenebeck |
3575 |
// real number tests ... |
3575 |
|
|
|
3576 |
|
|
runScript({ |
3577 |
|
|
.code = R"NKSP_CODE( |
3578 |
|
|
on init |
3579 |
|
|
exit(3.0 >= 3.0) |
3580 |
|
|
end on |
3581 |
|
|
)NKSP_CODE", |
3582 |
|
|
.expectBoolExitResult = true |
3583 |
|
|
}); |
3584 |
|
|
|
3585 |
|
|
runScript({ |
3586 |
|
|
.code = R"NKSP_CODE( |
3587 |
|
|
on init |
3588 |
|
|
exit(3.1 >= 3.1) |
3589 |
|
|
end on |
3590 |
|
|
)NKSP_CODE", |
3591 |
|
|
.expectBoolExitResult = true |
3592 |
|
|
}); |
3593 |
|
|
|
3594 |
|
|
runScript({ |
3595 |
|
|
.code = R"NKSP_CODE( |
3596 |
|
|
on init |
3597 |
|
|
exit(3.1 >= 3.0) |
3598 |
|
|
end on |
3599 |
|
|
)NKSP_CODE", |
3600 |
|
|
.expectBoolExitResult = true |
3601 |
|
|
}); |
3602 |
|
|
|
3603 |
|
|
runScript({ |
3604 |
|
|
.code = R"NKSP_CODE( |
3605 |
|
|
on init |
3606 |
|
|
exit(3.0 >= 3.1) |
3607 |
|
|
end on |
3608 |
|
|
)NKSP_CODE", |
3609 |
|
|
.expectBoolExitResult = false |
3610 |
|
|
}); |
3611 |
|
|
|
3612 |
|
|
runScript({ |
3613 |
|
|
.code = R"NKSP_CODE( |
3614 |
|
|
on init |
3615 |
|
|
exit(-23.33 >= -23.33) |
3616 |
|
|
end on |
3617 |
|
|
)NKSP_CODE", |
3618 |
|
|
.expectBoolExitResult = true |
3619 |
|
|
}); |
3620 |
|
|
|
3621 |
|
|
runScript({ |
3622 |
|
|
.code = R"NKSP_CODE( |
3623 |
|
|
on init |
3624 |
|
|
exit(23.0 >= -23.0) |
3625 |
|
|
end on |
3626 |
|
|
)NKSP_CODE", |
3627 |
|
|
.expectBoolExitResult = true |
3628 |
|
|
}); |
3629 |
|
|
|
3630 |
|
|
runScript({ |
3631 |
|
|
.code = R"NKSP_CODE( |
3632 |
|
|
on init |
3633 |
|
|
exit(3.0 >= 4.0) |
3634 |
|
|
end on |
3635 |
|
|
)NKSP_CODE", |
3636 |
|
|
.expectBoolExitResult = false |
3637 |
|
|
}); |
3638 |
|
|
|
3639 |
|
|
runScript({ |
3640 |
|
|
.code = R"NKSP_CODE( |
3641 |
|
|
on init |
3642 |
|
|
exit(4.0 >= 3.0) |
3643 |
|
|
end on |
3644 |
|
|
)NKSP_CODE", |
3645 |
|
|
.expectBoolExitResult = true |
3646 |
|
|
}); |
3647 |
|
|
|
3648 |
|
|
runScript({ |
3649 |
|
|
.code = R"NKSP_CODE( |
3650 |
|
|
on init |
3651 |
|
|
exit(-4.0 >= 3.0) |
3652 |
|
|
end on |
3653 |
|
|
)NKSP_CODE", |
3654 |
|
|
.expectBoolExitResult = false |
3655 |
|
|
}); |
3656 |
|
|
|
3657 |
|
|
runScript({ |
3658 |
|
|
.code = R"NKSP_CODE( |
3659 |
|
|
on init |
3660 |
|
|
exit(3.0 >= -4.0) |
3661 |
|
|
end on |
3662 |
|
|
)NKSP_CODE", |
3663 |
|
|
.expectBoolExitResult = true |
3664 |
|
|
}); |
3665 |
|
|
|
3666 |
|
|
runScript({ |
3667 |
|
|
.code = R"NKSP_CODE( |
3668 |
|
|
on init |
3669 |
|
|
exit(123.0 >= -45.0) |
3670 |
|
|
end on |
3671 |
|
|
)NKSP_CODE", |
3672 |
|
|
.expectBoolExitResult = true |
3673 |
|
|
}); |
3674 |
|
|
|
3675 |
|
|
runScript({ |
3676 |
|
|
.code = R"NKSP_CODE( |
3677 |
|
|
on init |
3678 |
|
|
exit(-45.0 >= 123.0) |
3679 |
|
|
end on |
3680 |
|
|
)NKSP_CODE", |
3681 |
|
|
.expectBoolExitResult = false |
3682 |
|
|
}); |
3683 |
|
|
|
3684 |
|
|
// mixed type tests ... |
3685 |
|
|
|
3686 |
|
|
runScript({ |
3687 |
|
|
.code = R"NKSP_CODE( |
3688 |
|
|
on init |
3689 |
|
|
exit(9 >= 9.1) |
3690 |
|
|
end on |
3691 |
|
|
)NKSP_CODE", |
3692 |
|
|
.expectBoolExitResult = false |
3693 |
|
|
}); |
3694 |
|
|
|
3695 |
|
|
runScript({ |
3696 |
|
|
.code = R"NKSP_CODE( |
3697 |
|
|
on init |
3698 |
|
|
exit(9.1 >= 9) |
3699 |
|
|
end on |
3700 |
|
|
)NKSP_CODE", |
3701 |
|
|
.expectBoolExitResult = true |
3702 |
|
|
}); |
3703 |
|
|
|
3704 |
|
|
runScript({ |
3705 |
|
|
.code = R"NKSP_CODE( |
3706 |
|
|
on init |
3707 |
|
|
exit(9 >= 9.0) |
3708 |
|
|
end on |
3709 |
|
|
)NKSP_CODE", |
3710 |
|
|
.expectBoolExitResult = true |
3711 |
|
|
}); |
3712 |
|
|
|
3713 |
|
|
runScript({ |
3714 |
|
|
.code = R"NKSP_CODE( |
3715 |
|
|
on init |
3716 |
|
|
exit(9.0 >= 9) |
3717 |
|
|
end on |
3718 |
|
|
)NKSP_CODE", |
3719 |
|
|
.expectBoolExitResult = true |
3720 |
|
|
}); |
3721 |
|
|
|
3722 |
schoenebeck |
3581 |
// std unit tests ... |
3723 |
|
|
|
3724 |
|
|
runScript({ |
3725 |
|
|
.code = R"NKSP_CODE( |
3726 |
|
|
on init |
3727 |
|
|
exit(13ms >= 14ms) |
3728 |
|
|
end on |
3729 |
|
|
)NKSP_CODE", |
3730 |
|
|
.expectBoolExitResult = false |
3731 |
|
|
}); |
3732 |
|
|
|
3733 |
|
|
runScript({ |
3734 |
|
|
.code = R"NKSP_CODE( |
3735 |
|
|
on init |
3736 |
|
|
exit(14ms >= 13ms) |
3737 |
|
|
end on |
3738 |
|
|
)NKSP_CODE", |
3739 |
|
|
.expectBoolExitResult = true |
3740 |
|
|
}); |
3741 |
|
|
|
3742 |
|
|
runScript({ |
3743 |
|
|
.code = R"NKSP_CODE( |
3744 |
|
|
on init |
3745 |
|
|
exit(1s >= 990ms) |
3746 |
|
|
end on |
3747 |
|
|
)NKSP_CODE", |
3748 |
|
|
.expectBoolExitResult = true |
3749 |
|
|
}); |
3750 |
|
|
|
3751 |
|
|
runScript({ |
3752 |
|
|
.code = R"NKSP_CODE( |
3753 |
|
|
on init |
3754 |
|
|
exit(990ms >= 1s) |
3755 |
|
|
end on |
3756 |
|
|
)NKSP_CODE", |
3757 |
|
|
.expectBoolExitResult = false |
3758 |
|
|
}); |
3759 |
|
|
|
3760 |
|
|
runScript({ |
3761 |
|
|
.code = R"NKSP_CODE( |
3762 |
|
|
on init |
3763 |
|
|
exit(1000ms >= 1s) |
3764 |
|
|
end on |
3765 |
|
|
)NKSP_CODE", |
3766 |
|
|
.expectBoolExitResult = true |
3767 |
|
|
}); |
3768 |
|
|
|
3769 |
|
|
runScript({ |
3770 |
|
|
.code = R"NKSP_CODE( |
3771 |
|
|
on init |
3772 |
|
|
exit(1s >= 1000ms) |
3773 |
|
|
end on |
3774 |
|
|
)NKSP_CODE", |
3775 |
|
|
.expectBoolExitResult = true |
3776 |
|
|
}); |
3777 |
|
|
|
3778 |
|
|
runScript({ |
3779 |
|
|
.code = R"NKSP_CODE( |
3780 |
|
|
on init |
3781 |
|
|
exit(1s >= 1) |
3782 |
|
|
end on |
3783 |
|
|
)NKSP_CODE", |
3784 |
|
|
.expectParseError = true // units on both sides must match |
3785 |
|
|
}); |
3786 |
|
|
|
3787 |
|
|
runScript({ |
3788 |
|
|
.code = R"NKSP_CODE( |
3789 |
|
|
on init |
3790 |
|
|
exit(1 >= 1s) |
3791 |
|
|
end on |
3792 |
|
|
)NKSP_CODE", |
3793 |
|
|
.expectParseError = true // units on both sides must match |
3794 |
|
|
}); |
3795 |
|
|
|
3796 |
|
|
runScript({ |
3797 |
|
|
.code = R"NKSP_CODE( |
3798 |
|
|
on init |
3799 |
|
|
exit(1Hz >= 1B) |
3800 |
|
|
end on |
3801 |
|
|
)NKSP_CODE", |
3802 |
|
|
.expectParseError = true // units on both sides must match |
3803 |
|
|
}); |
3804 |
|
|
|
3805 |
|
|
runScript({ |
3806 |
|
|
.code = R"NKSP_CODE( |
3807 |
|
|
on init |
3808 |
|
|
exit(13.0ms >= 13.1ms) |
3809 |
|
|
end on |
3810 |
|
|
)NKSP_CODE", |
3811 |
|
|
.expectBoolExitResult = false |
3812 |
|
|
}); |
3813 |
|
|
|
3814 |
|
|
runScript({ |
3815 |
|
|
.code = R"NKSP_CODE( |
3816 |
|
|
on init |
3817 |
|
|
exit(13.1ms >= 13.0ms) |
3818 |
|
|
end on |
3819 |
|
|
)NKSP_CODE", |
3820 |
|
|
.expectBoolExitResult = true |
3821 |
|
|
}); |
3822 |
|
|
|
3823 |
|
|
runScript({ |
3824 |
|
|
.code = R"NKSP_CODE( |
3825 |
|
|
on init |
3826 |
|
|
exit(0.9s >= 600.0ms) |
3827 |
|
|
end on |
3828 |
|
|
)NKSP_CODE", |
3829 |
|
|
.expectBoolExitResult = true |
3830 |
|
|
}); |
3831 |
|
|
|
3832 |
|
|
runScript({ |
3833 |
|
|
.code = R"NKSP_CODE( |
3834 |
|
|
on init |
3835 |
|
|
exit(600.0ms >= 0.9s) |
3836 |
|
|
end on |
3837 |
|
|
)NKSP_CODE", |
3838 |
|
|
.expectBoolExitResult = false |
3839 |
|
|
}); |
3840 |
|
|
|
3841 |
|
|
runScript({ |
3842 |
|
|
.code = R"NKSP_CODE( |
3843 |
|
|
on init |
3844 |
|
|
exit(5.1kHz >= 5100.0Hz) |
3845 |
|
|
end on |
3846 |
|
|
)NKSP_CODE", |
3847 |
|
|
.expectBoolExitResult = true |
3848 |
|
|
}); |
3849 |
|
|
|
3850 |
|
|
runScript({ |
3851 |
|
|
.code = R"NKSP_CODE( |
3852 |
|
|
on init |
3853 |
|
|
exit(5100.0Hz >= 5.1kHz) |
3854 |
|
|
end on |
3855 |
|
|
)NKSP_CODE", |
3856 |
|
|
.expectBoolExitResult = true |
3857 |
|
|
}); |
3858 |
|
|
|
3859 |
|
|
runScript({ |
3860 |
|
|
.code = R"NKSP_CODE( |
3861 |
|
|
on init |
3862 |
|
|
exit(1.0Hz >= 1.1) |
3863 |
|
|
end on |
3864 |
|
|
)NKSP_CODE", |
3865 |
|
|
.expectParseError = true // units on both sides must match |
3866 |
|
|
}); |
3867 |
|
|
|
3868 |
|
|
runScript({ |
3869 |
|
|
.code = R"NKSP_CODE( |
3870 |
|
|
on init |
3871 |
|
|
exit(1.2 >= 1.34mdB) |
3872 |
|
|
end on |
3873 |
|
|
)NKSP_CODE", |
3874 |
|
|
.expectParseError = true // units on both sides must match |
3875 |
|
|
}); |
3876 |
|
|
|
3877 |
|
|
runScript({ |
3878 |
|
|
.code = R"NKSP_CODE( |
3879 |
|
|
on init |
3880 |
|
|
exit(9.23us >= 3.14kHz) |
3881 |
|
|
end on |
3882 |
|
|
)NKSP_CODE", |
3883 |
|
|
.expectParseError = true // units on both sides must match |
3884 |
|
|
}); |
3885 |
|
|
|
3886 |
|
|
// 'final' ('!') operator tests ... |
3887 |
|
|
// (should always yield in false for relation operators) |
3888 |
|
|
|
3889 |
|
|
runScript({ |
3890 |
|
|
.code = R"NKSP_CODE( |
3891 |
|
|
on init |
3892 |
|
|
exit(!-4 >= !3) |
3893 |
|
|
end on |
3894 |
|
|
)NKSP_CODE", |
3895 |
|
|
.expectBoolExitResult = false, |
3896 |
|
|
.expectExitResultFinal = false |
3897 |
|
|
}); |
3898 |
|
|
|
3899 |
|
|
runScript({ |
3900 |
|
|
.code = R"NKSP_CODE( |
3901 |
|
|
on init |
3902 |
|
|
exit(-4 >= 3) |
3903 |
|
|
end on |
3904 |
|
|
)NKSP_CODE", |
3905 |
|
|
.expectBoolExitResult = false, |
3906 |
|
|
.expectExitResultFinal = false |
3907 |
|
|
}); |
3908 |
|
|
|
3909 |
schoenebeck |
3551 |
#if !SILENT_TEST |
3910 |
|
|
std::cout << std::endl; |
3911 |
|
|
#endif |
3912 |
|
|
} |
3913 |
|
|
|
3914 |
|
|
static void testEqualOperator() { |
3915 |
|
|
#if !SILENT_TEST |
3916 |
|
|
std::cout << "UNIT TEST: equal (=) operator\n"; |
3917 |
|
|
#endif |
3918 |
|
|
|
3919 |
schoenebeck |
3575 |
// integer tests ... |
3920 |
|
|
|
3921 |
schoenebeck |
3551 |
runScript({ |
3922 |
|
|
.code = R"NKSP_CODE( |
3923 |
|
|
on init |
3924 |
|
|
exit(3 = 3) |
3925 |
|
|
end on |
3926 |
|
|
)NKSP_CODE", |
3927 |
|
|
.expectBoolExitResult = true |
3928 |
|
|
}); |
3929 |
|
|
|
3930 |
|
|
runScript({ |
3931 |
|
|
.code = R"NKSP_CODE( |
3932 |
|
|
on init |
3933 |
|
|
exit(4 = 4) |
3934 |
|
|
end on |
3935 |
|
|
)NKSP_CODE", |
3936 |
|
|
.expectBoolExitResult = true |
3937 |
|
|
}); |
3938 |
|
|
|
3939 |
|
|
runScript({ |
3940 |
|
|
.code = R"NKSP_CODE( |
3941 |
|
|
on init |
3942 |
|
|
exit(3 = 4) |
3943 |
|
|
end on |
3944 |
|
|
)NKSP_CODE", |
3945 |
|
|
.expectBoolExitResult = false |
3946 |
|
|
}); |
3947 |
|
|
|
3948 |
|
|
runScript({ |
3949 |
|
|
.code = R"NKSP_CODE( |
3950 |
|
|
on init |
3951 |
|
|
exit(23 = -23) |
3952 |
|
|
end on |
3953 |
|
|
)NKSP_CODE", |
3954 |
|
|
.expectBoolExitResult = false |
3955 |
|
|
}); |
3956 |
|
|
|
3957 |
schoenebeck |
3575 |
// real number tests ... |
3958 |
|
|
|
3959 |
|
|
runScript({ |
3960 |
|
|
.code = R"NKSP_CODE( |
3961 |
|
|
on init |
3962 |
|
|
exit(3.0 = 3.0) |
3963 |
|
|
end on |
3964 |
|
|
)NKSP_CODE", |
3965 |
|
|
.expectBoolExitResult = true |
3966 |
|
|
}); |
3967 |
|
|
|
3968 |
|
|
runScript({ |
3969 |
|
|
.code = R"NKSP_CODE( |
3970 |
|
|
on init |
3971 |
|
|
exit(4.33 = 4.33) |
3972 |
|
|
end on |
3973 |
|
|
)NKSP_CODE", |
3974 |
|
|
.expectBoolExitResult = true |
3975 |
|
|
}); |
3976 |
|
|
|
3977 |
|
|
runScript({ |
3978 |
|
|
.code = R"NKSP_CODE( |
3979 |
|
|
on init |
3980 |
|
|
exit(4.31 = 4.35) |
3981 |
|
|
end on |
3982 |
|
|
)NKSP_CODE", |
3983 |
|
|
.expectBoolExitResult = false |
3984 |
|
|
}); |
3985 |
|
|
|
3986 |
|
|
runScript({ |
3987 |
|
|
.code = R"NKSP_CODE( |
3988 |
|
|
on init |
3989 |
|
|
exit(3.0 = 4.0) |
3990 |
|
|
end on |
3991 |
|
|
)NKSP_CODE", |
3992 |
|
|
.expectBoolExitResult = false |
3993 |
|
|
}); |
3994 |
|
|
|
3995 |
|
|
runScript({ |
3996 |
|
|
.code = R"NKSP_CODE( |
3997 |
|
|
on init |
3998 |
|
|
exit(23.0 = -23.0) |
3999 |
|
|
end on |
4000 |
|
|
)NKSP_CODE", |
4001 |
|
|
.expectBoolExitResult = false |
4002 |
|
|
}); |
4003 |
|
|
|
4004 |
schoenebeck |
3581 |
// deal with inaccuracy of float point |
4005 |
|
|
runScript({ |
4006 |
|
|
.code = R"NKSP_CODE( |
4007 |
|
|
on init |
4008 |
|
|
declare ~a := 0.165 |
4009 |
|
|
declare ~b := 0.185 |
4010 |
|
|
declare ~x := 0.1 |
4011 |
|
|
declare ~y := 0.25 |
4012 |
|
|
exit(~a + ~b = ~x + ~y) { both sides should actually be 0.35, they slightly deviate both though } |
4013 |
|
|
end on |
4014 |
|
|
)NKSP_CODE", |
4015 |
|
|
.expectBoolExitResult = true // our implementation of real number equal comparison should take care about floating point tolerance |
4016 |
|
|
}); |
4017 |
|
|
|
4018 |
|
|
// deal with inaccuracy of float point |
4019 |
|
|
runScript({ |
4020 |
|
|
.code = R"NKSP_CODE( |
4021 |
|
|
on init |
4022 |
|
|
declare ~a := 0.166 |
4023 |
|
|
declare ~b := 0.185 |
4024 |
|
|
declare ~x := 0.1 |
4025 |
|
|
declare ~y := 0.25 |
4026 |
|
|
exit(~a + ~b = ~x + ~y) { left side approx. 0.351, right side approx. 0.35 } |
4027 |
|
|
end on |
4028 |
|
|
)NKSP_CODE", |
4029 |
|
|
.expectBoolExitResult = false |
4030 |
|
|
}); |
4031 |
|
|
|
4032 |
schoenebeck |
3575 |
// mixed type tests ... |
4033 |
|
|
|
4034 |
|
|
runScript({ |
4035 |
|
|
.code = R"NKSP_CODE( |
4036 |
|
|
on init |
4037 |
|
|
exit(23 = 23.0) |
4038 |
|
|
end on |
4039 |
|
|
)NKSP_CODE", |
4040 |
|
|
.expectBoolExitResult = true |
4041 |
|
|
}); |
4042 |
|
|
|
4043 |
|
|
runScript({ |
4044 |
|
|
.code = R"NKSP_CODE( |
4045 |
|
|
on init |
4046 |
|
|
exit(23.0 = 23) |
4047 |
|
|
end on |
4048 |
|
|
)NKSP_CODE", |
4049 |
|
|
.expectBoolExitResult = true |
4050 |
|
|
}); |
4051 |
|
|
|
4052 |
|
|
runScript({ |
4053 |
|
|
.code = R"NKSP_CODE( |
4054 |
|
|
on init |
4055 |
|
|
exit(23 = 23.1) |
4056 |
|
|
end on |
4057 |
|
|
)NKSP_CODE", |
4058 |
|
|
.expectBoolExitResult = false |
4059 |
|
|
}); |
4060 |
|
|
|
4061 |
|
|
runScript({ |
4062 |
|
|
.code = R"NKSP_CODE( |
4063 |
|
|
on init |
4064 |
|
|
exit(23.1 = 23) |
4065 |
|
|
end on |
4066 |
|
|
)NKSP_CODE", |
4067 |
|
|
.expectBoolExitResult = false |
4068 |
|
|
}); |
4069 |
|
|
|
4070 |
schoenebeck |
3581 |
// std unit tests ... |
4071 |
|
|
|
4072 |
|
|
runScript({ |
4073 |
|
|
.code = R"NKSP_CODE( |
4074 |
|
|
on init |
4075 |
|
|
exit(13ms = 14ms) |
4076 |
|
|
end on |
4077 |
|
|
)NKSP_CODE", |
4078 |
|
|
.expectBoolExitResult = false |
4079 |
|
|
}); |
4080 |
|
|
|
4081 |
|
|
runScript({ |
4082 |
|
|
.code = R"NKSP_CODE( |
4083 |
|
|
on init |
4084 |
|
|
exit(14ms = 13ms) |
4085 |
|
|
end on |
4086 |
|
|
)NKSP_CODE", |
4087 |
|
|
.expectBoolExitResult = false |
4088 |
|
|
}); |
4089 |
|
|
|
4090 |
|
|
runScript({ |
4091 |
|
|
.code = R"NKSP_CODE( |
4092 |
|
|
on init |
4093 |
|
|
exit(1s = 1ms) |
4094 |
|
|
end on |
4095 |
|
|
)NKSP_CODE", |
4096 |
|
|
.expectBoolExitResult = false |
4097 |
|
|
}); |
4098 |
|
|
|
4099 |
|
|
runScript({ |
4100 |
|
|
.code = R"NKSP_CODE( |
4101 |
|
|
on init |
4102 |
|
|
exit(1ms = 1s) |
4103 |
|
|
end on |
4104 |
|
|
)NKSP_CODE", |
4105 |
|
|
.expectBoolExitResult = false |
4106 |
|
|
}); |
4107 |
|
|
|
4108 |
|
|
runScript({ |
4109 |
|
|
.code = R"NKSP_CODE( |
4110 |
|
|
on init |
4111 |
|
|
exit(3.14kHz = 3140Hz) |
4112 |
|
|
end on |
4113 |
|
|
)NKSP_CODE", |
4114 |
|
|
.expectBoolExitResult = true |
4115 |
|
|
}); |
4116 |
|
|
|
4117 |
|
|
runScript({ |
4118 |
|
|
.code = R"NKSP_CODE( |
4119 |
|
|
on init |
4120 |
|
|
exit(3140Hz = 3.14kHz) |
4121 |
|
|
end on |
4122 |
|
|
)NKSP_CODE", |
4123 |
|
|
.expectBoolExitResult = true |
4124 |
|
|
}); |
4125 |
|
|
|
4126 |
|
|
runScript({ |
4127 |
|
|
.code = R"NKSP_CODE( |
4128 |
|
|
on init |
4129 |
|
|
exit(1s = 1) |
4130 |
|
|
end on |
4131 |
|
|
)NKSP_CODE", |
4132 |
|
|
.expectParseError = true // units on both sides must match |
4133 |
|
|
}); |
4134 |
|
|
|
4135 |
|
|
runScript({ |
4136 |
|
|
.code = R"NKSP_CODE( |
4137 |
|
|
on init |
4138 |
|
|
exit(1 = 1s) |
4139 |
|
|
end on |
4140 |
|
|
)NKSP_CODE", |
4141 |
|
|
.expectParseError = true // units on both sides must match |
4142 |
|
|
}); |
4143 |
|
|
|
4144 |
|
|
runScript({ |
4145 |
|
|
.code = R"NKSP_CODE( |
4146 |
|
|
on init |
4147 |
|
|
exit(1Hz = 1B) |
4148 |
|
|
end on |
4149 |
|
|
)NKSP_CODE", |
4150 |
|
|
.expectParseError = true // units on both sides must match |
4151 |
|
|
}); |
4152 |
|
|
|
4153 |
|
|
// 'final' ('!') operator tests ... |
4154 |
|
|
// (should always yield in false for relation operators) |
4155 |
|
|
|
4156 |
|
|
runScript({ |
4157 |
|
|
.code = R"NKSP_CODE( |
4158 |
|
|
on init |
4159 |
|
|
exit(!-4 = !3) |
4160 |
|
|
end on |
4161 |
|
|
)NKSP_CODE", |
4162 |
|
|
.expectBoolExitResult = false, |
4163 |
|
|
.expectExitResultFinal = false |
4164 |
|
|
}); |
4165 |
|
|
|
4166 |
|
|
runScript({ |
4167 |
|
|
.code = R"NKSP_CODE( |
4168 |
|
|
on init |
4169 |
|
|
exit(-4 = 3) |
4170 |
|
|
end on |
4171 |
|
|
)NKSP_CODE", |
4172 |
|
|
.expectBoolExitResult = false, |
4173 |
|
|
.expectExitResultFinal = false |
4174 |
|
|
}); |
4175 |
|
|
|
4176 |
schoenebeck |
3551 |
#if !SILENT_TEST |
4177 |
|
|
std::cout << std::endl; |
4178 |
|
|
#endif |
4179 |
|
|
} |
4180 |
|
|
|
4181 |
|
|
static void testUnequalOperator() { |
4182 |
|
|
#if !SILENT_TEST |
4183 |
|
|
std::cout << "UNIT TEST: unequal (#) operator\n"; |
4184 |
|
|
#endif |
4185 |
|
|
|
4186 |
schoenebeck |
3575 |
// integer tests ... |
4187 |
|
|
|
4188 |
schoenebeck |
3551 |
runScript({ |
4189 |
|
|
.code = R"NKSP_CODE( |
4190 |
|
|
on init |
4191 |
|
|
exit(3 # 3) |
4192 |
|
|
end on |
4193 |
|
|
)NKSP_CODE", |
4194 |
|
|
.expectBoolExitResult = false |
4195 |
|
|
}); |
4196 |
|
|
|
4197 |
|
|
runScript({ |
4198 |
|
|
.code = R"NKSP_CODE( |
4199 |
|
|
on init |
4200 |
|
|
exit(4 # 4) |
4201 |
|
|
end on |
4202 |
|
|
)NKSP_CODE", |
4203 |
|
|
.expectBoolExitResult = false |
4204 |
|
|
}); |
4205 |
|
|
|
4206 |
|
|
runScript({ |
4207 |
|
|
.code = R"NKSP_CODE( |
4208 |
|
|
on init |
4209 |
|
|
exit(3 # 4) |
4210 |
|
|
end on |
4211 |
|
|
)NKSP_CODE", |
4212 |
|
|
.expectBoolExitResult = true |
4213 |
|
|
}); |
4214 |
|
|
|
4215 |
|
|
runScript({ |
4216 |
|
|
.code = R"NKSP_CODE( |
4217 |
|
|
on init |
4218 |
|
|
exit(23 # -23) |
4219 |
|
|
end on |
4220 |
|
|
)NKSP_CODE", |
4221 |
|
|
.expectBoolExitResult = true |
4222 |
|
|
}); |
4223 |
|
|
|
4224 |
schoenebeck |
3575 |
// real number tests ... |
4225 |
|
|
|
4226 |
|
|
runScript({ |
4227 |
|
|
.code = R"NKSP_CODE( |
4228 |
|
|
on init |
4229 |
|
|
exit(3.0 # 3.0) |
4230 |
|
|
end on |
4231 |
|
|
)NKSP_CODE", |
4232 |
|
|
.expectBoolExitResult = false |
4233 |
|
|
}); |
4234 |
|
|
|
4235 |
|
|
runScript({ |
4236 |
|
|
.code = R"NKSP_CODE( |
4237 |
|
|
on init |
4238 |
|
|
exit(3.14 # 3.14) |
4239 |
|
|
end on |
4240 |
|
|
)NKSP_CODE", |
4241 |
|
|
.expectBoolExitResult = false |
4242 |
|
|
}); |
4243 |
|
|
|
4244 |
|
|
runScript({ |
4245 |
|
|
.code = R"NKSP_CODE( |
4246 |
|
|
on init |
4247 |
|
|
exit(3.19 # 3.12) |
4248 |
|
|
end on |
4249 |
|
|
)NKSP_CODE", |
4250 |
|
|
.expectBoolExitResult = true |
4251 |
|
|
}); |
4252 |
|
|
|
4253 |
|
|
runScript({ |
4254 |
|
|
.code = R"NKSP_CODE( |
4255 |
|
|
on init |
4256 |
|
|
exit(23.0 # -23.0) |
4257 |
|
|
end on |
4258 |
|
|
)NKSP_CODE", |
4259 |
|
|
.expectBoolExitResult = true |
4260 |
|
|
}); |
4261 |
|
|
|
4262 |
schoenebeck |
3581 |
// deal with inaccuracy of float point |
4263 |
|
|
runScript({ |
4264 |
|
|
.code = R"NKSP_CODE( |
4265 |
|
|
on init |
4266 |
|
|
declare ~a := 0.165 |
4267 |
|
|
declare ~b := 0.185 |
4268 |
|
|
declare ~x := 0.1 |
4269 |
|
|
declare ~y := 0.25 |
4270 |
|
|
exit(~a + ~b # ~x + ~y) { both sides should actually be 0.35, they slightly deviate both though } |
4271 |
|
|
end on |
4272 |
|
|
)NKSP_CODE", |
4273 |
|
|
.expectBoolExitResult = false // our implementation of real number unequal comparison should take care about floating point tolerance |
4274 |
|
|
}); |
4275 |
|
|
|
4276 |
|
|
// deal with inaccuracy of float point |
4277 |
|
|
runScript({ |
4278 |
|
|
.code = R"NKSP_CODE( |
4279 |
|
|
on init |
4280 |
|
|
declare ~a := 0.166 |
4281 |
|
|
declare ~b := 0.185 |
4282 |
|
|
declare ~x := 0.1 |
4283 |
|
|
declare ~y := 0.25 |
4284 |
|
|
exit(~a + ~b # ~x + ~y) { left side approx. 0.351, right side approx. 0.35 } |
4285 |
|
|
end on |
4286 |
|
|
)NKSP_CODE", |
4287 |
|
|
.expectBoolExitResult = true |
4288 |
|
|
}); |
4289 |
|
|
|
4290 |
schoenebeck |
3575 |
// mixed type tests ... |
4291 |
|
|
|
4292 |
|
|
runScript({ |
4293 |
|
|
.code = R"NKSP_CODE( |
4294 |
|
|
on init |
4295 |
|
|
exit(3 # 3.0) |
4296 |
|
|
end on |
4297 |
|
|
)NKSP_CODE", |
4298 |
|
|
.expectBoolExitResult = false |
4299 |
|
|
}); |
4300 |
|
|
|
4301 |
|
|
runScript({ |
4302 |
|
|
.code = R"NKSP_CODE( |
4303 |
|
|
on init |
4304 |
|
|
exit(3.0 # 3) |
4305 |
|
|
end on |
4306 |
|
|
)NKSP_CODE", |
4307 |
|
|
.expectBoolExitResult = false |
4308 |
|
|
}); |
4309 |
|
|
|
4310 |
|
|
runScript({ |
4311 |
|
|
.code = R"NKSP_CODE( |
4312 |
|
|
on init |
4313 |
|
|
exit(3.1 # 3) |
4314 |
|
|
end on |
4315 |
|
|
)NKSP_CODE", |
4316 |
|
|
.expectBoolExitResult = true |
4317 |
|
|
}); |
4318 |
|
|
|
4319 |
|
|
runScript({ |
4320 |
|
|
.code = R"NKSP_CODE( |
4321 |
|
|
on init |
4322 |
|
|
exit(3 # 3.1) |
4323 |
|
|
end on |
4324 |
|
|
)NKSP_CODE", |
4325 |
|
|
.expectBoolExitResult = true |
4326 |
|
|
}); |
4327 |
|
|
|
4328 |
schoenebeck |
3581 |
// std unit tests ... |
4329 |
|
|
|
4330 |
|
|
runScript({ |
4331 |
|
|
.code = R"NKSP_CODE( |
4332 |
|
|
on init |
4333 |
|
|
exit(13ms # 14ms) |
4334 |
|
|
end on |
4335 |
|
|
)NKSP_CODE", |
4336 |
|
|
.expectBoolExitResult = true |
4337 |
|
|
}); |
4338 |
|
|
|
4339 |
|
|
runScript({ |
4340 |
|
|
.code = R"NKSP_CODE( |
4341 |
|
|
on init |
4342 |
|
|
exit(14ms # 13ms) |
4343 |
|
|
end on |
4344 |
|
|
)NKSP_CODE", |
4345 |
|
|
.expectBoolExitResult = true |
4346 |
|
|
}); |
4347 |
|
|
|
4348 |
|
|
runScript({ |
4349 |
|
|
.code = R"NKSP_CODE( |
4350 |
|
|
on init |
4351 |
|
|
exit(1s # 1ms) |
4352 |
|
|
end on |
4353 |
|
|
)NKSP_CODE", |
4354 |
|
|
.expectBoolExitResult = true |
4355 |
|
|
}); |
4356 |
|
|
|
4357 |
|
|
runScript({ |
4358 |
|
|
.code = R"NKSP_CODE( |
4359 |
|
|
on init |
4360 |
|
|
exit(1ms # 1s) |
4361 |
|
|
end on |
4362 |
|
|
)NKSP_CODE", |
4363 |
|
|
.expectBoolExitResult = true |
4364 |
|
|
}); |
4365 |
|
|
|
4366 |
|
|
runScript({ |
4367 |
|
|
.code = R"NKSP_CODE( |
4368 |
|
|
on init |
4369 |
|
|
exit(3.14kHz # 3140Hz) |
4370 |
|
|
end on |
4371 |
|
|
)NKSP_CODE", |
4372 |
|
|
.expectBoolExitResult = false |
4373 |
|
|
}); |
4374 |
|
|
|
4375 |
|
|
runScript({ |
4376 |
|
|
.code = R"NKSP_CODE( |
4377 |
|
|
on init |
4378 |
|
|
exit(3140Hz # 3.14kHz) |
4379 |
|
|
end on |
4380 |
|
|
)NKSP_CODE", |
4381 |
|
|
.expectBoolExitResult = false |
4382 |
|
|
}); |
4383 |
|
|
|
4384 |
|
|
runScript({ |
4385 |
|
|
.code = R"NKSP_CODE( |
4386 |
|
|
on init |
4387 |
|
|
exit(1s # 1) |
4388 |
|
|
end on |
4389 |
|
|
)NKSP_CODE", |
4390 |
|
|
.expectParseError = true // units on both sides must match |
4391 |
|
|
}); |
4392 |
|
|
|
4393 |
|
|
runScript({ |
4394 |
|
|
.code = R"NKSP_CODE( |
4395 |
|
|
on init |
4396 |
|
|
exit(1 # 1s) |
4397 |
|
|
end on |
4398 |
|
|
)NKSP_CODE", |
4399 |
|
|
.expectParseError = true // units on both sides must match |
4400 |
|
|
}); |
4401 |
|
|
|
4402 |
|
|
runScript({ |
4403 |
|
|
.code = R"NKSP_CODE( |
4404 |
|
|
on init |
4405 |
|
|
exit(1Hz # 1B) |
4406 |
|
|
end on |
4407 |
|
|
)NKSP_CODE", |
4408 |
|
|
.expectParseError = true // units on both sides must match |
4409 |
|
|
}); |
4410 |
|
|
|
4411 |
|
|
// 'final' ('!') operator tests ... |
4412 |
|
|
// (should always yield in false for relation operators) |
4413 |
|
|
|
4414 |
|
|
runScript({ |
4415 |
|
|
.code = R"NKSP_CODE( |
4416 |
|
|
on init |
4417 |
|
|
exit(!-4 # !3) |
4418 |
|
|
end on |
4419 |
|
|
)NKSP_CODE", |
4420 |
|
|
.expectBoolExitResult = true, |
4421 |
|
|
.expectExitResultFinal = false |
4422 |
|
|
}); |
4423 |
|
|
|
4424 |
|
|
runScript({ |
4425 |
|
|
.code = R"NKSP_CODE( |
4426 |
|
|
on init |
4427 |
|
|
exit(-4 # 3) |
4428 |
|
|
end on |
4429 |
|
|
)NKSP_CODE", |
4430 |
|
|
.expectBoolExitResult = true, |
4431 |
|
|
.expectExitResultFinal = false |
4432 |
|
|
}); |
4433 |
|
|
|
4434 |
schoenebeck |
3551 |
#if !SILENT_TEST |
4435 |
|
|
std::cout << std::endl; |
4436 |
|
|
#endif |
4437 |
|
|
} |
4438 |
|
|
|
4439 |
|
|
static void testLogicalAndOperator() { |
4440 |
|
|
#if !SILENT_TEST |
4441 |
|
|
std::cout << "UNIT TEST: logical and (and) operator\n"; |
4442 |
|
|
#endif |
4443 |
|
|
|
4444 |
schoenebeck |
3575 |
// integer tests ... |
4445 |
|
|
|
4446 |
schoenebeck |
3551 |
runScript({ |
4447 |
|
|
.code = R"NKSP_CODE( |
4448 |
|
|
on init |
4449 |
|
|
exit(1 and 1) |
4450 |
|
|
end on |
4451 |
|
|
)NKSP_CODE", |
4452 |
|
|
.expectBoolExitResult = true |
4453 |
|
|
}); |
4454 |
|
|
|
4455 |
|
|
runScript({ |
4456 |
|
|
.code = R"NKSP_CODE( |
4457 |
|
|
on init |
4458 |
|
|
exit(1 and 2) |
4459 |
|
|
end on |
4460 |
|
|
)NKSP_CODE", |
4461 |
|
|
.expectBoolExitResult = true |
4462 |
|
|
}); |
4463 |
|
|
|
4464 |
|
|
runScript({ |
4465 |
|
|
.code = R"NKSP_CODE( |
4466 |
|
|
on init |
4467 |
|
|
exit(1 and 3) |
4468 |
|
|
end on |
4469 |
|
|
)NKSP_CODE", |
4470 |
|
|
.expectBoolExitResult = true |
4471 |
|
|
}); |
4472 |
|
|
|
4473 |
|
|
runScript({ |
4474 |
|
|
.code = R"NKSP_CODE( |
4475 |
|
|
on init |
4476 |
|
|
exit(1 and 0) |
4477 |
|
|
end on |
4478 |
|
|
)NKSP_CODE", |
4479 |
|
|
.expectBoolExitResult = false |
4480 |
|
|
}); |
4481 |
|
|
|
4482 |
|
|
runScript({ |
4483 |
|
|
.code = R"NKSP_CODE( |
4484 |
|
|
on init |
4485 |
|
|
exit(0 and 1) |
4486 |
|
|
end on |
4487 |
|
|
)NKSP_CODE", |
4488 |
|
|
.expectBoolExitResult = false |
4489 |
|
|
}); |
4490 |
|
|
|
4491 |
|
|
runScript({ |
4492 |
|
|
.code = R"NKSP_CODE( |
4493 |
|
|
on init |
4494 |
|
|
exit(0 and 0) |
4495 |
|
|
end on |
4496 |
|
|
)NKSP_CODE", |
4497 |
|
|
.expectBoolExitResult = false |
4498 |
|
|
}); |
4499 |
|
|
|
4500 |
schoenebeck |
3575 |
// real number tests ... |
4501 |
|
|
// (not allowed for this operator) |
4502 |
|
|
|
4503 |
|
|
runScript({ |
4504 |
|
|
.code = R"NKSP_CODE( |
4505 |
|
|
on init |
4506 |
|
|
exit(1.0 and 1.0) |
4507 |
|
|
end on |
4508 |
|
|
)NKSP_CODE", |
4509 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4510 |
|
|
}); |
4511 |
|
|
|
4512 |
|
|
// mixed type tests ... |
4513 |
|
|
// (not allowed for this operator) |
4514 |
|
|
|
4515 |
|
|
runScript({ |
4516 |
|
|
.code = R"NKSP_CODE( |
4517 |
|
|
on init |
4518 |
|
|
exit(1.0 and 1) |
4519 |
|
|
end on |
4520 |
|
|
)NKSP_CODE", |
4521 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4522 |
|
|
}); |
4523 |
|
|
|
4524 |
|
|
runScript({ |
4525 |
|
|
.code = R"NKSP_CODE( |
4526 |
|
|
on init |
4527 |
|
|
exit(1 and 1.0) |
4528 |
|
|
end on |
4529 |
|
|
)NKSP_CODE", |
4530 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4531 |
|
|
}); |
4532 |
|
|
|
4533 |
schoenebeck |
3581 |
// std unit tests ... |
4534 |
|
|
// (not allowed for this operator) |
4535 |
|
|
|
4536 |
|
|
runScript({ |
4537 |
|
|
.code = R"NKSP_CODE( |
4538 |
|
|
on init |
4539 |
|
|
exit(1s and 0) |
4540 |
|
|
end on |
4541 |
|
|
)NKSP_CODE", |
4542 |
|
|
.expectParseError = true // std units not allowed for this operator |
4543 |
|
|
}); |
4544 |
|
|
|
4545 |
|
|
runScript({ |
4546 |
|
|
.code = R"NKSP_CODE( |
4547 |
|
|
on init |
4548 |
|
|
exit(0 and 1s) |
4549 |
|
|
end on |
4550 |
|
|
)NKSP_CODE", |
4551 |
|
|
.expectParseError = true // std units not allowed for this operator |
4552 |
|
|
}); |
4553 |
|
|
|
4554 |
|
|
// 'final' ('!') operator tests ... |
4555 |
|
|
|
4556 |
|
|
runScript({ |
4557 |
|
|
.code = R"NKSP_CODE( |
4558 |
|
|
on init |
4559 |
|
|
exit(!0 and !0) |
4560 |
|
|
end on |
4561 |
|
|
)NKSP_CODE", |
4562 |
|
|
.expectExitResultFinal = true |
4563 |
|
|
}); |
4564 |
|
|
|
4565 |
|
|
runScript({ |
4566 |
|
|
.code = R"NKSP_CODE( |
4567 |
|
|
on init |
4568 |
|
|
exit(0 and 0) |
4569 |
|
|
end on |
4570 |
|
|
)NKSP_CODE", |
4571 |
|
|
.expectExitResultFinal = false |
4572 |
|
|
}); |
4573 |
|
|
|
4574 |
schoenebeck |
3551 |
#if !SILENT_TEST |
4575 |
|
|
std::cout << std::endl; |
4576 |
|
|
#endif |
4577 |
|
|
} |
4578 |
|
|
|
4579 |
|
|
static void testLogicalOrOperator() { |
4580 |
|
|
#if !SILENT_TEST |
4581 |
|
|
std::cout << "UNIT TEST: logical or (or) operator\n"; |
4582 |
|
|
#endif |
4583 |
|
|
|
4584 |
schoenebeck |
3575 |
// integer tests ... |
4585 |
|
|
|
4586 |
schoenebeck |
3551 |
runScript({ |
4587 |
|
|
.code = R"NKSP_CODE( |
4588 |
|
|
on init |
4589 |
|
|
exit(1 or 1) |
4590 |
|
|
end on |
4591 |
|
|
)NKSP_CODE", |
4592 |
|
|
.expectBoolExitResult = true |
4593 |
|
|
}); |
4594 |
|
|
|
4595 |
|
|
runScript({ |
4596 |
|
|
.code = R"NKSP_CODE( |
4597 |
|
|
on init |
4598 |
|
|
exit(1 or 2) |
4599 |
|
|
end on |
4600 |
|
|
)NKSP_CODE", |
4601 |
|
|
.expectBoolExitResult = true |
4602 |
|
|
}); |
4603 |
|
|
|
4604 |
|
|
runScript({ |
4605 |
|
|
.code = R"NKSP_CODE( |
4606 |
|
|
on init |
4607 |
|
|
exit(1 or 3) |
4608 |
|
|
end on |
4609 |
|
|
)NKSP_CODE", |
4610 |
|
|
.expectBoolExitResult = true |
4611 |
|
|
}); |
4612 |
|
|
|
4613 |
|
|
runScript({ |
4614 |
|
|
.code = R"NKSP_CODE( |
4615 |
|
|
on init |
4616 |
|
|
exit(1 or 0) |
4617 |
|
|
end on |
4618 |
|
|
)NKSP_CODE", |
4619 |
|
|
.expectBoolExitResult = true |
4620 |
|
|
}); |
4621 |
|
|
|
4622 |
|
|
runScript({ |
4623 |
|
|
.code = R"NKSP_CODE( |
4624 |
|
|
on init |
4625 |
|
|
exit(0 or 1) |
4626 |
|
|
end on |
4627 |
|
|
)NKSP_CODE", |
4628 |
|
|
.expectBoolExitResult = true |
4629 |
|
|
}); |
4630 |
|
|
|
4631 |
|
|
runScript({ |
4632 |
|
|
.code = R"NKSP_CODE( |
4633 |
|
|
on init |
4634 |
|
|
exit(0 or 0) |
4635 |
|
|
end on |
4636 |
|
|
)NKSP_CODE", |
4637 |
|
|
.expectBoolExitResult = false |
4638 |
|
|
}); |
4639 |
|
|
|
4640 |
schoenebeck |
3575 |
// real number tests ... |
4641 |
|
|
// (not allowed for this operator) |
4642 |
|
|
|
4643 |
|
|
runScript({ |
4644 |
|
|
.code = R"NKSP_CODE( |
4645 |
|
|
on init |
4646 |
|
|
exit(1.0 or 1.0) |
4647 |
|
|
end on |
4648 |
|
|
)NKSP_CODE", |
4649 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4650 |
|
|
}); |
4651 |
|
|
|
4652 |
|
|
// mixed type tests ... |
4653 |
|
|
// (not allowed for this operator) |
4654 |
|
|
|
4655 |
|
|
runScript({ |
4656 |
|
|
.code = R"NKSP_CODE( |
4657 |
|
|
on init |
4658 |
|
|
exit(1.0 or 1) |
4659 |
|
|
end on |
4660 |
|
|
)NKSP_CODE", |
4661 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4662 |
|
|
}); |
4663 |
|
|
|
4664 |
|
|
runScript({ |
4665 |
|
|
.code = R"NKSP_CODE( |
4666 |
|
|
on init |
4667 |
|
|
exit(1 or 1.0) |
4668 |
|
|
end on |
4669 |
|
|
)NKSP_CODE", |
4670 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4671 |
|
|
}); |
4672 |
|
|
|
4673 |
schoenebeck |
3581 |
// std unit tests ... |
4674 |
|
|
// (not allowed for this operator) |
4675 |
|
|
|
4676 |
|
|
runScript({ |
4677 |
|
|
.code = R"NKSP_CODE( |
4678 |
|
|
on init |
4679 |
|
|
exit(1s or 0) |
4680 |
|
|
end on |
4681 |
|
|
)NKSP_CODE", |
4682 |
|
|
.expectParseError = true // std units not allowed for this operator |
4683 |
|
|
}); |
4684 |
|
|
|
4685 |
|
|
runScript({ |
4686 |
|
|
.code = R"NKSP_CODE( |
4687 |
|
|
on init |
4688 |
|
|
exit(0 or 1s) |
4689 |
|
|
end on |
4690 |
|
|
)NKSP_CODE", |
4691 |
|
|
.expectParseError = true // std units not allowed for this operator |
4692 |
|
|
}); |
4693 |
|
|
|
4694 |
|
|
// 'final' ('!') operator tests ... |
4695 |
|
|
|
4696 |
|
|
runScript({ |
4697 |
|
|
.code = R"NKSP_CODE( |
4698 |
|
|
on init |
4699 |
|
|
exit(!0 or !0) |
4700 |
|
|
end on |
4701 |
|
|
)NKSP_CODE", |
4702 |
|
|
.expectExitResultFinal = true |
4703 |
|
|
}); |
4704 |
|
|
|
4705 |
|
|
runScript({ |
4706 |
|
|
.code = R"NKSP_CODE( |
4707 |
|
|
on init |
4708 |
|
|
exit(0 or 0) |
4709 |
|
|
end on |
4710 |
|
|
)NKSP_CODE", |
4711 |
|
|
.expectExitResultFinal = false |
4712 |
|
|
}); |
4713 |
|
|
|
4714 |
schoenebeck |
3551 |
#if !SILENT_TEST |
4715 |
|
|
std::cout << std::endl; |
4716 |
|
|
#endif |
4717 |
|
|
} |
4718 |
|
|
|
4719 |
|
|
static void testLogicalNotOperator() { |
4720 |
|
|
#if !SILENT_TEST |
4721 |
|
|
std::cout << "UNIT TEST: logical not (not) operator\n"; |
4722 |
|
|
#endif |
4723 |
|
|
|
4724 |
schoenebeck |
3575 |
// integer tests ... |
4725 |
|
|
|
4726 |
schoenebeck |
3551 |
runScript({ |
4727 |
|
|
.code = R"NKSP_CODE( |
4728 |
|
|
on init |
4729 |
|
|
exit(not 1) |
4730 |
|
|
end on |
4731 |
|
|
)NKSP_CODE", |
4732 |
|
|
.expectBoolExitResult = false |
4733 |
|
|
}); |
4734 |
|
|
|
4735 |
|
|
runScript({ |
4736 |
|
|
.code = R"NKSP_CODE( |
4737 |
|
|
on init |
4738 |
|
|
exit(not 2) |
4739 |
|
|
end on |
4740 |
|
|
)NKSP_CODE", |
4741 |
|
|
.expectBoolExitResult = false |
4742 |
|
|
}); |
4743 |
|
|
|
4744 |
|
|
runScript({ |
4745 |
|
|
.code = R"NKSP_CODE( |
4746 |
|
|
on init |
4747 |
|
|
exit(not 0) |
4748 |
|
|
end on |
4749 |
|
|
)NKSP_CODE", |
4750 |
|
|
.expectBoolExitResult = true |
4751 |
|
|
}); |
4752 |
|
|
|
4753 |
schoenebeck |
3575 |
// real number tests ... |
4754 |
|
|
// (not allowed for this operator) |
4755 |
|
|
|
4756 |
|
|
runScript({ |
4757 |
|
|
.code = R"NKSP_CODE( |
4758 |
|
|
on init |
4759 |
|
|
exit(not 1.0) |
4760 |
|
|
end on |
4761 |
|
|
)NKSP_CODE", |
4762 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4763 |
|
|
}); |
4764 |
|
|
|
4765 |
schoenebeck |
3581 |
// std unit tests ... |
4766 |
|
|
// (not allowed for this operator) |
4767 |
|
|
|
4768 |
|
|
runScript({ |
4769 |
|
|
.code = R"NKSP_CODE( |
4770 |
|
|
on init |
4771 |
|
|
exit(not 1s) |
4772 |
|
|
end on |
4773 |
|
|
)NKSP_CODE", |
4774 |
|
|
.expectParseError = true // std units not allowed for this operator |
4775 |
|
|
}); |
4776 |
|
|
|
4777 |
|
|
// 'final' ('!') operator tests ... |
4778 |
|
|
|
4779 |
|
|
runScript({ |
4780 |
|
|
.code = R"NKSP_CODE( |
4781 |
|
|
on init |
4782 |
|
|
exit(not !1) |
4783 |
|
|
end on |
4784 |
|
|
)NKSP_CODE", |
4785 |
|
|
.expectExitResultFinal = true |
4786 |
|
|
}); |
4787 |
|
|
|
4788 |
|
|
runScript({ |
4789 |
|
|
.code = R"NKSP_CODE( |
4790 |
|
|
on init |
4791 |
|
|
exit(not 1) |
4792 |
|
|
end on |
4793 |
|
|
)NKSP_CODE", |
4794 |
|
|
.expectExitResultFinal = false |
4795 |
|
|
}); |
4796 |
|
|
|
4797 |
schoenebeck |
3551 |
#if !SILENT_TEST |
4798 |
|
|
std::cout << std::endl; |
4799 |
|
|
#endif |
4800 |
|
|
} |
4801 |
|
|
|
4802 |
|
|
static void testBitwiseAndOperator() { |
4803 |
|
|
#if !SILENT_TEST |
4804 |
|
|
std::cout << "UNIT TEST: bitwise and (.and.) operator\n"; |
4805 |
|
|
#endif |
4806 |
|
|
|
4807 |
schoenebeck |
3575 |
// integer tests ... |
4808 |
|
|
|
4809 |
schoenebeck |
3551 |
runScript({ |
4810 |
|
|
.code = R"NKSP_CODE( |
4811 |
|
|
on init |
4812 |
|
|
exit(1 .and. 1) |
4813 |
|
|
end on |
4814 |
|
|
)NKSP_CODE", |
4815 |
|
|
.expectIntExitResult = 1 |
4816 |
|
|
}); |
4817 |
|
|
|
4818 |
|
|
runScript({ |
4819 |
|
|
.code = R"NKSP_CODE( |
4820 |
|
|
on init |
4821 |
|
|
exit(43 .and. 142) |
4822 |
|
|
end on |
4823 |
|
|
)NKSP_CODE", |
4824 |
|
|
.expectIntExitResult = 10 |
4825 |
|
|
}); |
4826 |
|
|
|
4827 |
schoenebeck |
3575 |
// real number tests ... |
4828 |
|
|
// (not allowed for this operator) |
4829 |
|
|
|
4830 |
|
|
runScript({ |
4831 |
|
|
.code = R"NKSP_CODE( |
4832 |
|
|
on init |
4833 |
|
|
exit(1.0 .and. 1.0) |
4834 |
|
|
end on |
4835 |
|
|
)NKSP_CODE", |
4836 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4837 |
|
|
}); |
4838 |
|
|
|
4839 |
|
|
// mixed type tests ... |
4840 |
|
|
// (not allowed for this operator) |
4841 |
|
|
|
4842 |
|
|
runScript({ |
4843 |
|
|
.code = R"NKSP_CODE( |
4844 |
|
|
on init |
4845 |
|
|
exit(1.0 .and. 1) |
4846 |
|
|
end on |
4847 |
|
|
)NKSP_CODE", |
4848 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4849 |
|
|
}); |
4850 |
|
|
|
4851 |
|
|
runScript({ |
4852 |
|
|
.code = R"NKSP_CODE( |
4853 |
|
|
on init |
4854 |
|
|
exit(1 .and. 1.0) |
4855 |
|
|
end on |
4856 |
|
|
)NKSP_CODE", |
4857 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4858 |
|
|
}); |
4859 |
|
|
|
4860 |
schoenebeck |
3581 |
// std unit tests ... |
4861 |
|
|
// (not allowed for this operator) |
4862 |
|
|
|
4863 |
|
|
runScript({ |
4864 |
|
|
.code = R"NKSP_CODE( |
4865 |
|
|
on init |
4866 |
|
|
exit(1s .and. 1) |
4867 |
|
|
end on |
4868 |
|
|
)NKSP_CODE", |
4869 |
|
|
.expectParseError = true // std units not allowed for this operator |
4870 |
|
|
}); |
4871 |
|
|
|
4872 |
|
|
runScript({ |
4873 |
|
|
.code = R"NKSP_CODE( |
4874 |
|
|
on init |
4875 |
|
|
exit(1 .and. 1s) |
4876 |
|
|
end on |
4877 |
|
|
)NKSP_CODE", |
4878 |
|
|
.expectParseError = true // std units not allowed for this operator |
4879 |
|
|
}); |
4880 |
|
|
|
4881 |
|
|
// 'final' ('!') operator tests ... |
4882 |
|
|
|
4883 |
|
|
runScript({ |
4884 |
|
|
.code = R"NKSP_CODE( |
4885 |
|
|
on init |
4886 |
|
|
exit(!43 .and. !142) |
4887 |
|
|
end on |
4888 |
|
|
)NKSP_CODE", |
4889 |
|
|
.expectIntExitResult = 10, |
4890 |
|
|
.expectExitResultFinal = true |
4891 |
|
|
}); |
4892 |
|
|
|
4893 |
|
|
runScript({ |
4894 |
|
|
.code = R"NKSP_CODE( |
4895 |
|
|
on init |
4896 |
|
|
exit(43 .and. 142) |
4897 |
|
|
end on |
4898 |
|
|
)NKSP_CODE", |
4899 |
|
|
.expectIntExitResult = 10, |
4900 |
|
|
.expectExitResultFinal = false |
4901 |
|
|
}); |
4902 |
|
|
|
4903 |
schoenebeck |
3551 |
#if !SILENT_TEST |
4904 |
|
|
std::cout << std::endl; |
4905 |
|
|
#endif |
4906 |
|
|
} |
4907 |
|
|
|
4908 |
|
|
static void testBitwiseOrOperator() { |
4909 |
|
|
#if !SILENT_TEST |
4910 |
|
|
std::cout << "UNIT TEST: bitwise or (.or.) operator\n"; |
4911 |
|
|
#endif |
4912 |
|
|
|
4913 |
schoenebeck |
3575 |
// integer tests ... |
4914 |
|
|
|
4915 |
schoenebeck |
3551 |
runScript({ |
4916 |
|
|
.code = R"NKSP_CODE( |
4917 |
|
|
on init |
4918 |
|
|
exit(1 .or. 1) |
4919 |
|
|
end on |
4920 |
|
|
)NKSP_CODE", |
4921 |
|
|
.expectIntExitResult = 1 |
4922 |
|
|
}); |
4923 |
|
|
|
4924 |
|
|
runScript({ |
4925 |
|
|
.code = R"NKSP_CODE( |
4926 |
|
|
on init |
4927 |
|
|
exit(0 .or. 0) |
4928 |
|
|
end on |
4929 |
|
|
)NKSP_CODE", |
4930 |
|
|
.expectIntExitResult = 0 |
4931 |
|
|
}); |
4932 |
|
|
|
4933 |
|
|
runScript({ |
4934 |
|
|
.code = R"NKSP_CODE( |
4935 |
|
|
on init |
4936 |
|
|
exit(43 .or. 142) |
4937 |
|
|
end on |
4938 |
|
|
)NKSP_CODE", |
4939 |
|
|
.expectIntExitResult = 175 |
4940 |
|
|
}); |
4941 |
|
|
|
4942 |
schoenebeck |
3575 |
// real number tests ... |
4943 |
|
|
// (not allowed for this operator) |
4944 |
|
|
|
4945 |
|
|
runScript({ |
4946 |
|
|
.code = R"NKSP_CODE( |
4947 |
|
|
on init |
4948 |
|
|
exit(1.0 .or. 1.0) |
4949 |
|
|
end on |
4950 |
|
|
)NKSP_CODE", |
4951 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4952 |
|
|
}); |
4953 |
|
|
|
4954 |
|
|
// mixed type tests ... |
4955 |
|
|
// (not allowed for this operator) |
4956 |
|
|
|
4957 |
|
|
runScript({ |
4958 |
|
|
.code = R"NKSP_CODE( |
4959 |
|
|
on init |
4960 |
|
|
exit(1.0 .or. 1) |
4961 |
|
|
end on |
4962 |
|
|
)NKSP_CODE", |
4963 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4964 |
|
|
}); |
4965 |
|
|
|
4966 |
|
|
runScript({ |
4967 |
|
|
.code = R"NKSP_CODE( |
4968 |
|
|
on init |
4969 |
|
|
exit(1 .or. 1.0) |
4970 |
|
|
end on |
4971 |
|
|
)NKSP_CODE", |
4972 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
4973 |
|
|
}); |
4974 |
|
|
|
4975 |
schoenebeck |
3581 |
// std unit tests ... |
4976 |
|
|
// (not allowed for this operator) |
4977 |
|
|
|
4978 |
|
|
runScript({ |
4979 |
|
|
.code = R"NKSP_CODE( |
4980 |
|
|
on init |
4981 |
|
|
exit(1s .or. 1) |
4982 |
|
|
end on |
4983 |
|
|
)NKSP_CODE", |
4984 |
|
|
.expectParseError = true // std units not allowed for this operator |
4985 |
|
|
}); |
4986 |
|
|
|
4987 |
|
|
runScript({ |
4988 |
|
|
.code = R"NKSP_CODE( |
4989 |
|
|
on init |
4990 |
|
|
exit(1 .or. 1s) |
4991 |
|
|
end on |
4992 |
|
|
)NKSP_CODE", |
4993 |
|
|
.expectParseError = true // std units not allowed for this operator |
4994 |
|
|
}); |
4995 |
|
|
|
4996 |
|
|
// 'final' ('!') operator tests ... |
4997 |
|
|
|
4998 |
|
|
runScript({ |
4999 |
|
|
.code = R"NKSP_CODE( |
5000 |
|
|
on init |
5001 |
|
|
exit(!43 .or. !142) |
5002 |
|
|
end on |
5003 |
|
|
)NKSP_CODE", |
5004 |
|
|
.expectIntExitResult = 175, |
5005 |
|
|
.expectExitResultFinal = true |
5006 |
|
|
}); |
5007 |
|
|
|
5008 |
|
|
runScript({ |
5009 |
|
|
.code = R"NKSP_CODE( |
5010 |
|
|
on init |
5011 |
|
|
exit(43 .or. 142) |
5012 |
|
|
end on |
5013 |
|
|
)NKSP_CODE", |
5014 |
|
|
.expectIntExitResult = 175, |
5015 |
|
|
.expectExitResultFinal = false |
5016 |
|
|
}); |
5017 |
|
|
|
5018 |
schoenebeck |
3551 |
#if !SILENT_TEST |
5019 |
|
|
std::cout << std::endl; |
5020 |
|
|
#endif |
5021 |
|
|
} |
5022 |
|
|
|
5023 |
|
|
static void testBitwiseNotOperator() { |
5024 |
|
|
#if !SILENT_TEST |
5025 |
|
|
std::cout << "UNIT TEST: bitwise not (.not.) operator\n"; |
5026 |
|
|
#endif |
5027 |
|
|
|
5028 |
schoenebeck |
3575 |
// integer tests ... |
5029 |
|
|
|
5030 |
schoenebeck |
3551 |
runScript({ |
5031 |
|
|
.code = R"NKSP_CODE( |
5032 |
|
|
on init |
5033 |
|
|
exit(.not. -1) |
5034 |
|
|
end on |
5035 |
|
|
)NKSP_CODE", |
5036 |
|
|
.expectIntExitResult = 0 |
5037 |
|
|
}); |
5038 |
|
|
|
5039 |
|
|
runScript({ |
5040 |
|
|
.code = R"NKSP_CODE( |
5041 |
|
|
on init |
5042 |
|
|
exit(.not. 0) |
5043 |
|
|
end on |
5044 |
|
|
)NKSP_CODE", |
5045 |
|
|
.expectIntExitResult = -1 |
5046 |
|
|
}); |
5047 |
|
|
|
5048 |
|
|
runScript({ |
5049 |
|
|
.code = R"NKSP_CODE( |
5050 |
|
|
on init |
5051 |
|
|
exit(.not. 3) |
5052 |
|
|
end on |
5053 |
|
|
)NKSP_CODE", |
5054 |
|
|
.expectIntExitResult = ssize_t(size_t(-1) << 2) |
5055 |
|
|
}); |
5056 |
|
|
|
5057 |
schoenebeck |
3575 |
// real number tests ... |
5058 |
|
|
// (not allowed for this operator) |
5059 |
|
|
|
5060 |
|
|
runScript({ |
5061 |
|
|
.code = R"NKSP_CODE( |
5062 |
|
|
on init |
5063 |
|
|
exit(.not. 1.0) |
5064 |
|
|
end on |
5065 |
|
|
)NKSP_CODE", |
5066 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
5067 |
|
|
}); |
5068 |
|
|
|
5069 |
|
|
runScript({ |
5070 |
|
|
.code = R"NKSP_CODE( |
5071 |
|
|
on init |
5072 |
|
|
exit(.not. -1.0) |
5073 |
|
|
end on |
5074 |
|
|
)NKSP_CODE", |
5075 |
|
|
.expectParseError = true // real numbers not allowed for this operator |
5076 |
|
|
}); |
5077 |
|
|
|
5078 |
schoenebeck |
3581 |
// std unit tests ... |
5079 |
|
|
// (not allowed for this operator) |
5080 |
|
|
|
5081 |
|
|
runScript({ |
5082 |
|
|
.code = R"NKSP_CODE( |
5083 |
|
|
on init |
5084 |
|
|
exit(.not. 1s) |
5085 |
|
|
end on |
5086 |
|
|
)NKSP_CODE", |
5087 |
|
|
.expectParseError = true // std units not allowed for this operator |
5088 |
|
|
}); |
5089 |
|
|
|
5090 |
|
|
// 'final' ('!') operator tests ... |
5091 |
|
|
|
5092 |
|
|
runScript({ |
5093 |
|
|
.code = R"NKSP_CODE( |
5094 |
|
|
on init |
5095 |
|
|
exit(.not. !0) |
5096 |
|
|
end on |
5097 |
|
|
)NKSP_CODE", |
5098 |
|
|
.expectIntExitResult = -1, |
5099 |
|
|
.expectExitResultFinal = true |
5100 |
|
|
}); |
5101 |
|
|
|
5102 |
|
|
runScript({ |
5103 |
|
|
.code = R"NKSP_CODE( |
5104 |
|
|
on init |
5105 |
|
|
exit(.not. 0) |
5106 |
|
|
end on |
5107 |
|
|
)NKSP_CODE", |
5108 |
|
|
.expectIntExitResult = -1, |
5109 |
|
|
.expectExitResultFinal = false |
5110 |
|
|
}); |
5111 |
|
|
|
5112 |
schoenebeck |
3551 |
#if !SILENT_TEST |
5113 |
|
|
std::cout << std::endl; |
5114 |
|
|
#endif |
5115 |
|
|
} |
5116 |
|
|
|
5117 |
|
|
static void testPrecedenceOfOperators() { |
5118 |
|
|
#if !SILENT_TEST |
5119 |
|
|
std::cout << "UNIT TEST: precedence of operators\n"; |
5120 |
|
|
#endif |
5121 |
|
|
|
5122 |
schoenebeck |
3575 |
// integer tests ... |
5123 |
|
|
|
5124 |
schoenebeck |
3551 |
runScript({ |
5125 |
|
|
.code = R"NKSP_CODE( |
5126 |
|
|
on init |
5127 |
|
|
exit(3 + 4 * 2) |
5128 |
|
|
end on |
5129 |
|
|
)NKSP_CODE", |
5130 |
|
|
.expectIntExitResult = 11 |
5131 |
|
|
}); |
5132 |
|
|
|
5133 |
|
|
runScript({ |
5134 |
|
|
.code = R"NKSP_CODE( |
5135 |
|
|
on init |
5136 |
|
|
exit(4 * 2 + 3) |
5137 |
|
|
end on |
5138 |
|
|
)NKSP_CODE", |
5139 |
|
|
.expectIntExitResult = 11 |
5140 |
|
|
}); |
5141 |
|
|
|
5142 |
|
|
runScript({ |
5143 |
|
|
.code = R"NKSP_CODE( |
5144 |
|
|
on init |
5145 |
|
|
exit((3 + 4) * 2) |
5146 |
|
|
end on |
5147 |
|
|
)NKSP_CODE", |
5148 |
|
|
.expectIntExitResult = 14 |
5149 |
|
|
}); |
5150 |
|
|
|
5151 |
|
|
runScript({ |
5152 |
|
|
.code = R"NKSP_CODE( |
5153 |
|
|
on init |
5154 |
|
|
exit(4 * (2 + 3)) |
5155 |
|
|
end on |
5156 |
|
|
)NKSP_CODE", |
5157 |
|
|
.expectIntExitResult = 20 |
5158 |
|
|
}); |
5159 |
|
|
|
5160 |
schoenebeck |
3575 |
// real number tests ... |
5161 |
|
|
|
5162 |
|
|
runScript({ |
5163 |
|
|
.code = R"NKSP_CODE( |
5164 |
|
|
on init |
5165 |
|
|
exit(3.2 + 4.0 * 2.0) |
5166 |
|
|
end on |
5167 |
|
|
)NKSP_CODE", |
5168 |
|
|
.expectRealExitResult = 11.2 |
5169 |
|
|
}); |
5170 |
|
|
|
5171 |
|
|
runScript({ |
5172 |
|
|
.code = R"NKSP_CODE( |
5173 |
|
|
on init |
5174 |
|
|
exit(4.0 * 2.0 + 3.2) |
5175 |
|
|
end on |
5176 |
|
|
)NKSP_CODE", |
5177 |
|
|
.expectRealExitResult = 11.2 |
5178 |
|
|
}); |
5179 |
|
|
|
5180 |
|
|
runScript({ |
5181 |
|
|
.code = R"NKSP_CODE( |
5182 |
|
|
on init |
5183 |
|
|
exit((3.2 + 4.0) * 2.0) |
5184 |
|
|
end on |
5185 |
|
|
)NKSP_CODE", |
5186 |
|
|
.expectRealExitResult = 14.4 |
5187 |
|
|
}); |
5188 |
|
|
|
5189 |
|
|
runScript({ |
5190 |
|
|
.code = R"NKSP_CODE( |
5191 |
|
|
on init |
5192 |
|
|
exit(4.0 * (2.0 + 3.2)) |
5193 |
|
|
end on |
5194 |
|
|
)NKSP_CODE", |
5195 |
|
|
.expectRealExitResult = 20.8 |
5196 |
|
|
}); |
5197 |
|
|
|
5198 |
schoenebeck |
3581 |
// std unit tests ... |
5199 |
|
|
|
5200 |
|
|
runScript({ |
5201 |
|
|
.code = R"NKSP_CODE( |
5202 |
|
|
on init |
5203 |
|
|
exit(4 * (2us + 3us) + 7ms) |
5204 |
|
|
end on |
5205 |
|
|
)NKSP_CODE", |
5206 |
|
|
.expectIntExitResult = 7020, |
5207 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
5208 |
|
|
.expectExitResultUnit = VM_SECOND |
5209 |
|
|
}); |
5210 |
|
|
|
5211 |
|
|
runScript({ |
5212 |
|
|
.code = R"NKSP_CODE( |
5213 |
|
|
on init |
5214 |
|
|
declare $a := 4 |
5215 |
|
|
declare $c := 3us |
5216 |
|
|
exit($a * (2us + $c) + 7ms) |
5217 |
|
|
end on |
5218 |
|
|
)NKSP_CODE", |
5219 |
|
|
.expectIntExitResult = 7020, |
5220 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
5221 |
|
|
.expectExitResultUnit = VM_SECOND |
5222 |
|
|
}); |
5223 |
|
|
|
5224 |
|
|
runScript({ |
5225 |
|
|
.code = R"NKSP_CODE( |
5226 |
|
|
on init |
5227 |
|
|
declare $a := 4 |
5228 |
|
|
declare $b := 2us |
5229 |
|
|
declare $c := 3us |
5230 |
|
|
exit($a * ($b + $c) + 7ms) |
5231 |
|
|
end on |
5232 |
|
|
)NKSP_CODE", |
5233 |
|
|
.expectIntExitResult = 7020, |
5234 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
5235 |
|
|
.expectExitResultUnit = VM_SECOND |
5236 |
|
|
}); |
5237 |
|
|
|
5238 |
|
|
runScript({ |
5239 |
|
|
.code = R"NKSP_CODE( |
5240 |
|
|
on init |
5241 |
|
|
declare $a := 4 |
5242 |
|
|
declare $b := 2us |
5243 |
|
|
declare $c := 3us |
5244 |
|
|
declare $d := 7ms |
5245 |
|
|
exit($a * ($b + $c) + 7ms) |
5246 |
|
|
end on |
5247 |
|
|
)NKSP_CODE", |
5248 |
|
|
.expectIntExitResult = 7020, |
5249 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
5250 |
|
|
.expectExitResultUnit = VM_SECOND |
5251 |
|
|
}); |
5252 |
|
|
|
5253 |
|
|
runScript({ |
5254 |
|
|
.code = R"NKSP_CODE( |
5255 |
|
|
on init |
5256 |
|
|
declare $c := 3us |
5257 |
|
|
declare $a := 4 |
5258 |
|
|
declare $d := 7ms |
5259 |
|
|
declare $b := 2us |
5260 |
|
|
exit($a * ($b + $c) + 7ms) |
5261 |
|
|
end on |
5262 |
|
|
)NKSP_CODE", |
5263 |
|
|
.expectIntExitResult = 7020, |
5264 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
5265 |
|
|
.expectExitResultUnit = VM_SECOND |
5266 |
|
|
}); |
5267 |
|
|
|
5268 |
|
|
runScript({ |
5269 |
|
|
.code = R"NKSP_CODE( |
5270 |
|
|
on init |
5271 |
|
|
exit(4.0 * (2.0mdB + 3.2mdB) / 2.0) |
5272 |
|
|
end on |
5273 |
|
|
)NKSP_CODE", |
5274 |
|
|
.expectRealExitResult = 10.4, |
5275 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
5276 |
|
|
.expectExitResultUnit = VM_BEL |
5277 |
|
|
}); |
5278 |
|
|
|
5279 |
|
|
runScript({ |
5280 |
|
|
.code = R"NKSP_CODE( |
5281 |
|
|
on init |
5282 |
|
|
declare ~a := 2.0mdB |
5283 |
|
|
declare ~b := 3.2mdB |
5284 |
|
|
exit(4.0 * (~a + ~b) / 2.0) |
5285 |
|
|
end on |
5286 |
|
|
)NKSP_CODE", |
5287 |
|
|
.expectRealExitResult = 10.4, |
5288 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
5289 |
|
|
.expectExitResultUnit = VM_BEL |
5290 |
|
|
}); |
5291 |
|
|
|
5292 |
|
|
runScript({ |
5293 |
|
|
.code = R"NKSP_CODE( |
5294 |
|
|
on init |
5295 |
|
|
declare ~b := 3.2mdB |
5296 |
|
|
declare ~a := 2.0mdB |
5297 |
|
|
exit(4.0 * (~a + ~b) / 2.0) |
5298 |
|
|
end on |
5299 |
|
|
)NKSP_CODE", |
5300 |
|
|
.expectRealExitResult = 10.4, |
5301 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
5302 |
|
|
.expectExitResultUnit = VM_BEL |
5303 |
|
|
}); |
5304 |
|
|
|
5305 |
|
|
runScript({ |
5306 |
|
|
.code = R"NKSP_CODE( |
5307 |
|
|
on init |
5308 |
|
|
declare ~a := 4.0 |
5309 |
|
|
declare ~b := 2.0mdB |
5310 |
|
|
declare ~c := 3.2mdB |
5311 |
|
|
declare ~d := 2.0 |
5312 |
|
|
exit((~a * (~b + ~c) / ~d) + 1.1mdB) |
5313 |
|
|
end on |
5314 |
|
|
)NKSP_CODE", |
5315 |
|
|
.expectRealExitResult = 11.5, |
5316 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
5317 |
|
|
.expectExitResultUnit = VM_BEL |
5318 |
|
|
}); |
5319 |
|
|
|
5320 |
|
|
runScript({ |
5321 |
|
|
.code = R"NKSP_CODE( |
5322 |
|
|
on init |
5323 |
|
|
declare ~c := 3.2mdB |
5324 |
|
|
declare ~a := 4.0 |
5325 |
|
|
declare ~d := 2.0 |
5326 |
|
|
declare ~b := 2.0mdB |
5327 |
|
|
exit(~a * (~b + ~c) / ~d + 1.1mdB) |
5328 |
|
|
end on |
5329 |
|
|
)NKSP_CODE", |
5330 |
|
|
.expectRealExitResult = 11.5, |
5331 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
5332 |
|
|
.expectExitResultUnit = VM_BEL |
5333 |
|
|
}); |
5334 |
|
|
|
5335 |
|
|
// 'final' ('!') operator tests ... |
5336 |
|
|
|
5337 |
|
|
runScript({ |
5338 |
|
|
.code = R"NKSP_CODE( |
5339 |
|
|
on init |
5340 |
|
|
declare $a := 4 |
5341 |
|
|
declare $b := !2us |
5342 |
|
|
declare $c := 3us |
5343 |
|
|
declare $d := 7ms |
5344 |
|
|
exit($a * ($b + $c) + 7ms) |
5345 |
|
|
end on |
5346 |
|
|
)NKSP_CODE", |
5347 |
|
|
.expectIntExitResult = 7020, |
5348 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
5349 |
|
|
.expectExitResultUnit = VM_SECOND, |
5350 |
|
|
.expectExitResultFinal = true, |
5351 |
|
|
.expectParseWarning = true // only one operand is defined as 'final', result will be final though |
5352 |
|
|
}); |
5353 |
|
|
|
5354 |
|
|
runScript({ |
5355 |
|
|
.code = R"NKSP_CODE( |
5356 |
|
|
on init |
5357 |
|
|
declare $a := 4 |
5358 |
|
|
declare $b := 2us |
5359 |
|
|
declare $c := !3us |
5360 |
|
|
declare $d := 7ms |
5361 |
|
|
exit($a * ($b + $c) + 7ms) |
5362 |
|
|
end on |
5363 |
|
|
)NKSP_CODE", |
5364 |
|
|
.expectIntExitResult = 7020, |
5365 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
5366 |
|
|
.expectExitResultUnit = VM_SECOND, |
5367 |
|
|
.expectExitResultFinal = true, |
5368 |
|
|
.expectParseWarning = true // only one operand is defined as 'final', result will be final though |
5369 |
|
|
}); |
5370 |
|
|
|
5371 |
schoenebeck |
3551 |
#if !SILENT_TEST |
5372 |
|
|
std::cout << std::endl; |
5373 |
|
|
#endif |
5374 |
|
|
} |
5375 |
|
|
|
5376 |
|
|
static void testBuiltInMinFunction() { |
5377 |
|
|
#if !SILENT_TEST |
5378 |
|
|
std::cout << "UNIT TEST: built-in min() function\n"; |
5379 |
|
|
#endif |
5380 |
|
|
|
5381 |
|
|
runScript({ |
5382 |
|
|
.code = R"NKSP_CODE( |
5383 |
|
|
on init |
5384 |
|
|
declare $foo := min |
5385 |
|
|
end on |
5386 |
|
|
)NKSP_CODE", |
5387 |
|
|
.expectParseError = true // because min() function requires 2 arguments |
5388 |
|
|
}); |
5389 |
|
|
|
5390 |
|
|
runScript({ |
5391 |
|
|
.code = R"NKSP_CODE( |
5392 |
|
|
on init |
5393 |
|
|
declare $foo := min() |
5394 |
|
|
end on |
5395 |
|
|
)NKSP_CODE", |
5396 |
|
|
.expectParseError = true // because min() function requires 2 arguments |
5397 |
|
|
}); |
5398 |
|
|
|
5399 |
|
|
runScript({ |
5400 |
|
|
.code = R"NKSP_CODE( |
5401 |
|
|
on init |
5402 |
|
|
declare $foo := min(1) |
5403 |
|
|
end on |
5404 |
|
|
)NKSP_CODE", |
5405 |
|
|
.expectParseError = true // because min() function requires 2 arguments |
5406 |
|
|
}); |
5407 |
|
|
|
5408 |
schoenebeck |
3577 |
// integer tests ... |
5409 |
|
|
|
5410 |
schoenebeck |
3551 |
runScript({ |
5411 |
|
|
.code = R"NKSP_CODE( |
5412 |
|
|
on init |
5413 |
|
|
declare $foo := min(1,2) |
5414 |
|
|
exit($foo) |
5415 |
|
|
end on |
5416 |
|
|
)NKSP_CODE", |
5417 |
|
|
.expectIntExitResult = 1 |
5418 |
|
|
}); |
5419 |
|
|
|
5420 |
|
|
runScript({ |
5421 |
|
|
.code = R"NKSP_CODE( |
5422 |
|
|
on init |
5423 |
|
|
declare $foo := min(-30,4) |
5424 |
|
|
exit($foo) |
5425 |
|
|
end on |
5426 |
|
|
)NKSP_CODE", |
5427 |
|
|
.expectIntExitResult = -30 |
5428 |
|
|
}); |
5429 |
|
|
|
5430 |
schoenebeck |
3577 |
// real number tests ... |
5431 |
|
|
|
5432 |
|
|
runScript({ |
5433 |
|
|
.code = R"NKSP_CODE( |
5434 |
|
|
on init |
5435 |
schoenebeck |
3581 |
declare ~foo := min(1.0, 2.0) |
5436 |
|
|
exit(~foo) |
5437 |
schoenebeck |
3577 |
end on |
5438 |
|
|
)NKSP_CODE", |
5439 |
|
|
.expectRealExitResult = 1.0 |
5440 |
|
|
}); |
5441 |
|
|
|
5442 |
|
|
runScript({ |
5443 |
|
|
.code = R"NKSP_CODE( |
5444 |
|
|
on init |
5445 |
schoenebeck |
3581 |
declare ~foo := min(-30.0, 4.0) |
5446 |
|
|
exit(~foo) |
5447 |
schoenebeck |
3577 |
end on |
5448 |
|
|
)NKSP_CODE", |
5449 |
|
|
.expectRealExitResult = -30.0 |
5450 |
|
|
}); |
5451 |
|
|
|
5452 |
|
|
runScript({ |
5453 |
|
|
.code = R"NKSP_CODE( |
5454 |
|
|
on init |
5455 |
schoenebeck |
3581 |
declare ~foo := min(1.1, 1.13) |
5456 |
|
|
exit(~foo) |
5457 |
schoenebeck |
3577 |
end on |
5458 |
|
|
)NKSP_CODE", |
5459 |
|
|
.expectRealExitResult = 1.1 |
5460 |
|
|
}); |
5461 |
|
|
|
5462 |
|
|
runScript({ |
5463 |
|
|
.code = R"NKSP_CODE( |
5464 |
|
|
on init |
5465 |
schoenebeck |
3581 |
declare ~foo := min(1.13, 1.1) |
5466 |
|
|
exit(~foo) |
5467 |
schoenebeck |
3577 |
end on |
5468 |
|
|
)NKSP_CODE", |
5469 |
|
|
.expectRealExitResult = 1.1 |
5470 |
|
|
}); |
5471 |
|
|
|
5472 |
|
|
// mixed type tests ... |
5473 |
|
|
|
5474 |
|
|
runScript({ |
5475 |
|
|
.code = R"NKSP_CODE( |
5476 |
|
|
on init |
5477 |
schoenebeck |
3581 |
declare ~foo := min(1, 1.16) |
5478 |
|
|
exit(~foo) |
5479 |
|
|
end on |
5480 |
|
|
)NKSP_CODE", |
5481 |
|
|
.expectRealExitResult = 1.0, |
5482 |
|
|
.expectParseWarning = true // min() warns if data types of arguments not matching |
5483 |
|
|
}); |
5484 |
|
|
|
5485 |
|
|
runScript({ |
5486 |
|
|
.code = R"NKSP_CODE( |
5487 |
|
|
on init |
5488 |
|
|
declare ~foo := min(-3.92, 9) |
5489 |
|
|
exit(~foo) |
5490 |
|
|
end on |
5491 |
|
|
)NKSP_CODE", |
5492 |
|
|
.expectRealExitResult = -3.92, |
5493 |
|
|
.expectParseWarning = true // min() warns if data types of arguments not matching |
5494 |
|
|
}); |
5495 |
|
|
|
5496 |
|
|
// std unit tests ... |
5497 |
|
|
|
5498 |
|
|
runScript({ |
5499 |
|
|
.code = R"NKSP_CODE( |
5500 |
|
|
on init |
5501 |
|
|
declare $foo := min(30ms,4s) |
5502 |
schoenebeck |
3577 |
exit($foo) |
5503 |
|
|
end on |
5504 |
|
|
)NKSP_CODE", |
5505 |
schoenebeck |
3581 |
.expectIntExitResult = 30, |
5506 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
5507 |
|
|
.expectExitResultUnit = VM_SECOND, |
5508 |
schoenebeck |
3577 |
}); |
5509 |
|
|
|
5510 |
|
|
runScript({ |
5511 |
|
|
.code = R"NKSP_CODE( |
5512 |
|
|
on init |
5513 |
schoenebeck |
3581 |
declare $foo := min(4s,30ms) |
5514 |
schoenebeck |
3577 |
exit($foo) |
5515 |
|
|
end on |
5516 |
|
|
)NKSP_CODE", |
5517 |
schoenebeck |
3581 |
.expectIntExitResult = 30, |
5518 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
5519 |
|
|
.expectExitResultUnit = VM_SECOND, |
5520 |
schoenebeck |
3577 |
}); |
5521 |
|
|
|
5522 |
schoenebeck |
3581 |
runScript({ |
5523 |
|
|
.code = R"NKSP_CODE( |
5524 |
|
|
on init |
5525 |
|
|
declare $foo := min(-30mdB,-4dB) |
5526 |
|
|
exit($foo) |
5527 |
|
|
end on |
5528 |
|
|
)NKSP_CODE", |
5529 |
|
|
.expectIntExitResult = -4, |
5530 |
|
|
.expectExitResultUnitPrefix = { VM_DECI }, |
5531 |
|
|
.expectExitResultUnit = VM_BEL, |
5532 |
|
|
}); |
5533 |
|
|
|
5534 |
|
|
runScript({ |
5535 |
|
|
.code = R"NKSP_CODE( |
5536 |
|
|
on init |
5537 |
|
|
declare $foo := min(-4dB,-30mdB) |
5538 |
|
|
exit($foo) |
5539 |
|
|
end on |
5540 |
|
|
)NKSP_CODE", |
5541 |
|
|
.expectIntExitResult = -4, |
5542 |
|
|
.expectExitResultUnitPrefix = { VM_DECI }, |
5543 |
|
|
.expectExitResultUnit = VM_BEL, |
5544 |
|
|
}); |
5545 |
|
|
|
5546 |
|
|
runScript({ |
5547 |
|
|
.code = R"NKSP_CODE( |
5548 |
|
|
on init |
5549 |
|
|
declare $foo := min(-4s,-30Hz) |
5550 |
|
|
exit($foo) |
5551 |
|
|
end on |
5552 |
|
|
)NKSP_CODE", |
5553 |
|
|
.expectParseError = true // min() requires arguments to have same unit type |
5554 |
|
|
}); |
5555 |
|
|
|
5556 |
|
|
runScript({ |
5557 |
|
|
.code = R"NKSP_CODE( |
5558 |
|
|
on init |
5559 |
|
|
declare $foo := min(-4s,-30) |
5560 |
|
|
exit($foo) |
5561 |
|
|
end on |
5562 |
|
|
)NKSP_CODE", |
5563 |
|
|
.expectParseError = true // min() requires arguments to have same unit type |
5564 |
|
|
}); |
5565 |
|
|
|
5566 |
|
|
runScript({ |
5567 |
|
|
.code = R"NKSP_CODE( |
5568 |
|
|
on init |
5569 |
|
|
declare $foo := min(-4,-30s) |
5570 |
|
|
exit($foo) |
5571 |
|
|
end on |
5572 |
|
|
)NKSP_CODE", |
5573 |
|
|
.expectParseError = true // min() requires arguments to have same unit type |
5574 |
|
|
}); |
5575 |
|
|
|
5576 |
|
|
runScript({ |
5577 |
|
|
.code = R"NKSP_CODE( |
5578 |
|
|
on init |
5579 |
|
|
declare ~foo := min(0.9s,1.0s) |
5580 |
|
|
exit(~foo) |
5581 |
|
|
end on |
5582 |
|
|
)NKSP_CODE", |
5583 |
|
|
.expectRealExitResult = 0.9, |
5584 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
5585 |
|
|
.expectExitResultUnit = VM_SECOND, |
5586 |
|
|
}); |
5587 |
|
|
|
5588 |
|
|
// 'final' ('!') operator tests ... |
5589 |
|
|
|
5590 |
|
|
runScript({ |
5591 |
|
|
.code = R"NKSP_CODE( |
5592 |
|
|
on init |
5593 |
|
|
declare $foo := min(!30,!4) |
5594 |
|
|
exit($foo) |
5595 |
|
|
end on |
5596 |
|
|
)NKSP_CODE", |
5597 |
|
|
.expectIntExitResult = 4, |
5598 |
|
|
.expectExitResultFinal = true |
5599 |
|
|
}); |
5600 |
|
|
|
5601 |
|
|
runScript({ |
5602 |
|
|
.code = R"NKSP_CODE( |
5603 |
|
|
on init |
5604 |
|
|
declare $foo := min(30,4) |
5605 |
|
|
exit($foo) |
5606 |
|
|
end on |
5607 |
|
|
)NKSP_CODE", |
5608 |
|
|
.expectIntExitResult = 4, |
5609 |
|
|
.expectExitResultFinal = false |
5610 |
|
|
}); |
5611 |
|
|
|
5612 |
|
|
runScript({ |
5613 |
|
|
.code = R"NKSP_CODE( |
5614 |
|
|
on init |
5615 |
|
|
declare $foo := min(30,!4) |
5616 |
|
|
exit($foo) |
5617 |
|
|
end on |
5618 |
|
|
)NKSP_CODE", |
5619 |
|
|
.expectIntExitResult = 4, |
5620 |
|
|
.expectExitResultFinal = true, |
5621 |
|
|
.expectParseWarning = true // min() warns if only one argument is 'final' |
5622 |
|
|
}); |
5623 |
|
|
|
5624 |
|
|
runScript({ |
5625 |
|
|
.code = R"NKSP_CODE( |
5626 |
|
|
on init |
5627 |
|
|
declare $foo := min(!30,4) |
5628 |
|
|
exit($foo) |
5629 |
|
|
end on |
5630 |
|
|
)NKSP_CODE", |
5631 |
|
|
.expectIntExitResult = 4, |
5632 |
|
|
.expectExitResultFinal = true, |
5633 |
|
|
.expectParseWarning = true // min() warns if only one argument is 'final' |
5634 |
|
|
}); |
5635 |
|
|
|
5636 |
|
|
runScript({ |
5637 |
|
|
.code = R"NKSP_CODE( |
5638 |
|
|
on init |
5639 |
|
|
declare ~foo := min(!12.1,!12.2) |
5640 |
|
|
exit(~foo) |
5641 |
|
|
end on |
5642 |
|
|
)NKSP_CODE", |
5643 |
|
|
.expectRealExitResult = 12.1, |
5644 |
|
|
.expectExitResultFinal = true |
5645 |
|
|
}); |
5646 |
|
|
|
5647 |
|
|
runScript({ |
5648 |
|
|
.code = R"NKSP_CODE( |
5649 |
|
|
on init |
5650 |
|
|
declare ~foo := min(12.1,12.2) |
5651 |
|
|
exit(~foo) |
5652 |
|
|
end on |
5653 |
|
|
)NKSP_CODE", |
5654 |
|
|
.expectRealExitResult = 12.1, |
5655 |
|
|
.expectExitResultFinal = false |
5656 |
|
|
}); |
5657 |
|
|
|
5658 |
|
|
runScript({ |
5659 |
|
|
.code = R"NKSP_CODE( |
5660 |
|
|
on init |
5661 |
|
|
declare ~foo := min(!12.1,12.2) |
5662 |
|
|
exit(~foo) |
5663 |
|
|
end on |
5664 |
|
|
)NKSP_CODE", |
5665 |
|
|
.expectRealExitResult = 12.1, |
5666 |
|
|
.expectExitResultFinal = true, |
5667 |
|
|
.expectParseWarning = true // min() warns if only one argument is 'final' |
5668 |
|
|
}); |
5669 |
|
|
|
5670 |
|
|
runScript({ |
5671 |
|
|
.code = R"NKSP_CODE( |
5672 |
|
|
on init |
5673 |
|
|
declare ~foo := min(12.1,!12.2) |
5674 |
|
|
exit(~foo) |
5675 |
|
|
end on |
5676 |
|
|
)NKSP_CODE", |
5677 |
|
|
.expectRealExitResult = 12.1, |
5678 |
|
|
.expectExitResultFinal = true, |
5679 |
|
|
.expectParseWarning = true // min() warns if only one argument is 'final' |
5680 |
|
|
}); |
5681 |
|
|
|
5682 |
schoenebeck |
3551 |
#if !SILENT_TEST |
5683 |
|
|
std::cout << std::endl; |
5684 |
|
|
#endif |
5685 |
|
|
} |
5686 |
|
|
|
5687 |
|
|
static void testBuiltInMaxFunction() { |
5688 |
|
|
#if !SILENT_TEST |
5689 |
|
|
std::cout << "UNIT TEST: built-in max() function\n"; |
5690 |
|
|
#endif |
5691 |
|
|
|
5692 |
schoenebeck |
3577 |
// integer tests ... |
5693 |
|
|
|
5694 |
schoenebeck |
3551 |
runScript({ |
5695 |
|
|
.code = R"NKSP_CODE( |
5696 |
|
|
on init |
5697 |
|
|
declare $foo := max |
5698 |
|
|
end on |
5699 |
|
|
)NKSP_CODE", |
5700 |
|
|
.expectParseError = true // because max() function requires 2 arguments |
5701 |
|
|
}); |
5702 |
|
|
|
5703 |
|
|
runScript({ |
5704 |
|
|
.code = R"NKSP_CODE( |
5705 |
|
|
on init |
5706 |
|
|
declare $foo := max() |
5707 |
|
|
end on |
5708 |
|
|
)NKSP_CODE", |
5709 |
|
|
.expectParseError = true // because max() function requires 2 arguments |
5710 |
|
|
}); |
5711 |
|
|
|
5712 |
|
|
runScript({ |
5713 |
|
|
.code = R"NKSP_CODE( |
5714 |
|
|
on init |
5715 |
|
|
declare $foo := max(1) |
5716 |
|
|
end on |
5717 |
|
|
)NKSP_CODE", |
5718 |
|
|
.expectParseError = true // because max() function requires 2 arguments |
5719 |
|
|
}); |
5720 |
|
|
|
5721 |
|
|
runScript({ |
5722 |
|
|
.code = R"NKSP_CODE( |
5723 |
|
|
on init |
5724 |
|
|
declare $foo := max(1,2) |
5725 |
|
|
exit($foo) |
5726 |
|
|
end on |
5727 |
|
|
)NKSP_CODE", |
5728 |
|
|
.expectIntExitResult = 2 |
5729 |
|
|
}); |
5730 |
|
|
|
5731 |
|
|
runScript({ |
5732 |
|
|
.code = R"NKSP_CODE( |
5733 |
|
|
on init |
5734 |
|
|
declare $foo := max(-30,4) |
5735 |
|
|
exit($foo) |
5736 |
|
|
end on |
5737 |
|
|
)NKSP_CODE", |
5738 |
|
|
.expectIntExitResult = 4 |
5739 |
|
|
}); |
5740 |
|
|
|
5741 |
schoenebeck |
3577 |
// real number tests ... |
5742 |
|
|
|
5743 |
|
|
runScript({ |
5744 |
|
|
.code = R"NKSP_CODE( |
5745 |
|
|
on init |
5746 |
schoenebeck |
3581 |
declare ~foo := max(1.0, 2.0) |
5747 |
|
|
exit(~foo) |
5748 |
schoenebeck |
3577 |
end on |
5749 |
|
|
)NKSP_CODE", |
5750 |
|
|
.expectRealExitResult = 2.0 |
5751 |
|
|
}); |
5752 |
|
|
|
5753 |
|
|
runScript({ |
5754 |
|
|
.code = R"NKSP_CODE( |
5755 |
|
|
on init |
5756 |
schoenebeck |
3581 |
declare ~foo := max(-30.0, 4.0) |
5757 |
|
|
exit(~foo) |
5758 |
schoenebeck |
3577 |
end on |
5759 |
|
|
)NKSP_CODE", |
5760 |
|
|
.expectRealExitResult = 4.0 |
5761 |
|
|
}); |
5762 |
|
|
|
5763 |
|
|
runScript({ |
5764 |
|
|
.code = R"NKSP_CODE( |
5765 |
|
|
on init |
5766 |
schoenebeck |
3581 |
declare ~foo := max(1.1, 1.13) |
5767 |
|
|
exit(~foo) |
5768 |
schoenebeck |
3577 |
end on |
5769 |
|
|
)NKSP_CODE", |
5770 |
|
|
.expectRealExitResult = 1.13 |
5771 |
|
|
}); |
5772 |
|
|
|
5773 |
|
|
runScript({ |
5774 |
|
|
.code = R"NKSP_CODE( |
5775 |
|
|
on init |
5776 |
schoenebeck |
3581 |
declare ~foo := max(1.13, 1.1) |
5777 |
|
|
exit(~foo) |
5778 |
schoenebeck |
3577 |
end on |
5779 |
|
|
)NKSP_CODE", |
5780 |
|
|
.expectRealExitResult = 1.13 |
5781 |
|
|
}); |
5782 |
|
|
|
5783 |
|
|
// mixed type tests ... |
5784 |
|
|
|
5785 |
|
|
runScript({ |
5786 |
|
|
.code = R"NKSP_CODE( |
5787 |
|
|
on init |
5788 |
schoenebeck |
3581 |
declare ~foo := max(1, 1.16) |
5789 |
|
|
exit(~foo) |
5790 |
|
|
end on |
5791 |
|
|
)NKSP_CODE", |
5792 |
|
|
.expectRealExitResult = 1.16, |
5793 |
|
|
.expectParseWarning = true // max() warns if data types of arguments not matching |
5794 |
|
|
}); |
5795 |
|
|
|
5796 |
|
|
runScript({ |
5797 |
|
|
.code = R"NKSP_CODE( |
5798 |
|
|
on init |
5799 |
|
|
declare ~foo := max(-3.92, 9) |
5800 |
|
|
exit(~foo) |
5801 |
|
|
end on |
5802 |
|
|
)NKSP_CODE", |
5803 |
|
|
.expectRealExitResult = 9.0, |
5804 |
|
|
.expectParseWarning = true // max() warns if data types of arguments not matching |
5805 |
|
|
}); |
5806 |
|
|
|
5807 |
|
|
// std unit tests ... |
5808 |
|
|
|
5809 |
|
|
runScript({ |
5810 |
|
|
.code = R"NKSP_CODE( |
5811 |
|
|
on init |
5812 |
|
|
declare $foo := max(30ms,4s) |
5813 |
schoenebeck |
3577 |
exit($foo) |
5814 |
|
|
end on |
5815 |
|
|
)NKSP_CODE", |
5816 |
schoenebeck |
3581 |
.expectIntExitResult = 4, |
5817 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
5818 |
|
|
.expectExitResultUnit = VM_SECOND, |
5819 |
schoenebeck |
3577 |
}); |
5820 |
|
|
|
5821 |
|
|
runScript({ |
5822 |
|
|
.code = R"NKSP_CODE( |
5823 |
|
|
on init |
5824 |
schoenebeck |
3581 |
declare $foo := max(4s,30ms) |
5825 |
schoenebeck |
3577 |
exit($foo) |
5826 |
|
|
end on |
5827 |
|
|
)NKSP_CODE", |
5828 |
schoenebeck |
3581 |
.expectIntExitResult = 4, |
5829 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
5830 |
|
|
.expectExitResultUnit = VM_SECOND, |
5831 |
schoenebeck |
3577 |
}); |
5832 |
|
|
|
5833 |
schoenebeck |
3581 |
runScript({ |
5834 |
|
|
.code = R"NKSP_CODE( |
5835 |
|
|
on init |
5836 |
|
|
declare $foo := max(-30mdB,-4dB) |
5837 |
|
|
exit($foo) |
5838 |
|
|
end on |
5839 |
|
|
)NKSP_CODE", |
5840 |
|
|
.expectIntExitResult = -30, |
5841 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
5842 |
|
|
.expectExitResultUnit = VM_BEL, |
5843 |
|
|
}); |
5844 |
|
|
|
5845 |
|
|
runScript({ |
5846 |
|
|
.code = R"NKSP_CODE( |
5847 |
|
|
on init |
5848 |
|
|
declare $foo := max(-4dB,-30mdB) |
5849 |
|
|
exit($foo) |
5850 |
|
|
end on |
5851 |
|
|
)NKSP_CODE", |
5852 |
|
|
.expectIntExitResult = -30, |
5853 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
5854 |
|
|
.expectExitResultUnit = VM_BEL, |
5855 |
|
|
}); |
5856 |
|
|
|
5857 |
|
|
runScript({ |
5858 |
|
|
.code = R"NKSP_CODE( |
5859 |
|
|
on init |
5860 |
|
|
declare $foo := max(-4s,-30Hz) |
5861 |
|
|
exit($foo) |
5862 |
|
|
end on |
5863 |
|
|
)NKSP_CODE", |
5864 |
|
|
.expectParseError = true // max() requires arguments to have same unit type |
5865 |
|
|
}); |
5866 |
|
|
|
5867 |
|
|
runScript({ |
5868 |
|
|
.code = R"NKSP_CODE( |
5869 |
|
|
on init |
5870 |
|
|
declare $foo := max(-4s,-30) |
5871 |
|
|
exit($foo) |
5872 |
|
|
end on |
5873 |
|
|
)NKSP_CODE", |
5874 |
|
|
.expectParseError = true // max() requires arguments to have same unit type |
5875 |
|
|
}); |
5876 |
|
|
|
5877 |
|
|
runScript({ |
5878 |
|
|
.code = R"NKSP_CODE( |
5879 |
|
|
on init |
5880 |
|
|
declare $foo := max(-4,-30s) |
5881 |
|
|
exit($foo) |
5882 |
|
|
end on |
5883 |
|
|
)NKSP_CODE", |
5884 |
|
|
.expectParseError = true // max() requires arguments to have same unit type |
5885 |
|
|
}); |
5886 |
|
|
|
5887 |
|
|
runScript({ |
5888 |
|
|
.code = R"NKSP_CODE( |
5889 |
|
|
on init |
5890 |
|
|
declare ~foo := max(0.9s,1.0s) |
5891 |
|
|
exit(~foo) |
5892 |
|
|
end on |
5893 |
|
|
)NKSP_CODE", |
5894 |
|
|
.expectRealExitResult = 1.0, |
5895 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
5896 |
|
|
.expectExitResultUnit = VM_SECOND, |
5897 |
|
|
}); |
5898 |
|
|
|
5899 |
|
|
// 'final' ('!') operator tests ... |
5900 |
|
|
|
5901 |
|
|
runScript({ |
5902 |
|
|
.code = R"NKSP_CODE( |
5903 |
|
|
on init |
5904 |
|
|
declare $foo := max(!30,!4) |
5905 |
|
|
exit($foo) |
5906 |
|
|
end on |
5907 |
|
|
)NKSP_CODE", |
5908 |
|
|
.expectIntExitResult = 30, |
5909 |
|
|
.expectExitResultFinal = true |
5910 |
|
|
}); |
5911 |
|
|
|
5912 |
|
|
runScript({ |
5913 |
|
|
.code = R"NKSP_CODE( |
5914 |
|
|
on init |
5915 |
|
|
declare $foo := max(30,4) |
5916 |
|
|
exit($foo) |
5917 |
|
|
end on |
5918 |
|
|
)NKSP_CODE", |
5919 |
|
|
.expectIntExitResult = 30, |
5920 |
|
|
.expectExitResultFinal = false |
5921 |
|
|
}); |
5922 |
|
|
|
5923 |
|
|
runScript({ |
5924 |
|
|
.code = R"NKSP_CODE( |
5925 |
|
|
on init |
5926 |
|
|
declare $foo := max(30,!4) |
5927 |
|
|
exit($foo) |
5928 |
|
|
end on |
5929 |
|
|
)NKSP_CODE", |
5930 |
|
|
.expectIntExitResult = 30, |
5931 |
|
|
.expectExitResultFinal = true, |
5932 |
|
|
.expectParseWarning = true // max() warns if only one argument is 'final' |
5933 |
|
|
}); |
5934 |
|
|
|
5935 |
|
|
runScript({ |
5936 |
|
|
.code = R"NKSP_CODE( |
5937 |
|
|
on init |
5938 |
|
|
declare $foo := max(!30,4) |
5939 |
|
|
exit($foo) |
5940 |
|
|
end on |
5941 |
|
|
)NKSP_CODE", |
5942 |
|
|
.expectIntExitResult = 30, |
5943 |
|
|
.expectExitResultFinal = true, |
5944 |
|
|
.expectParseWarning = true // max() warns if only one argument is 'final' |
5945 |
|
|
}); |
5946 |
|
|
|
5947 |
|
|
runScript({ |
5948 |
|
|
.code = R"NKSP_CODE( |
5949 |
|
|
on init |
5950 |
|
|
declare ~foo := max(!12.1,!12.2) |
5951 |
|
|
exit(~foo) |
5952 |
|
|
end on |
5953 |
|
|
)NKSP_CODE", |
5954 |
|
|
.expectRealExitResult = 12.2, |
5955 |
|
|
.expectExitResultFinal = true |
5956 |
|
|
}); |
5957 |
|
|
|
5958 |
|
|
runScript({ |
5959 |
|
|
.code = R"NKSP_CODE( |
5960 |
|
|
on init |
5961 |
|
|
declare ~foo := max(12.1,12.2) |
5962 |
|
|
exit(~foo) |
5963 |
|
|
end on |
5964 |
|
|
)NKSP_CODE", |
5965 |
|
|
.expectRealExitResult = 12.2, |
5966 |
|
|
.expectExitResultFinal = false |
5967 |
|
|
}); |
5968 |
|
|
|
5969 |
|
|
runScript({ |
5970 |
|
|
.code = R"NKSP_CODE( |
5971 |
|
|
on init |
5972 |
|
|
declare ~foo := max(!12.1,12.2) |
5973 |
|
|
exit(~foo) |
5974 |
|
|
end on |
5975 |
|
|
)NKSP_CODE", |
5976 |
|
|
.expectRealExitResult = 12.2, |
5977 |
|
|
.expectExitResultFinal = true, |
5978 |
|
|
.expectParseWarning = true // max() warns if only one argument is 'final' |
5979 |
|
|
}); |
5980 |
|
|
|
5981 |
|
|
runScript({ |
5982 |
|
|
.code = R"NKSP_CODE( |
5983 |
|
|
on init |
5984 |
|
|
declare ~foo := max(12.1,!12.2) |
5985 |
|
|
exit(~foo) |
5986 |
|
|
end on |
5987 |
|
|
)NKSP_CODE", |
5988 |
|
|
.expectRealExitResult = 12.2, |
5989 |
|
|
.expectExitResultFinal = true, |
5990 |
|
|
.expectParseWarning = true // max() warns if only one argument is 'final' |
5991 |
|
|
}); |
5992 |
|
|
|
5993 |
schoenebeck |
3551 |
#if !SILENT_TEST |
5994 |
|
|
std::cout << std::endl; |
5995 |
|
|
#endif |
5996 |
|
|
} |
5997 |
|
|
|
5998 |
|
|
static void testBuiltInAbsFunction() { |
5999 |
|
|
#if !SILENT_TEST |
6000 |
|
|
std::cout << "UNIT TEST: built-in abs() function\n"; |
6001 |
|
|
#endif |
6002 |
|
|
|
6003 |
|
|
runScript({ |
6004 |
|
|
.code = R"NKSP_CODE( |
6005 |
|
|
on init |
6006 |
|
|
declare $foo := abs |
6007 |
|
|
end on |
6008 |
|
|
)NKSP_CODE", |
6009 |
|
|
.expectParseError = true // because abs() function requires 1 argument |
6010 |
|
|
}); |
6011 |
|
|
|
6012 |
|
|
runScript({ |
6013 |
|
|
.code = R"NKSP_CODE( |
6014 |
|
|
on init |
6015 |
|
|
declare $foo := abs() |
6016 |
|
|
end on |
6017 |
|
|
)NKSP_CODE", |
6018 |
|
|
.expectParseError = true // because abs() function requires 1 argument |
6019 |
|
|
}); |
6020 |
|
|
|
6021 |
schoenebeck |
3577 |
// integer tests ... |
6022 |
|
|
|
6023 |
schoenebeck |
3551 |
runScript({ |
6024 |
|
|
.code = R"NKSP_CODE( |
6025 |
|
|
on init |
6026 |
|
|
declare $foo := abs(23) |
6027 |
|
|
exit($foo) |
6028 |
|
|
end on |
6029 |
|
|
)NKSP_CODE", |
6030 |
|
|
.expectIntExitResult = 23 |
6031 |
|
|
}); |
6032 |
|
|
|
6033 |
|
|
runScript({ |
6034 |
|
|
.code = R"NKSP_CODE( |
6035 |
|
|
on init |
6036 |
|
|
declare $foo := abs(-23) |
6037 |
|
|
exit($foo) |
6038 |
|
|
end on |
6039 |
|
|
)NKSP_CODE", |
6040 |
|
|
.expectIntExitResult = 23 |
6041 |
|
|
}); |
6042 |
|
|
|
6043 |
schoenebeck |
3577 |
// real number tests ... |
6044 |
|
|
|
6045 |
|
|
runScript({ |
6046 |
|
|
.code = R"NKSP_CODE( |
6047 |
|
|
on init |
6048 |
|
|
declare ~foo := abs(23.0) |
6049 |
|
|
exit(~foo) |
6050 |
|
|
end on |
6051 |
|
|
)NKSP_CODE", |
6052 |
|
|
.expectRealExitResult = 23.0 |
6053 |
|
|
}); |
6054 |
|
|
|
6055 |
|
|
runScript({ |
6056 |
|
|
.code = R"NKSP_CODE( |
6057 |
|
|
on init |
6058 |
|
|
declare ~foo := abs(23.11) |
6059 |
|
|
exit(~foo) |
6060 |
|
|
end on |
6061 |
|
|
)NKSP_CODE", |
6062 |
|
|
.expectRealExitResult = 23.11 |
6063 |
|
|
}); |
6064 |
|
|
|
6065 |
|
|
runScript({ |
6066 |
|
|
.code = R"NKSP_CODE( |
6067 |
|
|
on init |
6068 |
|
|
declare ~foo := abs(-23.11) |
6069 |
|
|
exit(~foo) |
6070 |
|
|
end on |
6071 |
|
|
)NKSP_CODE", |
6072 |
|
|
.expectRealExitResult = 23.11 |
6073 |
|
|
}); |
6074 |
|
|
|
6075 |
|
|
runScript({ |
6076 |
|
|
.code = R"NKSP_CODE( |
6077 |
|
|
on init |
6078 |
|
|
declare ~bar := -23.11 |
6079 |
|
|
declare ~foo := abs(~bar) |
6080 |
|
|
exit(~foo) |
6081 |
|
|
end on |
6082 |
|
|
)NKSP_CODE", |
6083 |
|
|
.expectRealExitResult = 23.11 |
6084 |
|
|
}); |
6085 |
|
|
|
6086 |
schoenebeck |
3581 |
// std unit tests ... |
6087 |
|
|
|
6088 |
|
|
runScript({ |
6089 |
|
|
.code = R"NKSP_CODE( |
6090 |
|
|
on init |
6091 |
|
|
declare $foo := abs(-23kHz) |
6092 |
|
|
exit($foo) |
6093 |
|
|
end on |
6094 |
|
|
)NKSP_CODE", |
6095 |
|
|
.expectIntExitResult = 23, |
6096 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
6097 |
|
|
.expectExitResultUnit = VM_HERTZ |
6098 |
|
|
}); |
6099 |
|
|
|
6100 |
|
|
runScript({ |
6101 |
|
|
.code = R"NKSP_CODE( |
6102 |
|
|
on init |
6103 |
|
|
declare ~foo := abs(-23.4kHz) |
6104 |
|
|
exit(~foo) |
6105 |
|
|
end on |
6106 |
|
|
)NKSP_CODE", |
6107 |
|
|
.expectRealExitResult = 23.4, |
6108 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
6109 |
|
|
.expectExitResultUnit = VM_HERTZ |
6110 |
|
|
}); |
6111 |
|
|
|
6112 |
|
|
// 'final' ('!') operator tests ... |
6113 |
|
|
|
6114 |
|
|
runScript({ |
6115 |
|
|
.code = R"NKSP_CODE( |
6116 |
|
|
on init |
6117 |
|
|
declare $foo := abs(!-23) |
6118 |
|
|
exit($foo) |
6119 |
|
|
end on |
6120 |
|
|
)NKSP_CODE", |
6121 |
|
|
.expectIntExitResult = 23, |
6122 |
|
|
.expectExitResultFinal = true |
6123 |
|
|
}); |
6124 |
|
|
|
6125 |
|
|
runScript({ |
6126 |
|
|
.code = R"NKSP_CODE( |
6127 |
|
|
on init |
6128 |
|
|
declare $foo := abs(-23) |
6129 |
|
|
exit($foo) |
6130 |
|
|
end on |
6131 |
|
|
)NKSP_CODE", |
6132 |
|
|
.expectIntExitResult = 23, |
6133 |
|
|
.expectExitResultFinal = false |
6134 |
|
|
}); |
6135 |
|
|
|
6136 |
|
|
runScript({ |
6137 |
|
|
.code = R"NKSP_CODE( |
6138 |
|
|
on init |
6139 |
|
|
declare ~foo := abs(!-23.2) |
6140 |
|
|
exit(~foo) |
6141 |
|
|
end on |
6142 |
|
|
)NKSP_CODE", |
6143 |
|
|
.expectRealExitResult = 23.2, |
6144 |
|
|
.expectExitResultFinal = true |
6145 |
|
|
}); |
6146 |
|
|
|
6147 |
|
|
runScript({ |
6148 |
|
|
.code = R"NKSP_CODE( |
6149 |
|
|
on init |
6150 |
|
|
declare ~foo := abs(-23.9) |
6151 |
|
|
exit(~foo) |
6152 |
|
|
end on |
6153 |
|
|
)NKSP_CODE", |
6154 |
|
|
.expectRealExitResult = 23.9, |
6155 |
|
|
.expectExitResultFinal = false |
6156 |
|
|
}); |
6157 |
|
|
|
6158 |
schoenebeck |
3551 |
#if !SILENT_TEST |
6159 |
|
|
std::cout << std::endl; |
6160 |
|
|
#endif |
6161 |
|
|
} |
6162 |
|
|
|
6163 |
|
|
static void testBuiltInIncFunction() { |
6164 |
|
|
#if !SILENT_TEST |
6165 |
|
|
std::cout << "UNIT TEST: built-in inc() function\n"; |
6166 |
|
|
#endif |
6167 |
|
|
|
6168 |
schoenebeck |
3581 |
// integer tests ... |
6169 |
|
|
|
6170 |
schoenebeck |
3551 |
runScript({ |
6171 |
|
|
.code = R"NKSP_CODE( |
6172 |
|
|
on init |
6173 |
|
|
declare $foo := 5 |
6174 |
|
|
inc($foo) |
6175 |
|
|
exit($foo) |
6176 |
|
|
end on |
6177 |
|
|
)NKSP_CODE", |
6178 |
|
|
.expectIntExitResult = 6 |
6179 |
|
|
}); |
6180 |
|
|
|
6181 |
|
|
runScript({ |
6182 |
|
|
.code = R"NKSP_CODE( |
6183 |
|
|
on init |
6184 |
|
|
declare $foo := 5 |
6185 |
|
|
inc($foo) |
6186 |
|
|
inc($foo) |
6187 |
|
|
inc($foo) |
6188 |
|
|
exit($foo) |
6189 |
|
|
end on |
6190 |
|
|
)NKSP_CODE", |
6191 |
|
|
.expectIntExitResult = 8 |
6192 |
|
|
}); |
6193 |
|
|
|
6194 |
|
|
runScript({ |
6195 |
|
|
.code = R"NKSP_CODE( |
6196 |
|
|
on init |
6197 |
|
|
declare $foo := 5 |
6198 |
|
|
inc($foo) |
6199 |
|
|
exit( inc($foo) ) |
6200 |
|
|
end on |
6201 |
|
|
)NKSP_CODE", |
6202 |
|
|
.expectIntExitResult = 7 |
6203 |
|
|
}); |
6204 |
|
|
|
6205 |
schoenebeck |
3581 |
// std unit tests ... |
6206 |
|
|
|
6207 |
|
|
runScript({ |
6208 |
|
|
.code = R"NKSP_CODE( |
6209 |
|
|
on init |
6210 |
|
|
declare $foo := 53mdB |
6211 |
|
|
inc($foo) |
6212 |
|
|
exit( inc($foo) ) |
6213 |
|
|
end on |
6214 |
|
|
)NKSP_CODE", |
6215 |
|
|
.expectIntExitResult = 55, |
6216 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
6217 |
|
|
.expectExitResultUnit = VM_BEL, |
6218 |
|
|
.expectParseWarning = true // inc() warns if argument has a unit |
6219 |
|
|
}); |
6220 |
|
|
|
6221 |
|
|
// 'final' ('!') operator tests ... |
6222 |
|
|
|
6223 |
|
|
runScript({ |
6224 |
|
|
.code = R"NKSP_CODE( |
6225 |
|
|
on init |
6226 |
|
|
declare $foo := !53 |
6227 |
|
|
inc($foo) |
6228 |
|
|
exit( inc($foo) ) |
6229 |
|
|
end on |
6230 |
|
|
)NKSP_CODE", |
6231 |
|
|
.expectIntExitResult = 55, |
6232 |
|
|
.expectExitResultFinal = true |
6233 |
|
|
}); |
6234 |
|
|
|
6235 |
|
|
runScript({ |
6236 |
|
|
.code = R"NKSP_CODE( |
6237 |
|
|
on init |
6238 |
|
|
declare $foo := 53 |
6239 |
|
|
inc($foo) |
6240 |
|
|
exit( inc($foo) ) |
6241 |
|
|
end on |
6242 |
|
|
)NKSP_CODE", |
6243 |
|
|
.expectIntExitResult = 55, |
6244 |
|
|
.expectExitResultFinal = false |
6245 |
|
|
}); |
6246 |
|
|
|
6247 |
|
|
runScript({ |
6248 |
|
|
.code = R"NKSP_CODE( |
6249 |
|
|
on init |
6250 |
|
|
declare $foo := 53 |
6251 |
|
|
inc($foo) |
6252 |
|
|
exit( !inc($foo) ) |
6253 |
|
|
end on |
6254 |
|
|
)NKSP_CODE", |
6255 |
|
|
.expectIntExitResult = 55, |
6256 |
|
|
.expectExitResultFinal = true |
6257 |
|
|
}); |
6258 |
|
|
|
6259 |
schoenebeck |
3551 |
#if !SILENT_TEST |
6260 |
|
|
std::cout << std::endl; |
6261 |
|
|
#endif |
6262 |
|
|
} |
6263 |
|
|
|
6264 |
|
|
static void testBuiltInDecFunction() { |
6265 |
|
|
#if !SILENT_TEST |
6266 |
|
|
std::cout << "UNIT TEST: built-in dec() function\n"; |
6267 |
|
|
#endif |
6268 |
|
|
|
6269 |
schoenebeck |
3581 |
// integer tests ... |
6270 |
|
|
|
6271 |
schoenebeck |
3551 |
runScript({ |
6272 |
|
|
.code = R"NKSP_CODE( |
6273 |
|
|
on init |
6274 |
|
|
declare $foo := 5 |
6275 |
|
|
dec($foo) |
6276 |
|
|
exit($foo) |
6277 |
|
|
end on |
6278 |
|
|
)NKSP_CODE", |
6279 |
|
|
.expectIntExitResult = 4 |
6280 |
|
|
}); |
6281 |
|
|
|
6282 |
|
|
runScript({ |
6283 |
|
|
.code = R"NKSP_CODE( |
6284 |
|
|
on init |
6285 |
|
|
declare $foo := 5 |
6286 |
|
|
dec($foo) |
6287 |
|
|
dec($foo) |
6288 |
|
|
dec($foo) |
6289 |
|
|
exit($foo) |
6290 |
|
|
end on |
6291 |
|
|
)NKSP_CODE", |
6292 |
|
|
.expectIntExitResult = 2 |
6293 |
|
|
}); |
6294 |
|
|
|
6295 |
|
|
runScript({ |
6296 |
|
|
.code = R"NKSP_CODE( |
6297 |
|
|
on init |
6298 |
|
|
declare $foo := 5 |
6299 |
|
|
dec($foo) |
6300 |
|
|
exit( dec($foo) ) |
6301 |
|
|
end on |
6302 |
|
|
)NKSP_CODE", |
6303 |
|
|
.expectIntExitResult = 3 |
6304 |
|
|
}); |
6305 |
|
|
|
6306 |
schoenebeck |
3581 |
// std unit tests ... |
6307 |
|
|
|
6308 |
|
|
runScript({ |
6309 |
|
|
.code = R"NKSP_CODE( |
6310 |
|
|
on init |
6311 |
|
|
declare $foo := 53mdB |
6312 |
|
|
dec($foo) |
6313 |
|
|
exit( dec($foo) ) |
6314 |
|
|
end on |
6315 |
|
|
)NKSP_CODE", |
6316 |
|
|
.expectIntExitResult = 51, |
6317 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
6318 |
|
|
.expectExitResultUnit = VM_BEL, |
6319 |
|
|
.expectParseWarning = true // dec() warns if argument has a unit |
6320 |
|
|
}); |
6321 |
|
|
|
6322 |
|
|
// 'final' ('!') operator tests ... |
6323 |
|
|
|
6324 |
|
|
runScript({ |
6325 |
|
|
.code = R"NKSP_CODE( |
6326 |
|
|
on init |
6327 |
|
|
declare $foo := !53 |
6328 |
|
|
dec($foo) |
6329 |
|
|
exit( dec($foo) ) |
6330 |
|
|
end on |
6331 |
|
|
)NKSP_CODE", |
6332 |
|
|
.expectIntExitResult = 51, |
6333 |
|
|
.expectExitResultFinal = true |
6334 |
|
|
}); |
6335 |
|
|
|
6336 |
|
|
runScript({ |
6337 |
|
|
.code = R"NKSP_CODE( |
6338 |
|
|
on init |
6339 |
|
|
declare $foo := 53 |
6340 |
|
|
dec($foo) |
6341 |
|
|
exit( dec($foo) ) |
6342 |
|
|
end on |
6343 |
|
|
)NKSP_CODE", |
6344 |
|
|
.expectIntExitResult = 51, |
6345 |
|
|
.expectExitResultFinal = false |
6346 |
|
|
}); |
6347 |
|
|
|
6348 |
|
|
runScript({ |
6349 |
|
|
.code = R"NKSP_CODE( |
6350 |
|
|
on init |
6351 |
|
|
declare $foo := 53 |
6352 |
|
|
dec($foo) |
6353 |
|
|
exit( !dec($foo) ) |
6354 |
|
|
end on |
6355 |
|
|
)NKSP_CODE", |
6356 |
|
|
.expectIntExitResult = 51, |
6357 |
|
|
.expectExitResultFinal = true |
6358 |
|
|
}); |
6359 |
|
|
|
6360 |
schoenebeck |
3551 |
#if !SILENT_TEST |
6361 |
|
|
std::cout << std::endl; |
6362 |
|
|
#endif |
6363 |
|
|
} |
6364 |
|
|
|
6365 |
|
|
static void testBuiltInInRangeFunction() { |
6366 |
|
|
#if !SILENT_TEST |
6367 |
|
|
std::cout << "UNIT TEST: built-in in_range() function\n"; |
6368 |
|
|
#endif |
6369 |
|
|
|
6370 |
schoenebeck |
3581 |
// integer tests ... |
6371 |
|
|
|
6372 |
schoenebeck |
3551 |
runScript({ |
6373 |
|
|
.code = R"NKSP_CODE( |
6374 |
|
|
on init |
6375 |
|
|
exit( in_range(1,4,9) ) |
6376 |
|
|
end on |
6377 |
|
|
)NKSP_CODE", |
6378 |
|
|
.expectBoolExitResult = false |
6379 |
|
|
}); |
6380 |
|
|
|
6381 |
|
|
runScript({ |
6382 |
|
|
.code = R"NKSP_CODE( |
6383 |
|
|
on init |
6384 |
|
|
exit( in_range(5,4,9) ) |
6385 |
|
|
end on |
6386 |
|
|
)NKSP_CODE", |
6387 |
|
|
.expectBoolExitResult = true |
6388 |
|
|
}); |
6389 |
|
|
|
6390 |
|
|
runScript({ |
6391 |
|
|
.code = R"NKSP_CODE( |
6392 |
|
|
on init |
6393 |
|
|
exit( in_range(9,4,9) ) |
6394 |
|
|
end on |
6395 |
|
|
)NKSP_CODE", |
6396 |
|
|
.expectBoolExitResult = true |
6397 |
|
|
}); |
6398 |
|
|
|
6399 |
|
|
runScript({ |
6400 |
|
|
.code = R"NKSP_CODE( |
6401 |
|
|
on init |
6402 |
|
|
exit( in_range(10,4,9) ) |
6403 |
|
|
end on |
6404 |
|
|
)NKSP_CODE", |
6405 |
|
|
.expectBoolExitResult = false |
6406 |
|
|
}); |
6407 |
|
|
|
6408 |
|
|
runScript({ |
6409 |
|
|
.code = R"NKSP_CODE( |
6410 |
|
|
on init |
6411 |
|
|
exit( in_range(-6,-5,5) ) |
6412 |
|
|
end on |
6413 |
|
|
)NKSP_CODE", |
6414 |
|
|
.expectBoolExitResult = false |
6415 |
|
|
}); |
6416 |
|
|
|
6417 |
|
|
runScript({ |
6418 |
|
|
.code = R"NKSP_CODE( |
6419 |
|
|
on init |
6420 |
|
|
exit( in_range(-5,-5,5) ) |
6421 |
|
|
end on |
6422 |
|
|
)NKSP_CODE", |
6423 |
|
|
.expectBoolExitResult = true |
6424 |
|
|
}); |
6425 |
|
|
|
6426 |
|
|
runScript({ |
6427 |
|
|
.code = R"NKSP_CODE( |
6428 |
|
|
on init |
6429 |
|
|
exit( in_range(0,-5,5) ) |
6430 |
|
|
end on |
6431 |
|
|
)NKSP_CODE", |
6432 |
|
|
.expectBoolExitResult = true |
6433 |
|
|
}); |
6434 |
|
|
|
6435 |
|
|
runScript({ |
6436 |
|
|
.code = R"NKSP_CODE( |
6437 |
|
|
on init |
6438 |
|
|
exit( in_range(5,-5,5) ) |
6439 |
|
|
end on |
6440 |
|
|
)NKSP_CODE", |
6441 |
|
|
.expectBoolExitResult = true |
6442 |
|
|
}); |
6443 |
|
|
|
6444 |
|
|
runScript({ |
6445 |
|
|
.code = R"NKSP_CODE( |
6446 |
|
|
on init |
6447 |
|
|
exit( in_range(6,-5,5) ) |
6448 |
|
|
end on |
6449 |
|
|
)NKSP_CODE", |
6450 |
|
|
.expectBoolExitResult = false |
6451 |
|
|
}); |
6452 |
|
|
|
6453 |
schoenebeck |
3581 |
// real number tests ... |
6454 |
|
|
|
6455 |
|
|
runScript({ |
6456 |
|
|
.code = R"NKSP_CODE( |
6457 |
|
|
on init |
6458 |
|
|
exit( in_range(12.2,12.1,12.9) ) |
6459 |
|
|
end on |
6460 |
|
|
)NKSP_CODE", |
6461 |
|
|
.expectBoolExitResult = true |
6462 |
|
|
}); |
6463 |
|
|
|
6464 |
|
|
runScript({ |
6465 |
|
|
.code = R"NKSP_CODE( |
6466 |
|
|
on init |
6467 |
|
|
exit( in_range(12.2,12.9,12.1) ) |
6468 |
|
|
end on |
6469 |
|
|
)NKSP_CODE", |
6470 |
|
|
.expectBoolExitResult = true |
6471 |
|
|
}); |
6472 |
|
|
|
6473 |
|
|
runScript({ |
6474 |
|
|
.code = R"NKSP_CODE( |
6475 |
|
|
on init |
6476 |
|
|
exit( in_range(12.0,12.1,12.9) ) |
6477 |
|
|
end on |
6478 |
|
|
)NKSP_CODE", |
6479 |
|
|
.expectBoolExitResult = false |
6480 |
|
|
}); |
6481 |
|
|
|
6482 |
|
|
runScript({ |
6483 |
|
|
.code = R"NKSP_CODE( |
6484 |
|
|
on init |
6485 |
|
|
exit( in_range(12.0,12.9,12.1) ) |
6486 |
|
|
end on |
6487 |
|
|
)NKSP_CODE", |
6488 |
|
|
.expectBoolExitResult = false |
6489 |
|
|
}); |
6490 |
|
|
|
6491 |
|
|
runScript({ |
6492 |
|
|
.code = R"NKSP_CODE( |
6493 |
|
|
on init |
6494 |
|
|
exit( in_range(0.0,-0.3,0.3) ) |
6495 |
|
|
end on |
6496 |
|
|
)NKSP_CODE", |
6497 |
|
|
.expectBoolExitResult = true |
6498 |
|
|
}); |
6499 |
|
|
|
6500 |
|
|
runScript({ |
6501 |
|
|
.code = R"NKSP_CODE( |
6502 |
|
|
on init |
6503 |
|
|
exit( in_range(-0.34,-0.3,0.3) ) |
6504 |
|
|
end on |
6505 |
|
|
)NKSP_CODE", |
6506 |
|
|
.expectBoolExitResult = false |
6507 |
|
|
}); |
6508 |
|
|
|
6509 |
|
|
runScript({ |
6510 |
|
|
.code = R"NKSP_CODE( |
6511 |
|
|
on init |
6512 |
|
|
exit( in_range(0.34,-0.3,0.3) ) |
6513 |
|
|
end on |
6514 |
|
|
)NKSP_CODE", |
6515 |
|
|
.expectBoolExitResult = false |
6516 |
|
|
}); |
6517 |
|
|
|
6518 |
|
|
runScript({ |
6519 |
|
|
.code = R"NKSP_CODE( |
6520 |
|
|
on init |
6521 |
|
|
exit( in_range(-0.3,-0.3,0.3) ) |
6522 |
|
|
end on |
6523 |
|
|
)NKSP_CODE", |
6524 |
|
|
.expectBoolExitResult = true |
6525 |
|
|
}); |
6526 |
|
|
|
6527 |
|
|
runScript({ |
6528 |
|
|
.code = R"NKSP_CODE( |
6529 |
|
|
on init |
6530 |
|
|
exit( in_range(0.3,-0.3,0.3) ) |
6531 |
|
|
end on |
6532 |
|
|
)NKSP_CODE", |
6533 |
|
|
.expectBoolExitResult = true |
6534 |
|
|
}); |
6535 |
|
|
|
6536 |
|
|
// mixed type tests ... |
6537 |
|
|
|
6538 |
|
|
runScript({ |
6539 |
|
|
.code = R"NKSP_CODE( |
6540 |
|
|
on init |
6541 |
|
|
exit( in_range(4.0,-5,5) ) |
6542 |
|
|
end on |
6543 |
|
|
)NKSP_CODE", |
6544 |
|
|
.expectBoolExitResult = true, |
6545 |
|
|
.expectParseWarning = true // in_range() warns if not all arguments are of same type |
6546 |
|
|
}); |
6547 |
|
|
|
6548 |
|
|
runScript({ |
6549 |
|
|
.code = R"NKSP_CODE( |
6550 |
|
|
on init |
6551 |
|
|
exit( in_range(5,-5,5.0) ) |
6552 |
|
|
end on |
6553 |
|
|
)NKSP_CODE", |
6554 |
|
|
.expectBoolExitResult = true, |
6555 |
|
|
.expectParseWarning = true // in_range() warns if not all arguments are of same type |
6556 |
|
|
}); |
6557 |
|
|
|
6558 |
|
|
runScript({ |
6559 |
|
|
.code = R"NKSP_CODE( |
6560 |
|
|
on init |
6561 |
|
|
exit( in_range(-5,-5.0,5) ) |
6562 |
|
|
end on |
6563 |
|
|
)NKSP_CODE", |
6564 |
|
|
.expectBoolExitResult = true, |
6565 |
|
|
.expectParseWarning = true // in_range() warns if not all arguments are of same type |
6566 |
|
|
}); |
6567 |
|
|
|
6568 |
|
|
// std unit tests ... |
6569 |
|
|
|
6570 |
|
|
runScript({ |
6571 |
|
|
.code = R"NKSP_CODE( |
6572 |
|
|
on init |
6573 |
|
|
exit( in_range(4000Hz,3kHz,5kHz) ) |
6574 |
|
|
end on |
6575 |
|
|
)NKSP_CODE", |
6576 |
|
|
.expectBoolExitResult = true, |
6577 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
6578 |
|
|
.expectExitResultUnit = VM_NO_UNIT |
6579 |
|
|
}); |
6580 |
|
|
|
6581 |
|
|
runScript({ |
6582 |
|
|
.code = R"NKSP_CODE( |
6583 |
|
|
on init |
6584 |
|
|
exit( in_range(5000Hz,3kHz,5kHz) ) |
6585 |
|
|
end on |
6586 |
|
|
)NKSP_CODE", |
6587 |
|
|
.expectBoolExitResult = true, |
6588 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
6589 |
|
|
.expectExitResultUnit = VM_NO_UNIT |
6590 |
|
|
}); |
6591 |
|
|
|
6592 |
|
|
runScript({ |
6593 |
|
|
.code = R"NKSP_CODE( |
6594 |
|
|
on init |
6595 |
|
|
exit( in_range(5001Hz,3kHz,5kHz) ) |
6596 |
|
|
end on |
6597 |
|
|
)NKSP_CODE", |
6598 |
|
|
.expectBoolExitResult = false, |
6599 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
6600 |
|
|
.expectExitResultUnit = VM_NO_UNIT |
6601 |
|
|
}); |
6602 |
|
|
|
6603 |
|
|
runScript({ |
6604 |
|
|
.code = R"NKSP_CODE( |
6605 |
|
|
on init |
6606 |
|
|
exit( in_range(3000Hz,3kHz,5kHz) ) |
6607 |
|
|
end on |
6608 |
|
|
)NKSP_CODE", |
6609 |
|
|
.expectBoolExitResult = true, |
6610 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
6611 |
|
|
.expectExitResultUnit = VM_NO_UNIT |
6612 |
|
|
}); |
6613 |
|
|
|
6614 |
|
|
runScript({ |
6615 |
|
|
.code = R"NKSP_CODE( |
6616 |
|
|
on init |
6617 |
|
|
exit( in_range(2999Hz,3kHz,5kHz) ) |
6618 |
|
|
end on |
6619 |
|
|
)NKSP_CODE", |
6620 |
|
|
.expectBoolExitResult = false, |
6621 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
6622 |
|
|
.expectExitResultUnit = VM_NO_UNIT |
6623 |
|
|
}); |
6624 |
|
|
|
6625 |
|
|
runScript({ |
6626 |
|
|
.code = R"NKSP_CODE( |
6627 |
|
|
on init |
6628 |
|
|
exit( in_range(0.003s,3000.0us,5ms) ) |
6629 |
|
|
end on |
6630 |
|
|
)NKSP_CODE", |
6631 |
|
|
.expectBoolExitResult = true, |
6632 |
|
|
.expectParseWarning = true, // in_range() warns if not all arguments are of same type |
6633 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
6634 |
|
|
.expectExitResultUnit = VM_NO_UNIT |
6635 |
|
|
}); |
6636 |
|
|
|
6637 |
|
|
runScript({ |
6638 |
|
|
.code = R"NKSP_CODE( |
6639 |
|
|
on init |
6640 |
|
|
exit( in_range(0.005s,3000.0us,5ms) ) |
6641 |
|
|
end on |
6642 |
|
|
)NKSP_CODE", |
6643 |
|
|
.expectBoolExitResult = true, |
6644 |
|
|
.expectParseWarning = true, // in_range() warns if not all arguments are of same type, |
6645 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
6646 |
|
|
.expectExitResultUnit = VM_NO_UNIT |
6647 |
|
|
}); |
6648 |
|
|
|
6649 |
|
|
runScript({ |
6650 |
|
|
.code = R"NKSP_CODE( |
6651 |
|
|
on init |
6652 |
|
|
exit( in_range(0.0051s,3000.0us,5ms) ) |
6653 |
|
|
end on |
6654 |
|
|
)NKSP_CODE", |
6655 |
|
|
.expectBoolExitResult = false, |
6656 |
|
|
.expectParseWarning = true, // in_range() warns if not all arguments are of same type |
6657 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
6658 |
|
|
.expectExitResultUnit = VM_NO_UNIT |
6659 |
|
|
}); |
6660 |
|
|
|
6661 |
|
|
runScript({ |
6662 |
|
|
.code = R"NKSP_CODE( |
6663 |
|
|
on init |
6664 |
|
|
exit( in_range(3s,2Hz,5Hz) ) |
6665 |
|
|
end on |
6666 |
|
|
)NKSP_CODE", |
6667 |
|
|
.expectParseError = true // in_range() throws error if not all arguments' unit types equal, |
6668 |
|
|
}); |
6669 |
|
|
|
6670 |
|
|
runScript({ |
6671 |
|
|
.code = R"NKSP_CODE( |
6672 |
|
|
on init |
6673 |
|
|
exit( in_range(3Hz,2s,5Hz) ) |
6674 |
|
|
end on |
6675 |
|
|
)NKSP_CODE", |
6676 |
|
|
.expectParseError = true // in_range() throws error if not all arguments' unit types equal |
6677 |
|
|
}); |
6678 |
|
|
|
6679 |
|
|
runScript({ |
6680 |
|
|
.code = R"NKSP_CODE( |
6681 |
|
|
on init |
6682 |
|
|
exit( in_range(3Hz,2Hz,5s) ) |
6683 |
|
|
end on |
6684 |
|
|
)NKSP_CODE", |
6685 |
|
|
.expectParseError = true // in_range() throws error if not all arguments' unit types equal |
6686 |
|
|
}); |
6687 |
|
|
|
6688 |
|
|
// 'final' ('!') operator tests ... |
6689 |
|
|
// (result should always be NOT final) |
6690 |
|
|
|
6691 |
|
|
runScript({ |
6692 |
|
|
.code = R"NKSP_CODE( |
6693 |
|
|
on init |
6694 |
|
|
exit( in_range(!9,!4,!9) ) |
6695 |
|
|
end on |
6696 |
|
|
)NKSP_CODE", |
6697 |
|
|
.expectBoolExitResult = true, |
6698 |
|
|
.expectExitResultFinal = false |
6699 |
|
|
}); |
6700 |
|
|
|
6701 |
schoenebeck |
3551 |
#if !SILENT_TEST |
6702 |
|
|
std::cout << std::endl; |
6703 |
|
|
#endif |
6704 |
|
|
} |
6705 |
|
|
|
6706 |
|
|
static void testBuiltInRandomFunction() { |
6707 |
|
|
#if !SILENT_TEST |
6708 |
|
|
std::cout << "UNIT TEST: built-in random() function\n"; |
6709 |
|
|
#endif |
6710 |
|
|
|
6711 |
schoenebeck |
3581 |
// integer tests ... |
6712 |
|
|
|
6713 |
|
|
runScript({ |
6714 |
|
|
.code = R"NKSP_CODE( |
6715 |
|
|
on init |
6716 |
|
|
exit( random(-5,5) ) |
6717 |
|
|
end on |
6718 |
|
|
)NKSP_CODE", |
6719 |
|
|
.expectExitResultIsInt = true // only check type, exact value is irrelevant here |
6720 |
|
|
}); |
6721 |
|
|
|
6722 |
schoenebeck |
3551 |
for (int run = 0; run < 20; ++run) { |
6723 |
|
|
runScript({ |
6724 |
|
|
.code = R"NKSP_CODE( |
6725 |
|
|
on init |
6726 |
|
|
declare $foo := random(-5,5) |
6727 |
|
|
exit( in_range($foo,-5,5) ) |
6728 |
|
|
end on |
6729 |
|
|
)NKSP_CODE", |
6730 |
|
|
.expectBoolExitResult = true |
6731 |
|
|
}); |
6732 |
|
|
} |
6733 |
|
|
|
6734 |
schoenebeck |
3581 |
// real number tests ... |
6735 |
|
|
|
6736 |
|
|
runScript({ |
6737 |
|
|
.code = R"NKSP_CODE( |
6738 |
|
|
on init |
6739 |
|
|
exit( random(-0.5,0.5) ) |
6740 |
|
|
end on |
6741 |
|
|
)NKSP_CODE", |
6742 |
|
|
.expectExitResultIsReal = true // only check type, exact value is irrelevant here |
6743 |
|
|
}); |
6744 |
|
|
|
6745 |
|
|
runScript({ |
6746 |
|
|
.code = R"NKSP_CODE( |
6747 |
|
|
on init |
6748 |
|
|
declare ~foo := random(-5.0,5.0) |
6749 |
|
|
exit(~foo) |
6750 |
|
|
end on |
6751 |
|
|
)NKSP_CODE", |
6752 |
|
|
.expectExitResultIsReal = true // only check type, exact value is irrelevant here |
6753 |
|
|
}); |
6754 |
|
|
|
6755 |
|
|
for (int run = 0; run < 20; ++run) { |
6756 |
|
|
runScript({ |
6757 |
|
|
.code = R"NKSP_CODE( |
6758 |
|
|
on init |
6759 |
|
|
declare ~foo := random(-0.5,0.5) |
6760 |
|
|
exit( in_range(~foo,-0.5,0.5) ) |
6761 |
|
|
end on |
6762 |
|
|
)NKSP_CODE", |
6763 |
|
|
.expectBoolExitResult = true |
6764 |
|
|
}); |
6765 |
|
|
} |
6766 |
|
|
|
6767 |
|
|
for (int run = 0; run < 20; ++run) { |
6768 |
|
|
runScript({ |
6769 |
|
|
.code = R"NKSP_CODE( |
6770 |
|
|
on init |
6771 |
|
|
declare ~foo := random(-5.0,12.0) |
6772 |
|
|
exit( in_range(~foo,-5.0,12.0) ) |
6773 |
|
|
end on |
6774 |
|
|
)NKSP_CODE", |
6775 |
|
|
.expectBoolExitResult = true |
6776 |
|
|
}); |
6777 |
|
|
} |
6778 |
|
|
|
6779 |
|
|
for (int run = 0; run < 20; ++run) { |
6780 |
|
|
runScript({ |
6781 |
|
|
.code = R"NKSP_CODE( |
6782 |
|
|
on init |
6783 |
|
|
declare ~foo := random(23.3,98.4) |
6784 |
|
|
exit( in_range(~foo,23.3,98.4) ) |
6785 |
|
|
end on |
6786 |
|
|
)NKSP_CODE", |
6787 |
|
|
.expectBoolExitResult = true |
6788 |
|
|
}); |
6789 |
|
|
} |
6790 |
|
|
|
6791 |
|
|
// std unit tests ... |
6792 |
|
|
|
6793 |
|
|
runScript({ |
6794 |
|
|
.code = R"NKSP_CODE( |
6795 |
|
|
on init |
6796 |
|
|
exit( random(-5Hz,5Hz) ) |
6797 |
|
|
end on |
6798 |
|
|
)NKSP_CODE", |
6799 |
|
|
.expectExitResultIsInt = true, // only check type, exact value is irrelevant here |
6800 |
|
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
6801 |
|
|
.expectExitResultUnit = VM_HERTZ |
6802 |
|
|
}); |
6803 |
|
|
|
6804 |
|
|
for (int run = 0; run < 20; ++run) { |
6805 |
|
|
runScript({ |
6806 |
|
|
.code = R"NKSP_CODE( |
6807 |
|
|
on init |
6808 |
|
|
declare $foo := random(-5Hz,5Hz) |
6809 |
|
|
exit( in_range($foo,-5Hz,5Hz) ) |
6810 |
|
|
end on |
6811 |
|
|
)NKSP_CODE", |
6812 |
|
|
.expectBoolExitResult = true |
6813 |
|
|
}); |
6814 |
|
|
} |
6815 |
|
|
|
6816 |
|
|
runScript({ |
6817 |
|
|
.code = R"NKSP_CODE( |
6818 |
|
|
on init |
6819 |
|
|
exit( random(5us,1ms) ) |
6820 |
|
|
end on |
6821 |
|
|
)NKSP_CODE", |
6822 |
|
|
.expectExitResultIsInt = true, // only check type, exact value is irrelevant here |
6823 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
6824 |
|
|
.expectExitResultUnit = VM_SECOND |
6825 |
|
|
}); |
6826 |
|
|
|
6827 |
|
|
for (int run = 0; run < 20; ++run) { |
6828 |
|
|
runScript({ |
6829 |
|
|
.code = R"NKSP_CODE( |
6830 |
|
|
on init |
6831 |
|
|
declare $foo := random(5us,1ms) |
6832 |
|
|
exit( in_range($foo,5us,1ms) ) |
6833 |
|
|
end on |
6834 |
|
|
)NKSP_CODE", |
6835 |
|
|
.expectBoolExitResult = true |
6836 |
|
|
}); |
6837 |
|
|
} |
6838 |
|
|
|
6839 |
|
|
runScript({ |
6840 |
|
|
.code = R"NKSP_CODE( |
6841 |
|
|
on init |
6842 |
|
|
exit( random(1ms,5000us) ) |
6843 |
|
|
end on |
6844 |
|
|
)NKSP_CODE", |
6845 |
|
|
.expectExitResultIsInt = true, // only check type, exact value is irrelevant here |
6846 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
6847 |
|
|
.expectExitResultUnit = VM_SECOND |
6848 |
|
|
}); |
6849 |
|
|
|
6850 |
|
|
for (int run = 0; run < 20; ++run) { |
6851 |
|
|
runScript({ |
6852 |
|
|
.code = R"NKSP_CODE( |
6853 |
|
|
on init |
6854 |
|
|
declare $foo := random(1ms,5000us) |
6855 |
|
|
exit( in_range($foo,1ms,5000us) ) |
6856 |
|
|
end on |
6857 |
|
|
)NKSP_CODE", |
6858 |
|
|
.expectBoolExitResult = true |
6859 |
|
|
}); |
6860 |
|
|
} |
6861 |
|
|
|
6862 |
|
|
runScript({ |
6863 |
|
|
.code = R"NKSP_CODE( |
6864 |
|
|
on init |
6865 |
|
|
exit( random(1kHz,20kHz) ) |
6866 |
|
|
end on |
6867 |
|
|
)NKSP_CODE", |
6868 |
|
|
.expectExitResultIsInt = true, // only check type, exact value is irrelevant here |
6869 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
6870 |
|
|
.expectExitResultUnit = VM_HERTZ |
6871 |
|
|
}); |
6872 |
|
|
|
6873 |
|
|
for (int run = 0; run < 20; ++run) { |
6874 |
|
|
runScript({ |
6875 |
|
|
.code = R"NKSP_CODE( |
6876 |
|
|
on init |
6877 |
|
|
declare $foo := random(1kHz,20kHz) |
6878 |
|
|
exit( in_range($foo,1kHz,20kHz) ) |
6879 |
|
|
end on |
6880 |
|
|
)NKSP_CODE", |
6881 |
|
|
.expectBoolExitResult = true |
6882 |
|
|
}); |
6883 |
|
|
} |
6884 |
|
|
|
6885 |
|
|
runScript({ |
6886 |
|
|
.code = R"NKSP_CODE( |
6887 |
|
|
on init |
6888 |
|
|
exit( random(1.2us,3.5us) ) |
6889 |
|
|
end on |
6890 |
|
|
)NKSP_CODE", |
6891 |
|
|
.expectExitResultIsReal = true, // only check type, exact value is irrelevant here |
6892 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
6893 |
|
|
.expectExitResultUnit = VM_SECOND |
6894 |
|
|
}); |
6895 |
|
|
|
6896 |
|
|
for (int run = 0; run < 20; ++run) { |
6897 |
|
|
runScript({ |
6898 |
|
|
.code = R"NKSP_CODE( |
6899 |
|
|
on init |
6900 |
|
|
declare ~foo := random(1.2us,3.5us) |
6901 |
|
|
exit( in_range(~foo,1.2us,3.5us) ) |
6902 |
|
|
end on |
6903 |
|
|
)NKSP_CODE", |
6904 |
|
|
.expectBoolExitResult = true |
6905 |
|
|
}); |
6906 |
|
|
} |
6907 |
|
|
|
6908 |
|
|
runScript({ |
6909 |
|
|
.code = R"NKSP_CODE( |
6910 |
|
|
on init |
6911 |
|
|
exit( random(5.2us,1.1ms) ) |
6912 |
|
|
end on |
6913 |
|
|
)NKSP_CODE", |
6914 |
|
|
.expectExitResultIsReal = true, // only check type, exact value is irrelevant here |
6915 |
|
|
.expectExitResultUnitPrefix = { VM_MICRO }, |
6916 |
|
|
.expectExitResultUnit = VM_SECOND |
6917 |
|
|
}); |
6918 |
|
|
|
6919 |
|
|
for (int run = 0; run < 20; ++run) { |
6920 |
|
|
runScript({ |
6921 |
|
|
.code = R"NKSP_CODE( |
6922 |
|
|
on init |
6923 |
|
|
declare ~foo := random(5.2us,1.1ms) |
6924 |
|
|
exit( in_range(~foo,5.2us,1.1ms) ) |
6925 |
|
|
end on |
6926 |
|
|
)NKSP_CODE", |
6927 |
|
|
.expectBoolExitResult = true |
6928 |
|
|
}); |
6929 |
|
|
} |
6930 |
|
|
|
6931 |
|
|
runScript({ |
6932 |
|
|
.code = R"NKSP_CODE( |
6933 |
|
|
on init |
6934 |
|
|
exit( random(1Hz,12s) ) |
6935 |
|
|
end on |
6936 |
|
|
)NKSP_CODE", |
6937 |
|
|
.expectParseError = true // random() throws error if arguments' unit types don't match |
6938 |
|
|
}); |
6939 |
|
|
|
6940 |
|
|
runScript({ |
6941 |
|
|
.code = R"NKSP_CODE( |
6942 |
|
|
on init |
6943 |
|
|
exit( random(1,12s) ) |
6944 |
|
|
end on |
6945 |
|
|
)NKSP_CODE", |
6946 |
|
|
.expectParseError = true // random() throws error if arguments' unit types don't match |
6947 |
|
|
}); |
6948 |
|
|
|
6949 |
|
|
runScript({ |
6950 |
|
|
.code = R"NKSP_CODE( |
6951 |
|
|
on init |
6952 |
|
|
exit( random(1s,12) ) |
6953 |
|
|
end on |
6954 |
|
|
)NKSP_CODE", |
6955 |
|
|
.expectParseError = true // random() throws error if arguments' unit types don't match |
6956 |
|
|
}); |
6957 |
|
|
|
6958 |
|
|
// 'final' ('!') operator tests ... |
6959 |
|
|
|
6960 |
|
|
runScript({ |
6961 |
|
|
.code = R"NKSP_CODE( |
6962 |
|
|
on init |
6963 |
|
|
exit( random(!1,!12) ) |
6964 |
|
|
end on |
6965 |
|
|
)NKSP_CODE", |
6966 |
|
|
.expectExitResultFinal = true |
6967 |
|
|
}); |
6968 |
|
|
|
6969 |
|
|
runScript({ |
6970 |
|
|
.code = R"NKSP_CODE( |
6971 |
|
|
on init |
6972 |
|
|
exit( random(1,12) ) |
6973 |
|
|
end on |
6974 |
|
|
)NKSP_CODE", |
6975 |
|
|
.expectExitResultFinal = false |
6976 |
|
|
}); |
6977 |
|
|
|
6978 |
|
|
runScript({ |
6979 |
|
|
.code = R"NKSP_CODE( |
6980 |
|
|
on init |
6981 |
|
|
exit( random(!1,12) ) |
6982 |
|
|
end on |
6983 |
|
|
)NKSP_CODE", |
6984 |
|
|
.expectExitResultFinal = true, |
6985 |
|
|
.expectParseWarning = true // random() warns if only one argument is 'final' |
6986 |
|
|
}); |
6987 |
|
|
|
6988 |
|
|
runScript({ |
6989 |
|
|
.code = R"NKSP_CODE( |
6990 |
|
|
on init |
6991 |
|
|
exit( random(1,!12) ) |
6992 |
|
|
end on |
6993 |
|
|
)NKSP_CODE", |
6994 |
|
|
.expectExitResultFinal = true, |
6995 |
|
|
.expectParseWarning = true // random() warns if only one argument is 'final' |
6996 |
|
|
}); |
6997 |
|
|
|
6998 |
schoenebeck |
3551 |
#if !SILENT_TEST |
6999 |
|
|
std::cout << std::endl; |
7000 |
|
|
#endif |
7001 |
|
|
} |
7002 |
|
|
|
7003 |
|
|
static void testBuiltInShiftLeftFunction() { |
7004 |
|
|
#if !SILENT_TEST |
7005 |
|
|
std::cout << "UNIT TEST: built-in sh_left() function\n"; |
7006 |
|
|
#endif |
7007 |
|
|
|
7008 |
|
|
runScript({ |
7009 |
|
|
.code = R"NKSP_CODE( |
7010 |
|
|
on init |
7011 |
|
|
exit( sh_left(1,0) ) |
7012 |
|
|
end on |
7013 |
|
|
)NKSP_CODE", |
7014 |
|
|
.expectIntExitResult = 1 |
7015 |
|
|
}); |
7016 |
|
|
|
7017 |
|
|
runScript({ |
7018 |
|
|
.code = R"NKSP_CODE( |
7019 |
|
|
on init |
7020 |
|
|
exit( sh_left(1,1) ) |
7021 |
|
|
end on |
7022 |
|
|
)NKSP_CODE", |
7023 |
|
|
.expectIntExitResult = 2 |
7024 |
|
|
}); |
7025 |
|
|
|
7026 |
|
|
runScript({ |
7027 |
|
|
.code = R"NKSP_CODE( |
7028 |
|
|
on init |
7029 |
|
|
exit( sh_left(1,2) ) |
7030 |
|
|
end on |
7031 |
|
|
)NKSP_CODE", |
7032 |
|
|
.expectIntExitResult = 4 |
7033 |
|
|
}); |
7034 |
|
|
|
7035 |
|
|
runScript({ |
7036 |
|
|
.code = R"NKSP_CODE( |
7037 |
|
|
on init |
7038 |
|
|
exit( sh_left(1,3) ) |
7039 |
|
|
end on |
7040 |
|
|
)NKSP_CODE", |
7041 |
|
|
.expectIntExitResult = 8 |
7042 |
|
|
}); |
7043 |
|
|
|
7044 |
|
|
#if !SILENT_TEST |
7045 |
|
|
std::cout << std::endl; |
7046 |
|
|
#endif |
7047 |
|
|
} |
7048 |
|
|
|
7049 |
|
|
static void testBuiltInShiftRightFunction() { |
7050 |
|
|
#if !SILENT_TEST |
7051 |
|
|
std::cout << "UNIT TEST: built-in sh_right() function\n"; |
7052 |
|
|
#endif |
7053 |
|
|
|
7054 |
|
|
runScript({ |
7055 |
|
|
.code = R"NKSP_CODE( |
7056 |
|
|
on init |
7057 |
|
|
exit( sh_right(8,0) ) |
7058 |
|
|
end on |
7059 |
|
|
)NKSP_CODE", |
7060 |
|
|
.expectIntExitResult = 8 |
7061 |
|
|
}); |
7062 |
|
|
|
7063 |
|
|
runScript({ |
7064 |
|
|
.code = R"NKSP_CODE( |
7065 |
|
|
on init |
7066 |
|
|
exit( sh_right(8,1) ) |
7067 |
|
|
end on |
7068 |
|
|
)NKSP_CODE", |
7069 |
|
|
.expectIntExitResult = 4 |
7070 |
|
|
}); |
7071 |
|
|
|
7072 |
|
|
runScript({ |
7073 |
|
|
.code = R"NKSP_CODE( |
7074 |
|
|
on init |
7075 |
|
|
exit( sh_right(8,2) ) |
7076 |
|
|
end on |
7077 |
|
|
)NKSP_CODE", |
7078 |
|
|
.expectIntExitResult = 2 |
7079 |
|
|
}); |
7080 |
|
|
|
7081 |
|
|
runScript({ |
7082 |
|
|
.code = R"NKSP_CODE( |
7083 |
|
|
on init |
7084 |
|
|
exit( sh_right(8,3) ) |
7085 |
|
|
end on |
7086 |
|
|
)NKSP_CODE", |
7087 |
|
|
.expectIntExitResult = 1 |
7088 |
|
|
}); |
7089 |
|
|
|
7090 |
|
|
runScript({ |
7091 |
|
|
.code = R"NKSP_CODE( |
7092 |
|
|
on init |
7093 |
|
|
exit( sh_right(8,4) ) |
7094 |
|
|
end on |
7095 |
|
|
)NKSP_CODE", |
7096 |
|
|
.expectIntExitResult = 0 |
7097 |
|
|
}); |
7098 |
|
|
|
7099 |
|
|
#if !SILENT_TEST |
7100 |
|
|
std::cout << std::endl; |
7101 |
|
|
#endif |
7102 |
|
|
} |
7103 |
|
|
|
7104 |
schoenebeck |
3575 |
static void testBuiltInIntToRealFunction() { |
7105 |
|
|
#if !SILENT_TEST |
7106 |
|
|
std::cout << "UNIT TEST: built-in int_to_real() function\n"; |
7107 |
|
|
#endif |
7108 |
|
|
|
7109 |
|
|
runScript({ |
7110 |
|
|
.code = R"NKSP_CODE( |
7111 |
|
|
on init |
7112 |
|
|
exit( int_to_real(8) ) |
7113 |
|
|
end on |
7114 |
|
|
)NKSP_CODE", |
7115 |
|
|
.expectRealExitResult = 8.0 |
7116 |
|
|
}); |
7117 |
|
|
|
7118 |
|
|
runScript({ |
7119 |
|
|
.code = R"NKSP_CODE( |
7120 |
|
|
on init |
7121 |
|
|
declare $foo := 23 |
7122 |
|
|
exit( int_to_real($foo) ) |
7123 |
|
|
end on |
7124 |
|
|
)NKSP_CODE", |
7125 |
|
|
.expectRealExitResult = 23.0 |
7126 |
|
|
}); |
7127 |
|
|
|
7128 |
schoenebeck |
3581 |
// std unit tests ... |
7129 |
|
|
|
7130 |
|
|
runScript({ |
7131 |
|
|
.code = R"NKSP_CODE( |
7132 |
|
|
on init |
7133 |
|
|
exit( int_to_real(-58mdB) ) |
7134 |
|
|
end on |
7135 |
|
|
)NKSP_CODE", |
7136 |
|
|
.expectRealExitResult = -58.0, |
7137 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
7138 |
|
|
.expectExitResultUnit = VM_BEL |
7139 |
|
|
}); |
7140 |
|
|
|
7141 |
|
|
runScript({ |
7142 |
|
|
.code = R"NKSP_CODE( |
7143 |
|
|
on init |
7144 |
|
|
declare $foo := -58mdB |
7145 |
|
|
exit( int_to_real($foo) ) |
7146 |
|
|
end on |
7147 |
|
|
)NKSP_CODE", |
7148 |
|
|
.expectRealExitResult = -58.0, |
7149 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
7150 |
|
|
.expectExitResultUnit = VM_BEL |
7151 |
|
|
}); |
7152 |
|
|
|
7153 |
|
|
// 'final' ('!') operator tests ... |
7154 |
|
|
|
7155 |
|
|
runScript({ |
7156 |
|
|
.code = R"NKSP_CODE( |
7157 |
|
|
on init |
7158 |
|
|
declare $foo := !-58 |
7159 |
|
|
exit( int_to_real($foo) ) |
7160 |
|
|
end on |
7161 |
|
|
)NKSP_CODE", |
7162 |
|
|
.expectRealExitResult = -58.0, |
7163 |
|
|
.expectExitResultFinal = true |
7164 |
|
|
}); |
7165 |
|
|
|
7166 |
|
|
runScript({ |
7167 |
|
|
.code = R"NKSP_CODE( |
7168 |
|
|
on init |
7169 |
|
|
declare $foo := -58 |
7170 |
|
|
exit( int_to_real($foo) ) |
7171 |
|
|
end on |
7172 |
|
|
)NKSP_CODE", |
7173 |
|
|
.expectRealExitResult = -58.0, |
7174 |
|
|
.expectExitResultFinal = false |
7175 |
|
|
}); |
7176 |
|
|
|
7177 |
schoenebeck |
3575 |
#if !SILENT_TEST |
7178 |
|
|
std::cout << std::endl; |
7179 |
|
|
#endif |
7180 |
|
|
} |
7181 |
|
|
|
7182 |
|
|
static void testBuiltInRealFunction() { |
7183 |
|
|
#if !SILENT_TEST |
7184 |
|
|
std::cout << "UNIT TEST: built-in real() function\n"; |
7185 |
|
|
#endif |
7186 |
|
|
|
7187 |
|
|
runScript({ |
7188 |
|
|
.code = R"NKSP_CODE( |
7189 |
|
|
on init |
7190 |
|
|
exit( real(8) ) |
7191 |
|
|
end on |
7192 |
|
|
)NKSP_CODE", |
7193 |
|
|
.expectRealExitResult = 8.0 |
7194 |
|
|
}); |
7195 |
|
|
|
7196 |
|
|
runScript({ |
7197 |
|
|
.code = R"NKSP_CODE( |
7198 |
|
|
on init |
7199 |
|
|
declare $foo := 23 |
7200 |
|
|
exit( real($foo) ) |
7201 |
|
|
end on |
7202 |
|
|
)NKSP_CODE", |
7203 |
|
|
.expectRealExitResult = 23.0 |
7204 |
|
|
}); |
7205 |
|
|
|
7206 |
schoenebeck |
3581 |
// std unit tests ... |
7207 |
|
|
|
7208 |
|
|
runScript({ |
7209 |
|
|
.code = R"NKSP_CODE( |
7210 |
|
|
on init |
7211 |
|
|
exit( real(-58mdB) ) |
7212 |
|
|
end on |
7213 |
|
|
)NKSP_CODE", |
7214 |
|
|
.expectRealExitResult = -58.0, |
7215 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
7216 |
|
|
.expectExitResultUnit = VM_BEL |
7217 |
|
|
}); |
7218 |
|
|
|
7219 |
|
|
runScript({ |
7220 |
|
|
.code = R"NKSP_CODE( |
7221 |
|
|
on init |
7222 |
|
|
declare $foo := -58mdB |
7223 |
|
|
exit( real($foo) ) |
7224 |
|
|
end on |
7225 |
|
|
)NKSP_CODE", |
7226 |
|
|
.expectRealExitResult = -58.0, |
7227 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
7228 |
|
|
.expectExitResultUnit = VM_BEL |
7229 |
|
|
}); |
7230 |
|
|
|
7231 |
|
|
// 'final' ('!') operator tests ... |
7232 |
|
|
|
7233 |
|
|
runScript({ |
7234 |
|
|
.code = R"NKSP_CODE( |
7235 |
|
|
on init |
7236 |
|
|
declare $foo := !-58 |
7237 |
|
|
exit( real($foo) ) |
7238 |
|
|
end on |
7239 |
|
|
)NKSP_CODE", |
7240 |
|
|
.expectRealExitResult = -58.0, |
7241 |
|
|
.expectExitResultFinal = true |
7242 |
|
|
}); |
7243 |
|
|
|
7244 |
|
|
runScript({ |
7245 |
|
|
.code = R"NKSP_CODE( |
7246 |
|
|
on init |
7247 |
|
|
declare $foo := -58 |
7248 |
|
|
exit( real($foo) ) |
7249 |
|
|
end on |
7250 |
|
|
)NKSP_CODE", |
7251 |
|
|
.expectRealExitResult = -58.0, |
7252 |
|
|
.expectExitResultFinal = false |
7253 |
|
|
}); |
7254 |
|
|
|
7255 |
schoenebeck |
3575 |
#if !SILENT_TEST |
7256 |
|
|
std::cout << std::endl; |
7257 |
|
|
#endif |
7258 |
|
|
} |
7259 |
|
|
|
7260 |
|
|
static void testBuiltInRealToIntFunction() { |
7261 |
|
|
#if !SILENT_TEST |
7262 |
|
|
std::cout << "UNIT TEST: built-in real_to_int() function\n"; |
7263 |
|
|
#endif |
7264 |
|
|
|
7265 |
|
|
runScript({ |
7266 |
|
|
.code = R"NKSP_CODE( |
7267 |
|
|
on init |
7268 |
|
|
exit( real_to_int(8.9) ) |
7269 |
|
|
end on |
7270 |
|
|
)NKSP_CODE", |
7271 |
|
|
.expectIntExitResult = 8 |
7272 |
|
|
}); |
7273 |
|
|
|
7274 |
|
|
runScript({ |
7275 |
|
|
.code = R"NKSP_CODE( |
7276 |
|
|
on init |
7277 |
|
|
declare ~foo := 8.9 |
7278 |
|
|
exit( real_to_int(~foo) ) |
7279 |
|
|
end on |
7280 |
|
|
)NKSP_CODE", |
7281 |
|
|
.expectIntExitResult = 8 |
7282 |
|
|
}); |
7283 |
|
|
|
7284 |
schoenebeck |
3581 |
// std unit tests ... |
7285 |
|
|
|
7286 |
|
|
runScript({ |
7287 |
|
|
.code = R"NKSP_CODE( |
7288 |
|
|
on init |
7289 |
|
|
declare ~foo := 8.9mdB |
7290 |
|
|
exit( real_to_int(~foo) ) |
7291 |
|
|
end on |
7292 |
|
|
)NKSP_CODE", |
7293 |
|
|
.expectIntExitResult = 8, |
7294 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
7295 |
|
|
.expectExitResultUnit = VM_BEL |
7296 |
|
|
}); |
7297 |
|
|
|
7298 |
|
|
// 'final' ('!') operator tests ... |
7299 |
|
|
|
7300 |
|
|
runScript({ |
7301 |
|
|
.code = R"NKSP_CODE( |
7302 |
|
|
on init |
7303 |
|
|
declare ~foo := !8.9 |
7304 |
|
|
exit( real_to_int(~foo) ) |
7305 |
|
|
end on |
7306 |
|
|
)NKSP_CODE", |
7307 |
|
|
.expectIntExitResult = 8, |
7308 |
|
|
.expectExitResultFinal = true |
7309 |
|
|
}); |
7310 |
|
|
|
7311 |
|
|
runScript({ |
7312 |
|
|
.code = R"NKSP_CODE( |
7313 |
|
|
on init |
7314 |
|
|
declare ~foo := 8.9 |
7315 |
|
|
exit( real_to_int(~foo) ) |
7316 |
|
|
end on |
7317 |
|
|
)NKSP_CODE", |
7318 |
|
|
.expectIntExitResult = 8, |
7319 |
|
|
.expectExitResultFinal = false |
7320 |
|
|
}); |
7321 |
|
|
|
7322 |
schoenebeck |
3575 |
#if !SILENT_TEST |
7323 |
|
|
std::cout << std::endl; |
7324 |
|
|
#endif |
7325 |
|
|
} |
7326 |
|
|
|
7327 |
|
|
static void testBuiltInIntFunction() { |
7328 |
|
|
#if !SILENT_TEST |
7329 |
|
|
std::cout << "UNIT TEST: built-in int() function\n"; |
7330 |
|
|
#endif |
7331 |
|
|
|
7332 |
|
|
runScript({ |
7333 |
|
|
.code = R"NKSP_CODE( |
7334 |
|
|
on init |
7335 |
|
|
exit( int(8.9) ) |
7336 |
|
|
end on |
7337 |
|
|
)NKSP_CODE", |
7338 |
|
|
.expectIntExitResult = 8 |
7339 |
|
|
}); |
7340 |
|
|
|
7341 |
|
|
runScript({ |
7342 |
|
|
.code = R"NKSP_CODE( |
7343 |
|
|
on init |
7344 |
|
|
declare ~foo := 8.9 |
7345 |
|
|
exit( int(~foo) ) |
7346 |
|
|
end on |
7347 |
|
|
)NKSP_CODE", |
7348 |
|
|
.expectIntExitResult = 8 |
7349 |
|
|
}); |
7350 |
|
|
|
7351 |
schoenebeck |
3581 |
// std unit tests ... |
7352 |
|
|
|
7353 |
|
|
runScript({ |
7354 |
|
|
.code = R"NKSP_CODE( |
7355 |
|
|
on init |
7356 |
|
|
declare ~foo := 8.9mdB |
7357 |
|
|
exit( int(~foo) ) |
7358 |
|
|
end on |
7359 |
|
|
)NKSP_CODE", |
7360 |
|
|
.expectIntExitResult = 8, |
7361 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI, VM_DECI }, |
7362 |
|
|
.expectExitResultUnit = VM_BEL |
7363 |
|
|
}); |
7364 |
|
|
|
7365 |
|
|
// 'final' ('!') operator tests ... |
7366 |
|
|
|
7367 |
|
|
runScript({ |
7368 |
|
|
.code = R"NKSP_CODE( |
7369 |
|
|
on init |
7370 |
|
|
declare ~foo := !8.9 |
7371 |
|
|
exit( int(~foo) ) |
7372 |
|
|
end on |
7373 |
|
|
)NKSP_CODE", |
7374 |
|
|
.expectIntExitResult = 8, |
7375 |
|
|
.expectExitResultFinal = true |
7376 |
|
|
}); |
7377 |
|
|
|
7378 |
|
|
runScript({ |
7379 |
|
|
.code = R"NKSP_CODE( |
7380 |
|
|
on init |
7381 |
|
|
declare ~foo := 8.9 |
7382 |
|
|
exit( int(~foo) ) |
7383 |
|
|
end on |
7384 |
|
|
)NKSP_CODE", |
7385 |
|
|
.expectIntExitResult = 8, |
7386 |
|
|
.expectExitResultFinal = false |
7387 |
|
|
}); |
7388 |
|
|
|
7389 |
schoenebeck |
3575 |
#if !SILENT_TEST |
7390 |
|
|
std::cout << std::endl; |
7391 |
|
|
#endif |
7392 |
|
|
} |
7393 |
|
|
|
7394 |
schoenebeck |
3551 |
static void testBuiltInArrayEqualFunction() { |
7395 |
|
|
#if !SILENT_TEST |
7396 |
|
|
std::cout << "UNIT TEST: built-in array_equal() function\n"; |
7397 |
|
|
#endif |
7398 |
|
|
|
7399 |
schoenebeck |
3581 |
// integer array tests ... |
7400 |
|
|
|
7401 |
schoenebeck |
3551 |
runScript({ |
7402 |
|
|
.code = R"NKSP_CODE( |
7403 |
|
|
on init |
7404 |
|
|
declare %foo[3] := ( 1, 2, 3 ) |
7405 |
|
|
declare %bar[3] := ( 1, 2, 3 ) |
7406 |
|
|
exit( array_equal(%foo, %bar) ) |
7407 |
|
|
end on |
7408 |
|
|
)NKSP_CODE", |
7409 |
|
|
.expectBoolExitResult = true |
7410 |
|
|
}); |
7411 |
|
|
|
7412 |
|
|
runScript({ |
7413 |
|
|
.code = R"NKSP_CODE( |
7414 |
|
|
on init |
7415 |
|
|
declare %foo[1] := ( 1 ) |
7416 |
|
|
declare %bar[1] := ( 1 ) |
7417 |
|
|
exit( array_equal(%foo, %bar) ) |
7418 |
|
|
end on |
7419 |
|
|
)NKSP_CODE", |
7420 |
|
|
.expectBoolExitResult = true |
7421 |
|
|
}); |
7422 |
|
|
|
7423 |
|
|
runScript({ |
7424 |
|
|
.code = R"NKSP_CODE( |
7425 |
|
|
on init |
7426 |
|
|
declare %foo[3] := ( 1, 2, 3 ) |
7427 |
|
|
declare %bar[3] := ( 0, 2, 3 ) |
7428 |
|
|
exit( array_equal(%foo, %bar) ) |
7429 |
|
|
end on |
7430 |
|
|
)NKSP_CODE", |
7431 |
|
|
.expectBoolExitResult = false |
7432 |
|
|
}); |
7433 |
|
|
|
7434 |
|
|
runScript({ |
7435 |
|
|
.code = R"NKSP_CODE( |
7436 |
|
|
on init |
7437 |
|
|
declare %foo[3] := ( 1, 2, 3 ) |
7438 |
|
|
declare %bar[3] := ( 3, 2, 1 ) |
7439 |
|
|
exit( array_equal(%foo, %bar) ) |
7440 |
|
|
end on |
7441 |
|
|
)NKSP_CODE", |
7442 |
|
|
.expectBoolExitResult = false |
7443 |
|
|
}); |
7444 |
|
|
|
7445 |
|
|
runScript({ |
7446 |
|
|
.code = R"NKSP_CODE( |
7447 |
|
|
on init |
7448 |
|
|
declare %foo[3] := ( 1, 2, 3 ) |
7449 |
|
|
declare %bar[2] := ( 1, 2 ) |
7450 |
|
|
exit( array_equal(%foo, %bar) ) |
7451 |
|
|
end on |
7452 |
|
|
)NKSP_CODE", |
7453 |
schoenebeck |
3581 |
.expectBoolExitResult = false, |
7454 |
|
|
.expectParseWarning = true // array_equal() warns if array sizes do not match |
7455 |
|
|
}); |
7456 |
|
|
|
7457 |
|
|
// real number array tests ... |
7458 |
|
|
|
7459 |
|
|
runScript({ |
7460 |
|
|
.code = R"NKSP_CODE( |
7461 |
|
|
on init |
7462 |
|
|
declare ?foo[3] := ( 1.0, 2.0, 3.0 ) |
7463 |
|
|
declare ?bar[3] := ( 1.0, 2.0, 3.0 ) |
7464 |
|
|
exit( array_equal(?foo, ?bar) ) |
7465 |
|
|
end on |
7466 |
|
|
)NKSP_CODE", |
7467 |
|
|
.expectBoolExitResult = true |
7468 |
|
|
}); |
7469 |
|
|
|
7470 |
|
|
runScript({ |
7471 |
|
|
.code = R"NKSP_CODE( |
7472 |
|
|
on init |
7473 |
|
|
declare ?foo[3] := ( 1.0, 1.1, 3.4 ) |
7474 |
|
|
declare ?bar[3] := ( 1.0, 1.1, 3.4 ) |
7475 |
|
|
exit( array_equal(?foo, ?bar) ) |
7476 |
|
|
end on |
7477 |
|
|
)NKSP_CODE", |
7478 |
|
|
.expectBoolExitResult = true |
7479 |
|
|
}); |
7480 |
|
|
|
7481 |
|
|
runScript({ |
7482 |
|
|
.code = R"NKSP_CODE( |
7483 |
|
|
on init |
7484 |
|
|
declare ?foo[3] := ( 1.0, 1.1, 3.4 ) |
7485 |
|
|
declare ?bar[3] := ( 1.0, 1.2, 3.4 ) |
7486 |
|
|
exit( array_equal(?foo, ?bar) ) |
7487 |
|
|
end on |
7488 |
|
|
)NKSP_CODE", |
7489 |
schoenebeck |
3551 |
.expectBoolExitResult = false |
7490 |
|
|
}); |
7491 |
|
|
|
7492 |
schoenebeck |
3581 |
runScript({ |
7493 |
|
|
.code = R"NKSP_CODE( |
7494 |
|
|
on init |
7495 |
|
|
declare ?foo[3] := ( 1.0, 1.1, 3.4 ) |
7496 |
|
|
declare ?bar[2] := ( 1.0, 1.1 ) |
7497 |
|
|
exit( array_equal(?foo, ?bar) ) |
7498 |
|
|
end on |
7499 |
|
|
)NKSP_CODE", |
7500 |
|
|
.expectBoolExitResult = false, |
7501 |
|
|
.expectParseWarning = true // array_equal() warns if array sizes do not match |
7502 |
|
|
}); |
7503 |
|
|
|
7504 |
|
|
// std unit tests ... |
7505 |
|
|
// (only metric prefixes allowed, unit types are prohibited for arrays ATM) |
7506 |
|
|
|
7507 |
|
|
runScript({ |
7508 |
|
|
.code = R"NKSP_CODE( |
7509 |
|
|
on init |
7510 |
|
|
declare %foo[3] := ( 1, 1s, 1 ) |
7511 |
|
|
declare %bar[3] := ( 1, 1, 1 ) |
7512 |
|
|
exit( array_equal(%foo, %bar) ) |
7513 |
|
|
end on |
7514 |
|
|
)NKSP_CODE", |
7515 |
|
|
.expectParseError = true // see comment above |
7516 |
|
|
}); |
7517 |
|
|
|
7518 |
|
|
runScript({ |
7519 |
|
|
.code = R"NKSP_CODE( |
7520 |
|
|
on init |
7521 |
|
|
declare %foo[3] := ( 1k, 1, 1m ) |
7522 |
|
|
declare %bar[3] := ( 1k, 1, 1m ) |
7523 |
|
|
exit( array_equal(%foo, %bar) ) |
7524 |
|
|
end on |
7525 |
|
|
)NKSP_CODE", |
7526 |
|
|
.expectBoolExitResult = true |
7527 |
|
|
}); |
7528 |
|
|
|
7529 |
|
|
runScript({ |
7530 |
|
|
.code = R"NKSP_CODE( |
7531 |
|
|
on init |
7532 |
|
|
declare %foo[3] := ( 1m, 1, 1k ) |
7533 |
|
|
declare %bar[3] := ( 1k, 1, 1m ) |
7534 |
|
|
exit( array_equal(%foo, %bar) ) |
7535 |
|
|
end on |
7536 |
|
|
)NKSP_CODE", |
7537 |
|
|
.expectBoolExitResult = false |
7538 |
|
|
}); |
7539 |
|
|
|
7540 |
|
|
runScript({ |
7541 |
|
|
.code = R"NKSP_CODE( |
7542 |
|
|
on init |
7543 |
|
|
declare %foo[3] := ( 1, 1k, 1 ) |
7544 |
|
|
declare %bar[3] := ( 1, 1, 1 ) |
7545 |
|
|
exit( array_equal(%foo, %bar) ) |
7546 |
|
|
end on |
7547 |
|
|
)NKSP_CODE", |
7548 |
|
|
.expectBoolExitResult = false |
7549 |
|
|
}); |
7550 |
|
|
|
7551 |
|
|
runScript({ |
7552 |
|
|
.code = R"NKSP_CODE( |
7553 |
|
|
on init |
7554 |
|
|
declare %foo[3] := ( 1, 1k, 1 ) |
7555 |
|
|
declare %bar[3] := ( 1, 1000, 1 ) |
7556 |
|
|
exit( array_equal(%foo, %bar) ) |
7557 |
|
|
end on |
7558 |
|
|
)NKSP_CODE", |
7559 |
|
|
.expectBoolExitResult = true |
7560 |
|
|
}); |
7561 |
|
|
|
7562 |
|
|
runScript({ |
7563 |
|
|
.code = R"NKSP_CODE( |
7564 |
|
|
on init |
7565 |
|
|
declare %foo[3] := ( 1, 2, 3000 ) |
7566 |
|
|
declare %bar[3] := ( 1, 2, 3k ) |
7567 |
|
|
exit( array_equal(%foo, %bar) ) |
7568 |
|
|
end on |
7569 |
|
|
)NKSP_CODE", |
7570 |
|
|
.expectBoolExitResult = true |
7571 |
|
|
}); |
7572 |
|
|
|
7573 |
|
|
runScript({ |
7574 |
|
|
.code = R"NKSP_CODE( |
7575 |
|
|
on init |
7576 |
|
|
declare %foo[3] := ( 1, 2, 3m ) |
7577 |
|
|
declare %bar[3] := ( 1, 2, 3k ) |
7578 |
|
|
exit( array_equal(%foo, %bar) ) |
7579 |
|
|
end on |
7580 |
|
|
)NKSP_CODE", |
7581 |
|
|
.expectBoolExitResult = false |
7582 |
|
|
}); |
7583 |
|
|
|
7584 |
|
|
runScript({ |
7585 |
|
|
.code = R"NKSP_CODE( |
7586 |
|
|
on init |
7587 |
|
|
declare ?foo[4] := ( 1.0, 1.0m, 1.1m, 3.4k ) |
7588 |
|
|
declare ?bar[4] := ( 1.0, 1.0m, 1.1m, 3.4k ) |
7589 |
|
|
exit( array_equal(?foo, ?bar) ) |
7590 |
|
|
end on |
7591 |
|
|
)NKSP_CODE", |
7592 |
|
|
.expectBoolExitResult = true |
7593 |
|
|
}); |
7594 |
|
|
|
7595 |
|
|
runScript({ |
7596 |
|
|
.code = R"NKSP_CODE( |
7597 |
|
|
on init |
7598 |
|
|
declare ?foo[4] := ( 1.0, 1.0m, 1.1m, 3.4k ) |
7599 |
|
|
declare ?bar[4] := ( 1.0, 1.0 , 1.1m, 3.4k ) |
7600 |
|
|
exit( array_equal(?foo, ?bar) ) |
7601 |
|
|
end on |
7602 |
|
|
)NKSP_CODE", |
7603 |
|
|
.expectBoolExitResult = false |
7604 |
|
|
}); |
7605 |
|
|
|
7606 |
|
|
runScript({ |
7607 |
|
|
.code = R"NKSP_CODE( |
7608 |
|
|
on init |
7609 |
|
|
declare ?foo[4] := ( 1.0, 1.0m, 1.1m, 3.4k ) |
7610 |
|
|
declare ?bar[4] := ( 1.0, 1.0m, 1.1k, 3.4k ) |
7611 |
|
|
exit( array_equal(?foo, ?bar) ) |
7612 |
|
|
end on |
7613 |
|
|
)NKSP_CODE", |
7614 |
|
|
.expectBoolExitResult = false |
7615 |
|
|
}); |
7616 |
|
|
|
7617 |
|
|
runScript({ |
7618 |
|
|
.code = R"NKSP_CODE( |
7619 |
|
|
on init |
7620 |
|
|
declare ?foo[4] := ( 1.0, 1.0m, 1.1m, 3.4k ) |
7621 |
|
|
declare ?bar[4] := ( 1.0, 1.0m, 1.1m, 3.4u ) |
7622 |
|
|
exit( array_equal(?foo, ?bar) ) |
7623 |
|
|
end on |
7624 |
|
|
)NKSP_CODE", |
7625 |
|
|
.expectBoolExitResult = false |
7626 |
|
|
}); |
7627 |
|
|
|
7628 |
|
|
runScript({ |
7629 |
|
|
.code = R"NKSP_CODE( |
7630 |
|
|
on init |
7631 |
|
|
declare ?foo[3] := ( 1.0, 1.0k, 1.1m ) |
7632 |
|
|
declare ?bar[3] := ( 1.0, 1000.0, 1.1m ) |
7633 |
|
|
exit( array_equal(?foo, ?bar) ) |
7634 |
|
|
end on |
7635 |
|
|
)NKSP_CODE", |
7636 |
|
|
.expectBoolExitResult = true |
7637 |
|
|
}); |
7638 |
|
|
|
7639 |
|
|
runScript({ |
7640 |
|
|
.code = R"NKSP_CODE( |
7641 |
|
|
on init |
7642 |
|
|
declare ?foo[3] := ( 1.0, 1.0k, 1.1u ) |
7643 |
|
|
declare ?bar[3] := ( 1.0, 1000.0, 0.0011m ) |
7644 |
|
|
exit( array_equal(?foo, ?bar) ) |
7645 |
|
|
end on |
7646 |
|
|
)NKSP_CODE", |
7647 |
|
|
.expectBoolExitResult = true |
7648 |
|
|
}); |
7649 |
|
|
|
7650 |
|
|
runScript({ |
7651 |
|
|
.code = R"NKSP_CODE( |
7652 |
|
|
on init |
7653 |
|
|
declare ?foo[3] := ( 1.0, 1.0k, 1.1u ) |
7654 |
|
|
declare ?bar[3] := ( 1.0, 1000.0, 0.0016m ) |
7655 |
|
|
exit( array_equal(?foo, ?bar) ) |
7656 |
|
|
end on |
7657 |
|
|
)NKSP_CODE", |
7658 |
|
|
.expectBoolExitResult = false |
7659 |
|
|
}); |
7660 |
|
|
|
7661 |
|
|
// 'final' ('!') operator tests ... |
7662 |
|
|
// (currently prohibited for arrays) |
7663 |
|
|
|
7664 |
|
|
runScript({ |
7665 |
|
|
.code = R"NKSP_CODE( |
7666 |
|
|
on init |
7667 |
|
|
declare %foo[3] := ( !1, !1, !1 ) |
7668 |
|
|
declare %bar[3] := ( !1, !1, !1 ) |
7669 |
|
|
exit( array_equal(%foo, %bar) ) |
7670 |
|
|
end on |
7671 |
|
|
)NKSP_CODE", |
7672 |
|
|
.expectParseError = true // see comment above |
7673 |
|
|
}); |
7674 |
|
|
|
7675 |
|
|
runScript({ |
7676 |
|
|
.code = R"NKSP_CODE( |
7677 |
|
|
on init |
7678 |
|
|
declare ?foo[3] := ( !1.0, !1.0, !1.0 ) |
7679 |
|
|
declare ?bar[3] := ( !1.0, !1.0, !1.0 ) |
7680 |
|
|
exit( array_equal(?foo, ?bar) ) |
7681 |
|
|
end on |
7682 |
|
|
)NKSP_CODE", |
7683 |
|
|
.expectParseError = true // see comment above |
7684 |
|
|
}); |
7685 |
|
|
|
7686 |
schoenebeck |
3551 |
#if !SILENT_TEST |
7687 |
|
|
std::cout << std::endl; |
7688 |
|
|
#endif |
7689 |
|
|
} |
7690 |
|
|
|
7691 |
|
|
static void testBuiltInSortFunction() { |
7692 |
|
|
#if !SILENT_TEST |
7693 |
|
|
std::cout << "UNIT TEST: built-in sort() function\n"; |
7694 |
|
|
#endif |
7695 |
|
|
|
7696 |
schoenebeck |
3581 |
// integer array tests ... |
7697 |
|
|
|
7698 |
schoenebeck |
3551 |
runScript({ |
7699 |
|
|
.code = R"NKSP_CODE( |
7700 |
|
|
on init |
7701 |
|
|
declare %input[3] := ( 19, 3, 6 ) |
7702 |
|
|
declare %expected[3] := ( 3, 6, 19 ) |
7703 |
|
|
sort(%input, 0) |
7704 |
|
|
exit( array_equal(%input, %expected) ) |
7705 |
|
|
end on |
7706 |
|
|
)NKSP_CODE", |
7707 |
|
|
.expectBoolExitResult = true |
7708 |
|
|
}); |
7709 |
|
|
|
7710 |
|
|
runScript({ |
7711 |
|
|
.code = R"NKSP_CODE( |
7712 |
|
|
on init |
7713 |
|
|
declare %input[3] := ( 19, 3, 6 ) |
7714 |
|
|
declare %expected[3] := ( 19, 6, 3 ) |
7715 |
|
|
sort(%input, 1) |
7716 |
|
|
exit( array_equal(%input, %expected) ) |
7717 |
|
|
end on |
7718 |
|
|
)NKSP_CODE", |
7719 |
|
|
.expectBoolExitResult = true |
7720 |
|
|
}); |
7721 |
|
|
|
7722 |
schoenebeck |
3581 |
runScript({ |
7723 |
|
|
.code = R"NKSP_CODE( |
7724 |
|
|
on init |
7725 |
|
|
declare %input[6] := ( 1, 80, 120, 40, 3000, 20 ) |
7726 |
|
|
declare %expected[6] := ( 1, 20, 40, 80, 120, 3000 ) |
7727 |
|
|
sort(%input, 0) |
7728 |
|
|
exit( array_equal(%input, %expected) ) |
7729 |
|
|
end on |
7730 |
|
|
)NKSP_CODE", |
7731 |
|
|
.expectBoolExitResult = true |
7732 |
|
|
}); |
7733 |
|
|
|
7734 |
|
|
// real number array tests ... |
7735 |
|
|
|
7736 |
|
|
runScript({ |
7737 |
|
|
.code = R"NKSP_CODE( |
7738 |
|
|
on init |
7739 |
|
|
declare ?input[4] := ( 1.4, 1.0, 13.4, 2.7 ) |
7740 |
|
|
declare ?expected[4] := ( 1.0, 1.4, 2.7, 13.4 ) |
7741 |
|
|
sort(?input, 0) |
7742 |
|
|
exit( array_equal(?input, ?expected) ) |
7743 |
|
|
end on |
7744 |
|
|
)NKSP_CODE", |
7745 |
|
|
.expectBoolExitResult = true |
7746 |
|
|
}); |
7747 |
|
|
|
7748 |
|
|
runScript({ |
7749 |
|
|
.code = R"NKSP_CODE( |
7750 |
|
|
on init |
7751 |
|
|
declare ?input[4] := ( 1.4, 1.0, 13.4, 2.7 ) |
7752 |
|
|
declare ?expected[4] := ( 13.4, 2.7, 1.4, 1.0 ) |
7753 |
|
|
sort(?input, 1) |
7754 |
|
|
exit( array_equal(?input, ?expected) ) |
7755 |
|
|
end on |
7756 |
|
|
)NKSP_CODE", |
7757 |
|
|
.expectBoolExitResult = true |
7758 |
|
|
}); |
7759 |
|
|
|
7760 |
|
|
// std unit tests ... |
7761 |
|
|
// (only metric prefixes are allowed for arrays ATM) |
7762 |
|
|
|
7763 |
|
|
runScript({ |
7764 |
|
|
.code = R"NKSP_CODE( |
7765 |
|
|
on init |
7766 |
|
|
declare %input[3] := ( 1k, 6, 900 ) |
7767 |
|
|
declare %expected[3] := ( 6, 900, 1k ) |
7768 |
|
|
sort(%input, 0) |
7769 |
|
|
exit( array_equal(%input, %expected) ) |
7770 |
|
|
end on |
7771 |
|
|
)NKSP_CODE", |
7772 |
|
|
.expectBoolExitResult = true |
7773 |
|
|
}); |
7774 |
|
|
|
7775 |
|
|
runScript({ |
7776 |
|
|
.code = R"NKSP_CODE( |
7777 |
|
|
on init |
7778 |
|
|
declare %input[3] := ( 900, 1k, 6 ) |
7779 |
|
|
declare %expected[3] := ( 1k, 900, 6 ) |
7780 |
|
|
sort(%input, 1) |
7781 |
|
|
exit( array_equal(%input, %expected) ) |
7782 |
|
|
end on |
7783 |
|
|
)NKSP_CODE", |
7784 |
|
|
.expectBoolExitResult = true |
7785 |
|
|
}); |
7786 |
|
|
|
7787 |
|
|
runScript({ |
7788 |
|
|
.code = R"NKSP_CODE( |
7789 |
|
|
on init |
7790 |
|
|
declare %input[6] := ( 1k, 8m, 4k, 12000u, 3000u, 1000u ) |
7791 |
|
|
declare %expected[6] := ( 1000u, 3000u, 8m, 12000u, 1k, 4k ) |
7792 |
|
|
sort(%input, 0) |
7793 |
|
|
exit( array_equal(%input, %expected) ) |
7794 |
|
|
end on |
7795 |
|
|
)NKSP_CODE", |
7796 |
|
|
.expectBoolExitResult = true |
7797 |
|
|
}); |
7798 |
|
|
|
7799 |
|
|
runScript({ |
7800 |
|
|
.code = R"NKSP_CODE( |
7801 |
|
|
on init |
7802 |
|
|
declare ?input[3] := ( 1.0k, 6.0, 900.0 ) |
7803 |
|
|
declare ?expected[3] := ( 6.0, 900.0, 1.0k ) |
7804 |
|
|
sort(?input, 0) |
7805 |
|
|
exit( array_equal(?input, ?expected) ) |
7806 |
|
|
end on |
7807 |
|
|
)NKSP_CODE", |
7808 |
|
|
.expectBoolExitResult = true |
7809 |
|
|
}); |
7810 |
|
|
|
7811 |
|
|
runScript({ |
7812 |
|
|
.code = R"NKSP_CODE( |
7813 |
|
|
on init |
7814 |
|
|
declare ?input[3] := ( 900.0, 1.0k, 6.0 ) |
7815 |
|
|
declare ?expected[3] := ( 1.0k, 900.0, 6.0 ) |
7816 |
|
|
sort(?input, 1) |
7817 |
|
|
exit( array_equal(?input, ?expected) ) |
7818 |
|
|
end on |
7819 |
|
|
)NKSP_CODE", |
7820 |
|
|
.expectBoolExitResult = true |
7821 |
|
|
}); |
7822 |
|
|
|
7823 |
|
|
runScript({ |
7824 |
|
|
.code = R"NKSP_CODE( |
7825 |
|
|
on init |
7826 |
|
|
declare ?input[3] := ( 1.0k, 0.9k, 1.1k ) |
7827 |
|
|
declare ?expected[3] := ( 0.9k, 1.0k, 1.1k ) |
7828 |
|
|
sort(?input, 0) |
7829 |
|
|
exit( array_equal(?input, ?expected) ) |
7830 |
|
|
end on |
7831 |
|
|
)NKSP_CODE", |
7832 |
|
|
.expectBoolExitResult = true |
7833 |
|
|
}); |
7834 |
|
|
|
7835 |
|
|
runScript({ |
7836 |
|
|
.code = R"NKSP_CODE( |
7837 |
|
|
on init |
7838 |
|
|
declare ?input[3] := ( 2.0m, 1000.1u, 1.0 ) |
7839 |
|
|
declare ?expected[3] := ( 1000.1u, 2.0m, 1.0 ) |
7840 |
|
|
sort(?input, 0) |
7841 |
|
|
exit( array_equal(?input, ?expected) ) |
7842 |
|
|
end on |
7843 |
|
|
)NKSP_CODE", |
7844 |
|
|
.expectBoolExitResult = true |
7845 |
|
|
}); |
7846 |
|
|
|
7847 |
|
|
runScript({ |
7848 |
|
|
.code = R"NKSP_CODE( |
7849 |
|
|
on init |
7850 |
|
|
declare ?input[4] := ( 2.0m, 1000.1u, 1.0, 1400.0u ) |
7851 |
|
|
declare ?expected[4] := ( 1000.1u, 1400.0u, 2.0m, 1.0 ) |
7852 |
|
|
sort(?input, 0) |
7853 |
|
|
exit( array_equal(?input, ?expected) ) |
7854 |
|
|
end on |
7855 |
|
|
)NKSP_CODE", |
7856 |
|
|
.expectBoolExitResult = true |
7857 |
|
|
}); |
7858 |
|
|
|
7859 |
|
|
runScript({ |
7860 |
|
|
.code = R"NKSP_CODE( |
7861 |
|
|
on init |
7862 |
|
|
declare ?input[4] := ( 2.0m, 1000.1u, 1.0, 1400.0u ) |
7863 |
|
|
declare ?expected[4] := ( 1.0, 2.0m, 1400.0u, 1000.1u ) |
7864 |
|
|
sort(?input, 1) |
7865 |
|
|
exit( array_equal(?input, ?expected) ) |
7866 |
|
|
end on |
7867 |
|
|
)NKSP_CODE", |
7868 |
|
|
.expectBoolExitResult = true |
7869 |
|
|
}); |
7870 |
|
|
|
7871 |
|
|
runScript({ |
7872 |
|
|
.code = R"NKSP_CODE( |
7873 |
|
|
on init |
7874 |
|
|
declare ?input[6] := ( 0.9k, 8.0m, 1.1k, 12000.0u, 3000.0u, 1000.0u ) |
7875 |
|
|
declare ?expected[6] := ( 1000.0u, 3000.0u, 8.0m, 12000.0u, 0.9k, 1.1k ) |
7876 |
|
|
sort(?input, 0) |
7877 |
|
|
exit( array_equal(?input, ?expected) ) |
7878 |
|
|
end on |
7879 |
|
|
)NKSP_CODE", |
7880 |
|
|
.expectBoolExitResult = true |
7881 |
|
|
}); |
7882 |
|
|
|
7883 |
|
|
runScript({ |
7884 |
|
|
.code = R"NKSP_CODE( |
7885 |
|
|
on init |
7886 |
|
|
declare ?input[6] := ( 0.9k, 8.0m, 1.1k, 12000.0u, 3000.0u, 1000.0u ) |
7887 |
|
|
declare ?expected[6] := ( 1.1k, 0.9k, 12000.0u, 8.0m, 3000.0u, 1000.0u ) |
7888 |
|
|
sort(?input, 1) |
7889 |
|
|
exit( array_equal(?input, ?expected) ) |
7890 |
|
|
end on |
7891 |
|
|
)NKSP_CODE", |
7892 |
|
|
.expectBoolExitResult = true |
7893 |
|
|
}); |
7894 |
|
|
|
7895 |
schoenebeck |
3551 |
#if !SILENT_TEST |
7896 |
|
|
std::cout << std::endl; |
7897 |
|
|
#endif |
7898 |
|
|
} |
7899 |
|
|
|
7900 |
schoenebeck |
3590 |
static void testBuiltInRoundFunction() { |
7901 |
|
|
#if !SILENT_TEST |
7902 |
|
|
std::cout << "UNIT TEST: built-in round() function\n"; |
7903 |
|
|
#endif |
7904 |
|
|
|
7905 |
|
|
// integer tests ... |
7906 |
|
|
// (ATM not allowed for this function) |
7907 |
|
|
|
7908 |
|
|
runScript({ |
7909 |
|
|
.code = R"NKSP_CODE( |
7910 |
|
|
on init |
7911 |
|
|
declare $foo := 1 |
7912 |
|
|
exit( round($foo) ) |
7913 |
|
|
end on |
7914 |
|
|
)NKSP_CODE", |
7915 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
7916 |
|
|
}); |
7917 |
|
|
|
7918 |
|
|
// real number tests ... |
7919 |
|
|
|
7920 |
|
|
runScript({ |
7921 |
|
|
.code = R"NKSP_CODE( |
7922 |
|
|
on init |
7923 |
|
|
exit( round(99.4) ) |
7924 |
|
|
end on |
7925 |
|
|
)NKSP_CODE", |
7926 |
|
|
.expectRealExitResult = 99.0 |
7927 |
|
|
}); |
7928 |
|
|
|
7929 |
|
|
runScript({ |
7930 |
|
|
.code = R"NKSP_CODE( |
7931 |
|
|
on init |
7932 |
|
|
exit( round(99.5) ) |
7933 |
|
|
end on |
7934 |
|
|
)NKSP_CODE", |
7935 |
|
|
.expectRealExitResult = 100.0 |
7936 |
|
|
}); |
7937 |
|
|
|
7938 |
|
|
// std unit tests ... |
7939 |
|
|
|
7940 |
|
|
runScript({ |
7941 |
|
|
.code = R"NKSP_CODE( |
7942 |
|
|
on init |
7943 |
|
|
exit( round(2.4ms) ) |
7944 |
|
|
end on |
7945 |
|
|
)NKSP_CODE", |
7946 |
|
|
.expectRealExitResult = 2.0, |
7947 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
7948 |
|
|
.expectExitResultUnit = VM_SECOND |
7949 |
|
|
}); |
7950 |
|
|
|
7951 |
|
|
runScript({ |
7952 |
|
|
.code = R"NKSP_CODE( |
7953 |
|
|
on init |
7954 |
|
|
exit( round(2.6kHz) ) |
7955 |
|
|
end on |
7956 |
|
|
)NKSP_CODE", |
7957 |
|
|
.expectRealExitResult = 3.0, |
7958 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
7959 |
|
|
.expectExitResultUnit = VM_HERTZ |
7960 |
|
|
}); |
7961 |
|
|
|
7962 |
|
|
// 'final' ('!') operator tests ... |
7963 |
|
|
|
7964 |
|
|
runScript({ |
7965 |
|
|
.code = R"NKSP_CODE( |
7966 |
|
|
on init |
7967 |
|
|
exit( round(123.8) ) |
7968 |
|
|
end on |
7969 |
|
|
)NKSP_CODE", |
7970 |
|
|
.expectRealExitResult = 124.0, |
7971 |
|
|
.expectExitResultFinal = false |
7972 |
|
|
}); |
7973 |
|
|
|
7974 |
|
|
runScript({ |
7975 |
|
|
.code = R"NKSP_CODE( |
7976 |
|
|
on init |
7977 |
|
|
exit( round(!123.8) ) |
7978 |
|
|
end on |
7979 |
|
|
)NKSP_CODE", |
7980 |
|
|
.expectRealExitResult = 124.0, |
7981 |
|
|
.expectExitResultFinal = true |
7982 |
|
|
}); |
7983 |
|
|
|
7984 |
|
|
#if !SILENT_TEST |
7985 |
|
|
std::cout << std::endl; |
7986 |
|
|
#endif |
7987 |
|
|
} |
7988 |
|
|
|
7989 |
|
|
static void testBuiltInCeilFunction() { |
7990 |
|
|
#if !SILENT_TEST |
7991 |
|
|
std::cout << "UNIT TEST: built-in ceil() function\n"; |
7992 |
|
|
#endif |
7993 |
|
|
|
7994 |
|
|
// integer tests ... |
7995 |
|
|
// (ATM not allowed for this function) |
7996 |
|
|
|
7997 |
|
|
runScript({ |
7998 |
|
|
.code = R"NKSP_CODE( |
7999 |
|
|
on init |
8000 |
|
|
declare $foo := 1 |
8001 |
|
|
exit( ceil($foo) ) |
8002 |
|
|
end on |
8003 |
|
|
)NKSP_CODE", |
8004 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
8005 |
|
|
}); |
8006 |
|
|
|
8007 |
|
|
// real number tests ... |
8008 |
|
|
|
8009 |
|
|
runScript({ |
8010 |
|
|
.code = R"NKSP_CODE( |
8011 |
|
|
on init |
8012 |
|
|
exit( ceil(99.0) ) |
8013 |
|
|
end on |
8014 |
|
|
)NKSP_CODE", |
8015 |
|
|
.expectRealExitResult = 99.0 |
8016 |
|
|
}); |
8017 |
|
|
|
8018 |
|
|
runScript({ |
8019 |
|
|
.code = R"NKSP_CODE( |
8020 |
|
|
on init |
8021 |
|
|
exit( ceil(99.1) ) |
8022 |
|
|
end on |
8023 |
|
|
)NKSP_CODE", |
8024 |
|
|
.expectRealExitResult = 100.0 |
8025 |
|
|
}); |
8026 |
|
|
|
8027 |
|
|
runScript({ |
8028 |
|
|
.code = R"NKSP_CODE( |
8029 |
|
|
on init |
8030 |
|
|
exit( ceil(99.9) ) |
8031 |
|
|
end on |
8032 |
|
|
)NKSP_CODE", |
8033 |
|
|
.expectRealExitResult = 100.0 |
8034 |
|
|
}); |
8035 |
|
|
|
8036 |
|
|
// std unit tests ... |
8037 |
|
|
|
8038 |
|
|
runScript({ |
8039 |
|
|
.code = R"NKSP_CODE( |
8040 |
|
|
on init |
8041 |
|
|
exit( ceil(2.4ms) ) |
8042 |
|
|
end on |
8043 |
|
|
)NKSP_CODE", |
8044 |
|
|
.expectRealExitResult = 3.0, |
8045 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8046 |
|
|
.expectExitResultUnit = VM_SECOND |
8047 |
|
|
}); |
8048 |
|
|
|
8049 |
|
|
runScript({ |
8050 |
|
|
.code = R"NKSP_CODE( |
8051 |
|
|
on init |
8052 |
|
|
exit( ceil(2.6kHz) ) |
8053 |
|
|
end on |
8054 |
|
|
)NKSP_CODE", |
8055 |
|
|
.expectRealExitResult = 3.0, |
8056 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8057 |
|
|
.expectExitResultUnit = VM_HERTZ |
8058 |
|
|
}); |
8059 |
|
|
|
8060 |
|
|
// 'final' ('!') operator tests ... |
8061 |
|
|
|
8062 |
|
|
runScript({ |
8063 |
|
|
.code = R"NKSP_CODE( |
8064 |
|
|
on init |
8065 |
|
|
exit( ceil(123.1) ) |
8066 |
|
|
end on |
8067 |
|
|
)NKSP_CODE", |
8068 |
|
|
.expectRealExitResult = 124.0, |
8069 |
|
|
.expectExitResultFinal = false |
8070 |
|
|
}); |
8071 |
|
|
|
8072 |
|
|
runScript({ |
8073 |
|
|
.code = R"NKSP_CODE( |
8074 |
|
|
on init |
8075 |
|
|
exit( ceil(!123.8) ) |
8076 |
|
|
end on |
8077 |
|
|
)NKSP_CODE", |
8078 |
|
|
.expectRealExitResult = 124.0, |
8079 |
|
|
.expectExitResultFinal = true |
8080 |
|
|
}); |
8081 |
|
|
|
8082 |
|
|
#if !SILENT_TEST |
8083 |
|
|
std::cout << std::endl; |
8084 |
|
|
#endif |
8085 |
|
|
} |
8086 |
|
|
|
8087 |
|
|
static void testBuiltInFloorFunction() { |
8088 |
|
|
#if !SILENT_TEST |
8089 |
|
|
std::cout << "UNIT TEST: built-in floor() function\n"; |
8090 |
|
|
#endif |
8091 |
|
|
|
8092 |
|
|
// integer tests ... |
8093 |
|
|
// (ATM not allowed for this function) |
8094 |
|
|
|
8095 |
|
|
runScript({ |
8096 |
|
|
.code = R"NKSP_CODE( |
8097 |
|
|
on init |
8098 |
|
|
declare $foo := 1 |
8099 |
|
|
exit( floor($foo) ) |
8100 |
|
|
end on |
8101 |
|
|
)NKSP_CODE", |
8102 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
8103 |
|
|
}); |
8104 |
|
|
|
8105 |
|
|
// real number tests ... |
8106 |
|
|
|
8107 |
|
|
runScript({ |
8108 |
|
|
.code = R"NKSP_CODE( |
8109 |
|
|
on init |
8110 |
|
|
exit( floor(99.0) ) |
8111 |
|
|
end on |
8112 |
|
|
)NKSP_CODE", |
8113 |
|
|
.expectRealExitResult = 99.0 |
8114 |
|
|
}); |
8115 |
|
|
|
8116 |
|
|
runScript({ |
8117 |
|
|
.code = R"NKSP_CODE( |
8118 |
|
|
on init |
8119 |
|
|
exit( floor(99.1) ) |
8120 |
|
|
end on |
8121 |
|
|
)NKSP_CODE", |
8122 |
|
|
.expectRealExitResult = 99.0 |
8123 |
|
|
}); |
8124 |
|
|
|
8125 |
|
|
runScript({ |
8126 |
|
|
.code = R"NKSP_CODE( |
8127 |
|
|
on init |
8128 |
|
|
exit( floor(99.9) ) |
8129 |
|
|
end on |
8130 |
|
|
)NKSP_CODE", |
8131 |
|
|
.expectRealExitResult = 99.0 |
8132 |
|
|
}); |
8133 |
|
|
|
8134 |
|
|
// std unit tests ... |
8135 |
|
|
|
8136 |
|
|
runScript({ |
8137 |
|
|
.code = R"NKSP_CODE( |
8138 |
|
|
on init |
8139 |
|
|
exit( floor(2.4ms) ) |
8140 |
|
|
end on |
8141 |
|
|
)NKSP_CODE", |
8142 |
|
|
.expectRealExitResult = 2.0, |
8143 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8144 |
|
|
.expectExitResultUnit = VM_SECOND |
8145 |
|
|
}); |
8146 |
|
|
|
8147 |
|
|
runScript({ |
8148 |
|
|
.code = R"NKSP_CODE( |
8149 |
|
|
on init |
8150 |
|
|
exit( floor(2.6kHz) ) |
8151 |
|
|
end on |
8152 |
|
|
)NKSP_CODE", |
8153 |
|
|
.expectRealExitResult = 2.0, |
8154 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8155 |
|
|
.expectExitResultUnit = VM_HERTZ |
8156 |
|
|
}); |
8157 |
|
|
|
8158 |
|
|
// 'final' ('!') operator tests ... |
8159 |
|
|
|
8160 |
|
|
runScript({ |
8161 |
|
|
.code = R"NKSP_CODE( |
8162 |
|
|
on init |
8163 |
|
|
exit( floor(123.1) ) |
8164 |
|
|
end on |
8165 |
|
|
)NKSP_CODE", |
8166 |
|
|
.expectRealExitResult = 123.0, |
8167 |
|
|
.expectExitResultFinal = false |
8168 |
|
|
}); |
8169 |
|
|
|
8170 |
|
|
runScript({ |
8171 |
|
|
.code = R"NKSP_CODE( |
8172 |
|
|
on init |
8173 |
|
|
exit( floor(!123.8) ) |
8174 |
|
|
end on |
8175 |
|
|
)NKSP_CODE", |
8176 |
|
|
.expectRealExitResult = 123.0, |
8177 |
|
|
.expectExitResultFinal = true |
8178 |
|
|
}); |
8179 |
|
|
|
8180 |
|
|
#if !SILENT_TEST |
8181 |
|
|
std::cout << std::endl; |
8182 |
|
|
#endif |
8183 |
|
|
} |
8184 |
|
|
|
8185 |
|
|
static void testBuiltInSqrtFunction() { |
8186 |
|
|
#if !SILENT_TEST |
8187 |
|
|
std::cout << "UNIT TEST: built-in sqrt() function\n"; |
8188 |
|
|
#endif |
8189 |
|
|
|
8190 |
|
|
// integer tests ... |
8191 |
|
|
// (ATM not allowed for this function) |
8192 |
|
|
|
8193 |
|
|
runScript({ |
8194 |
|
|
.code = R"NKSP_CODE( |
8195 |
|
|
on init |
8196 |
|
|
declare $foo := 1 |
8197 |
|
|
exit( sqrt($foo) ) |
8198 |
|
|
end on |
8199 |
|
|
)NKSP_CODE", |
8200 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
8201 |
|
|
}); |
8202 |
|
|
|
8203 |
|
|
// real number tests ... |
8204 |
|
|
|
8205 |
|
|
runScript({ |
8206 |
|
|
.code = R"NKSP_CODE( |
8207 |
|
|
on init |
8208 |
|
|
exit( sqrt(36.0) ) |
8209 |
|
|
end on |
8210 |
|
|
)NKSP_CODE", |
8211 |
|
|
.expectRealExitResult = 6.0 |
8212 |
|
|
}); |
8213 |
|
|
|
8214 |
|
|
// std unit tests ... |
8215 |
|
|
|
8216 |
|
|
runScript({ |
8217 |
|
|
.code = R"NKSP_CODE( |
8218 |
|
|
on init |
8219 |
|
|
exit( sqrt(100.0ms) ) |
8220 |
|
|
end on |
8221 |
|
|
)NKSP_CODE", |
8222 |
|
|
.expectRealExitResult = 10.0, |
8223 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8224 |
|
|
.expectExitResultUnit = VM_SECOND |
8225 |
|
|
}); |
8226 |
|
|
|
8227 |
|
|
runScript({ |
8228 |
|
|
.code = R"NKSP_CODE( |
8229 |
|
|
on init |
8230 |
|
|
exit( sqrt(5.76kHz) ) |
8231 |
|
|
end on |
8232 |
|
|
)NKSP_CODE", |
8233 |
|
|
.expectRealExitResult = 2.4, |
8234 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8235 |
|
|
.expectExitResultUnit = VM_HERTZ |
8236 |
|
|
}); |
8237 |
|
|
|
8238 |
|
|
// 'final' ('!') operator tests ... |
8239 |
|
|
|
8240 |
|
|
runScript({ |
8241 |
|
|
.code = R"NKSP_CODE( |
8242 |
|
|
on init |
8243 |
|
|
exit( sqrt(25.0) ) |
8244 |
|
|
end on |
8245 |
|
|
)NKSP_CODE", |
8246 |
|
|
.expectRealExitResult = 5.0, |
8247 |
|
|
.expectExitResultFinal = false |
8248 |
|
|
}); |
8249 |
|
|
|
8250 |
|
|
runScript({ |
8251 |
|
|
.code = R"NKSP_CODE( |
8252 |
|
|
on init |
8253 |
|
|
exit( sqrt(!25.0) ) |
8254 |
|
|
end on |
8255 |
|
|
)NKSP_CODE", |
8256 |
|
|
.expectRealExitResult = 5.0, |
8257 |
|
|
.expectExitResultFinal = true |
8258 |
|
|
}); |
8259 |
|
|
|
8260 |
|
|
#if !SILENT_TEST |
8261 |
|
|
std::cout << std::endl; |
8262 |
|
|
#endif |
8263 |
|
|
} |
8264 |
|
|
|
8265 |
|
|
static void testBuiltInLogFunction() { |
8266 |
|
|
#if !SILENT_TEST |
8267 |
|
|
std::cout << "UNIT TEST: built-in log() function\n"; |
8268 |
|
|
#endif |
8269 |
|
|
|
8270 |
|
|
// integer tests ... |
8271 |
|
|
// (ATM not allowed for this function) |
8272 |
|
|
|
8273 |
|
|
runScript({ |
8274 |
|
|
.code = R"NKSP_CODE( |
8275 |
|
|
on init |
8276 |
|
|
declare $foo := 1 |
8277 |
|
|
exit( log($foo) ) |
8278 |
|
|
end on |
8279 |
|
|
)NKSP_CODE", |
8280 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
8281 |
|
|
}); |
8282 |
|
|
|
8283 |
|
|
// real number tests ... |
8284 |
|
|
|
8285 |
|
|
runScript({ |
8286 |
|
|
.code = R"NKSP_CODE( |
8287 |
|
|
on init |
8288 |
|
|
exit( log(1.0) ) |
8289 |
|
|
end on |
8290 |
|
|
)NKSP_CODE", |
8291 |
|
|
.expectRealExitResult = 0.0 |
8292 |
|
|
}); |
8293 |
|
|
|
8294 |
|
|
runScript({ |
8295 |
|
|
.code = R"NKSP_CODE( |
8296 |
|
|
on init |
8297 |
|
|
exit( log(~NI_MATH_E) ) |
8298 |
|
|
end on |
8299 |
|
|
)NKSP_CODE", |
8300 |
|
|
.expectRealExitResult = 1.0 |
8301 |
|
|
}); |
8302 |
|
|
|
8303 |
|
|
// std unit tests ... |
8304 |
|
|
|
8305 |
|
|
runScript({ |
8306 |
|
|
.code = R"NKSP_CODE( |
8307 |
|
|
on init |
8308 |
|
|
exit( log(~NI_MATH_E * 1.0ms) ) |
8309 |
|
|
end on |
8310 |
|
|
)NKSP_CODE", |
8311 |
|
|
.expectRealExitResult = 1.0, |
8312 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8313 |
|
|
.expectExitResultUnit = VM_SECOND |
8314 |
|
|
}); |
8315 |
|
|
|
8316 |
|
|
runScript({ |
8317 |
|
|
.code = R"NKSP_CODE( |
8318 |
|
|
on init |
8319 |
|
|
exit( log(~NI_MATH_E * 1.0kHz) ) |
8320 |
|
|
end on |
8321 |
|
|
)NKSP_CODE", |
8322 |
|
|
.expectRealExitResult = 1.0, |
8323 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8324 |
|
|
.expectExitResultUnit = VM_HERTZ |
8325 |
|
|
}); |
8326 |
|
|
|
8327 |
|
|
// 'final' ('!') operator tests ... |
8328 |
|
|
|
8329 |
|
|
runScript({ |
8330 |
|
|
.code = R"NKSP_CODE( |
8331 |
|
|
on init |
8332 |
|
|
exit( log(~NI_MATH_E * 1.0) ) |
8333 |
|
|
end on |
8334 |
|
|
)NKSP_CODE", |
8335 |
|
|
.expectRealExitResult = 1.0, |
8336 |
|
|
.expectExitResultFinal = false |
8337 |
|
|
}); |
8338 |
|
|
|
8339 |
|
|
runScript({ |
8340 |
|
|
.code = R"NKSP_CODE( |
8341 |
|
|
on init |
8342 |
|
|
exit( log(!(~NI_MATH_E * 1.0)) ) |
8343 |
|
|
end on |
8344 |
|
|
)NKSP_CODE", |
8345 |
|
|
.expectRealExitResult = 1.0, |
8346 |
|
|
.expectExitResultFinal = true |
8347 |
|
|
}); |
8348 |
|
|
|
8349 |
|
|
#if !SILENT_TEST |
8350 |
|
|
std::cout << std::endl; |
8351 |
|
|
#endif |
8352 |
|
|
} |
8353 |
|
|
|
8354 |
|
|
static void testBuiltInLog2Function() { |
8355 |
|
|
#if !SILENT_TEST |
8356 |
|
|
std::cout << "UNIT TEST: built-in log2() function\n"; |
8357 |
|
|
#endif |
8358 |
|
|
|
8359 |
|
|
// integer tests ... |
8360 |
|
|
// (ATM not allowed for this function) |
8361 |
|
|
|
8362 |
|
|
runScript({ |
8363 |
|
|
.code = R"NKSP_CODE( |
8364 |
|
|
on init |
8365 |
|
|
declare $foo := 1 |
8366 |
|
|
exit( log2($foo) ) |
8367 |
|
|
end on |
8368 |
|
|
)NKSP_CODE", |
8369 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
8370 |
|
|
}); |
8371 |
|
|
|
8372 |
|
|
// real number tests ... |
8373 |
|
|
|
8374 |
|
|
runScript({ |
8375 |
|
|
.code = R"NKSP_CODE( |
8376 |
|
|
on init |
8377 |
|
|
exit( log2(1.0) ) |
8378 |
|
|
end on |
8379 |
|
|
)NKSP_CODE", |
8380 |
|
|
.expectRealExitResult = 0.0 |
8381 |
|
|
}); |
8382 |
|
|
|
8383 |
|
|
runScript({ |
8384 |
|
|
.code = R"NKSP_CODE( |
8385 |
|
|
on init |
8386 |
|
|
exit( log2(32.0) ) |
8387 |
|
|
end on |
8388 |
|
|
)NKSP_CODE", |
8389 |
|
|
.expectRealExitResult = 5.0 |
8390 |
|
|
}); |
8391 |
|
|
|
8392 |
|
|
// std unit tests ... |
8393 |
|
|
|
8394 |
|
|
runScript({ |
8395 |
|
|
.code = R"NKSP_CODE( |
8396 |
|
|
on init |
8397 |
|
|
exit( log2(32.0ms) ) |
8398 |
|
|
end on |
8399 |
|
|
)NKSP_CODE", |
8400 |
|
|
.expectRealExitResult = 5.0, |
8401 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8402 |
|
|
.expectExitResultUnit = VM_SECOND |
8403 |
|
|
}); |
8404 |
|
|
|
8405 |
|
|
runScript({ |
8406 |
|
|
.code = R"NKSP_CODE( |
8407 |
|
|
on init |
8408 |
|
|
exit( log2(32.0kHz) ) |
8409 |
|
|
end on |
8410 |
|
|
)NKSP_CODE", |
8411 |
|
|
.expectRealExitResult = 5.0, |
8412 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8413 |
|
|
.expectExitResultUnit = VM_HERTZ |
8414 |
|
|
}); |
8415 |
|
|
|
8416 |
|
|
// 'final' ('!') operator tests ... |
8417 |
|
|
|
8418 |
|
|
runScript({ |
8419 |
|
|
.code = R"NKSP_CODE( |
8420 |
|
|
on init |
8421 |
|
|
exit( log2(32.0) ) |
8422 |
|
|
end on |
8423 |
|
|
)NKSP_CODE", |
8424 |
|
|
.expectRealExitResult = 5.0, |
8425 |
|
|
.expectExitResultFinal = false |
8426 |
|
|
}); |
8427 |
|
|
|
8428 |
|
|
runScript({ |
8429 |
|
|
.code = R"NKSP_CODE( |
8430 |
|
|
on init |
8431 |
|
|
exit( log2(!32.0) ) |
8432 |
|
|
end on |
8433 |
|
|
)NKSP_CODE", |
8434 |
|
|
.expectRealExitResult = 5.0, |
8435 |
|
|
.expectExitResultFinal = true |
8436 |
|
|
}); |
8437 |
|
|
|
8438 |
|
|
#if !SILENT_TEST |
8439 |
|
|
std::cout << std::endl; |
8440 |
|
|
#endif |
8441 |
|
|
} |
8442 |
|
|
|
8443 |
|
|
static void testBuiltInLog10Function() { |
8444 |
|
|
#if !SILENT_TEST |
8445 |
|
|
std::cout << "UNIT TEST: built-in log10() function\n"; |
8446 |
|
|
#endif |
8447 |
|
|
|
8448 |
|
|
// integer tests ... |
8449 |
|
|
// (ATM not allowed for this function) |
8450 |
|
|
|
8451 |
|
|
runScript({ |
8452 |
|
|
.code = R"NKSP_CODE( |
8453 |
|
|
on init |
8454 |
|
|
declare $foo := 1 |
8455 |
|
|
exit( log10($foo) ) |
8456 |
|
|
end on |
8457 |
|
|
)NKSP_CODE", |
8458 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
8459 |
|
|
}); |
8460 |
|
|
|
8461 |
|
|
// real number tests ... |
8462 |
|
|
|
8463 |
|
|
runScript({ |
8464 |
|
|
.code = R"NKSP_CODE( |
8465 |
|
|
on init |
8466 |
|
|
exit( log10(1000.0) ) |
8467 |
|
|
end on |
8468 |
|
|
)NKSP_CODE", |
8469 |
|
|
.expectRealExitResult = 3.0 |
8470 |
|
|
}); |
8471 |
|
|
|
8472 |
|
|
runScript({ |
8473 |
|
|
.code = R"NKSP_CODE( |
8474 |
|
|
on init |
8475 |
|
|
exit( log10(1000.0) ) |
8476 |
|
|
end on |
8477 |
|
|
)NKSP_CODE", |
8478 |
|
|
.expectRealExitResult = 3.0 |
8479 |
|
|
}); |
8480 |
|
|
|
8481 |
|
|
// std unit tests ... |
8482 |
|
|
|
8483 |
|
|
runScript({ |
8484 |
|
|
.code = R"NKSP_CODE( |
8485 |
|
|
on init |
8486 |
|
|
exit( log10(1000.0ms) ) |
8487 |
|
|
end on |
8488 |
|
|
)NKSP_CODE", |
8489 |
|
|
.expectRealExitResult = 3.0, |
8490 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8491 |
|
|
.expectExitResultUnit = VM_SECOND |
8492 |
|
|
}); |
8493 |
|
|
|
8494 |
|
|
runScript({ |
8495 |
|
|
.code = R"NKSP_CODE( |
8496 |
|
|
on init |
8497 |
|
|
exit( log10(1000.0kHz) ) |
8498 |
|
|
end on |
8499 |
|
|
)NKSP_CODE", |
8500 |
|
|
.expectRealExitResult = 3.0, |
8501 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8502 |
|
|
.expectExitResultUnit = VM_HERTZ |
8503 |
|
|
}); |
8504 |
|
|
|
8505 |
|
|
// 'final' ('!') operator tests ... |
8506 |
|
|
|
8507 |
|
|
runScript({ |
8508 |
|
|
.code = R"NKSP_CODE( |
8509 |
|
|
on init |
8510 |
|
|
exit( log10(1000.0) ) |
8511 |
|
|
end on |
8512 |
|
|
)NKSP_CODE", |
8513 |
|
|
.expectRealExitResult = 3.0, |
8514 |
|
|
.expectExitResultFinal = false |
8515 |
|
|
}); |
8516 |
|
|
|
8517 |
|
|
runScript({ |
8518 |
|
|
.code = R"NKSP_CODE( |
8519 |
|
|
on init |
8520 |
|
|
exit( log10(!1000.0) ) |
8521 |
|
|
end on |
8522 |
|
|
)NKSP_CODE", |
8523 |
|
|
.expectRealExitResult = 3.0, |
8524 |
|
|
.expectExitResultFinal = true |
8525 |
|
|
}); |
8526 |
|
|
|
8527 |
|
|
#if !SILENT_TEST |
8528 |
|
|
std::cout << std::endl; |
8529 |
|
|
#endif |
8530 |
|
|
} |
8531 |
|
|
|
8532 |
|
|
static void testBuiltInExpFunction() { |
8533 |
|
|
#if !SILENT_TEST |
8534 |
|
|
std::cout << "UNIT TEST: built-in exp() function\n"; |
8535 |
|
|
#endif |
8536 |
|
|
|
8537 |
|
|
// integer tests ... |
8538 |
|
|
// (ATM not allowed for this function) |
8539 |
|
|
|
8540 |
|
|
runScript({ |
8541 |
|
|
.code = R"NKSP_CODE( |
8542 |
|
|
on init |
8543 |
|
|
declare $foo := 1 |
8544 |
|
|
exit( exp($foo) ) |
8545 |
|
|
end on |
8546 |
|
|
)NKSP_CODE", |
8547 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
8548 |
|
|
}); |
8549 |
|
|
|
8550 |
|
|
// real number tests ... |
8551 |
|
|
|
8552 |
|
|
runScript({ |
8553 |
|
|
.code = R"NKSP_CODE( |
8554 |
|
|
on init |
8555 |
|
|
exit( exp(0.0) ) |
8556 |
|
|
end on |
8557 |
|
|
)NKSP_CODE", |
8558 |
|
|
.expectRealExitResult = 1.0 |
8559 |
|
|
}); |
8560 |
|
|
|
8561 |
|
|
runScript({ |
8562 |
|
|
.code = R"NKSP_CODE( |
8563 |
|
|
on init |
8564 |
|
|
exit( exp(1.0) ) |
8565 |
|
|
end on |
8566 |
|
|
)NKSP_CODE", |
8567 |
|
|
.expectRealExitResult = M_E |
8568 |
|
|
}); |
8569 |
|
|
|
8570 |
|
|
// std unit tests ... |
8571 |
|
|
|
8572 |
|
|
runScript({ |
8573 |
|
|
.code = R"NKSP_CODE( |
8574 |
|
|
on init |
8575 |
|
|
exit( exp(0.0ms) ) |
8576 |
|
|
end on |
8577 |
|
|
)NKSP_CODE", |
8578 |
|
|
.expectRealExitResult = 1.0, |
8579 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8580 |
|
|
.expectExitResultUnit = VM_SECOND |
8581 |
|
|
}); |
8582 |
|
|
|
8583 |
|
|
runScript({ |
8584 |
|
|
.code = R"NKSP_CODE( |
8585 |
|
|
on init |
8586 |
|
|
exit( exp(0.0kHz) ) |
8587 |
|
|
end on |
8588 |
|
|
)NKSP_CODE", |
8589 |
|
|
.expectRealExitResult = 1.0, |
8590 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8591 |
|
|
.expectExitResultUnit = VM_HERTZ |
8592 |
|
|
}); |
8593 |
|
|
|
8594 |
|
|
// 'final' ('!') operator tests ... |
8595 |
|
|
|
8596 |
|
|
runScript({ |
8597 |
|
|
.code = R"NKSP_CODE( |
8598 |
|
|
on init |
8599 |
|
|
exit( exp(0.0) ) |
8600 |
|
|
end on |
8601 |
|
|
)NKSP_CODE", |
8602 |
|
|
.expectRealExitResult = 1.0, |
8603 |
|
|
.expectExitResultFinal = false |
8604 |
|
|
}); |
8605 |
|
|
|
8606 |
|
|
runScript({ |
8607 |
|
|
.code = R"NKSP_CODE( |
8608 |
|
|
on init |
8609 |
|
|
exit( exp(!0.0) ) |
8610 |
|
|
end on |
8611 |
|
|
)NKSP_CODE", |
8612 |
|
|
.expectRealExitResult = 1.0, |
8613 |
|
|
.expectExitResultFinal = true |
8614 |
|
|
}); |
8615 |
|
|
|
8616 |
|
|
#if !SILENT_TEST |
8617 |
|
|
std::cout << std::endl; |
8618 |
|
|
#endif |
8619 |
|
|
} |
8620 |
|
|
|
8621 |
|
|
static void testBuiltInPowFunction() { |
8622 |
|
|
#if !SILENT_TEST |
8623 |
|
|
std::cout << "UNIT TEST: built-in pow() function\n"; |
8624 |
|
|
#endif |
8625 |
|
|
|
8626 |
|
|
// integer tests ... |
8627 |
|
|
// (ATM not allowed for this function) |
8628 |
|
|
|
8629 |
|
|
runScript({ |
8630 |
|
|
.code = R"NKSP_CODE( |
8631 |
|
|
on init |
8632 |
|
|
declare $foo := 1 |
8633 |
|
|
exit( pow($foo,$foo) ) |
8634 |
|
|
end on |
8635 |
|
|
)NKSP_CODE", |
8636 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
8637 |
|
|
}); |
8638 |
|
|
|
8639 |
|
|
// real number tests ... |
8640 |
|
|
|
8641 |
|
|
runScript({ |
8642 |
|
|
.code = R"NKSP_CODE( |
8643 |
|
|
on init |
8644 |
|
|
exit( pow(1.0) ) |
8645 |
|
|
end on |
8646 |
|
|
)NKSP_CODE", |
8647 |
|
|
.expectParseError = true // because pow() requires exactly 2 arguments |
8648 |
|
|
}); |
8649 |
|
|
|
8650 |
|
|
runScript({ |
8651 |
|
|
.code = R"NKSP_CODE( |
8652 |
|
|
on init |
8653 |
|
|
exit( pow(3.0,4.0) ) |
8654 |
|
|
end on |
8655 |
|
|
)NKSP_CODE", |
8656 |
|
|
.expectRealExitResult = 81.0 |
8657 |
|
|
}); |
8658 |
|
|
|
8659 |
|
|
// std unit tests ... |
8660 |
|
|
|
8661 |
|
|
runScript({ |
8662 |
|
|
.code = R"NKSP_CODE( |
8663 |
|
|
on init |
8664 |
|
|
exit( pow(3.0ms,4.0ms) ) |
8665 |
|
|
end on |
8666 |
|
|
)NKSP_CODE", |
8667 |
|
|
.expectParseError = true // because units are prohibited for 2nd argument |
8668 |
|
|
}); |
8669 |
|
|
|
8670 |
|
|
runScript({ |
8671 |
|
|
.code = R"NKSP_CODE( |
8672 |
|
|
on init |
8673 |
|
|
exit( pow(3.0,4.0ms) ) |
8674 |
|
|
end on |
8675 |
|
|
)NKSP_CODE", |
8676 |
|
|
.expectParseError = true // because units are prohibited for 2nd argument |
8677 |
|
|
}); |
8678 |
|
|
|
8679 |
|
|
runScript({ |
8680 |
|
|
.code = R"NKSP_CODE( |
8681 |
|
|
on init |
8682 |
|
|
exit( pow(3.0ms,4.0) ) |
8683 |
|
|
end on |
8684 |
|
|
)NKSP_CODE", |
8685 |
|
|
.expectRealExitResult = 81.0, |
8686 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8687 |
|
|
.expectExitResultUnit = VM_SECOND |
8688 |
|
|
}); |
8689 |
|
|
|
8690 |
|
|
runScript({ |
8691 |
|
|
.code = R"NKSP_CODE( |
8692 |
|
|
on init |
8693 |
|
|
exit( pow(3.0kHz,4.0) ) |
8694 |
|
|
end on |
8695 |
|
|
)NKSP_CODE", |
8696 |
|
|
.expectRealExitResult = 81.0, |
8697 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8698 |
|
|
.expectExitResultUnit = VM_HERTZ |
8699 |
|
|
}); |
8700 |
|
|
|
8701 |
|
|
// 'final' ('!') operator tests ... |
8702 |
|
|
|
8703 |
|
|
runScript({ |
8704 |
|
|
.code = R"NKSP_CODE( |
8705 |
|
|
on init |
8706 |
|
|
exit( pow(3.0,4.0) ) |
8707 |
|
|
end on |
8708 |
|
|
)NKSP_CODE", |
8709 |
|
|
.expectRealExitResult = 81.0, |
8710 |
|
|
.expectExitResultFinal = false |
8711 |
|
|
}); |
8712 |
|
|
|
8713 |
|
|
runScript({ |
8714 |
|
|
.code = R"NKSP_CODE( |
8715 |
|
|
on init |
8716 |
|
|
exit( pow(!3.0,4.0) ) |
8717 |
|
|
end on |
8718 |
|
|
)NKSP_CODE", |
8719 |
|
|
.expectRealExitResult = 81.0, |
8720 |
|
|
.expectExitResultFinal = true |
8721 |
|
|
}); |
8722 |
|
|
|
8723 |
|
|
runScript({ |
8724 |
|
|
.code = R"NKSP_CODE( |
8725 |
|
|
on init |
8726 |
|
|
exit( pow(3.0,!4.0) ) |
8727 |
|
|
end on |
8728 |
|
|
)NKSP_CODE", |
8729 |
|
|
.expectParseError = true // because 'final' is meaningless for 2nd argument |
8730 |
|
|
}); |
8731 |
|
|
|
8732 |
|
|
#if !SILENT_TEST |
8733 |
|
|
std::cout << std::endl; |
8734 |
|
|
#endif |
8735 |
|
|
} |
8736 |
|
|
|
8737 |
|
|
static void testBuiltInSinFunction() { |
8738 |
|
|
#if !SILENT_TEST |
8739 |
|
|
std::cout << "UNIT TEST: built-in sin() function\n"; |
8740 |
|
|
#endif |
8741 |
|
|
|
8742 |
|
|
// integer tests ... |
8743 |
|
|
// (ATM not allowed for this function) |
8744 |
|
|
|
8745 |
|
|
runScript({ |
8746 |
|
|
.code = R"NKSP_CODE( |
8747 |
|
|
on init |
8748 |
|
|
declare $foo := 1 |
8749 |
|
|
exit( sin($foo) ) |
8750 |
|
|
end on |
8751 |
|
|
)NKSP_CODE", |
8752 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
8753 |
|
|
}); |
8754 |
|
|
|
8755 |
|
|
// real number tests ... |
8756 |
|
|
|
8757 |
|
|
runScript({ |
8758 |
|
|
.code = R"NKSP_CODE( |
8759 |
|
|
on init |
8760 |
|
|
exit( sin(0.0) ) |
8761 |
|
|
end on |
8762 |
|
|
)NKSP_CODE", |
8763 |
|
|
.expectRealExitResult = 0.0 |
8764 |
|
|
}); |
8765 |
|
|
|
8766 |
|
|
runScript({ |
8767 |
|
|
.code = R"NKSP_CODE( |
8768 |
|
|
on init |
8769 |
|
|
exit( sin(0.5 * ~NI_MATH_PI) ) |
8770 |
|
|
end on |
8771 |
|
|
)NKSP_CODE", |
8772 |
|
|
.expectRealExitResult = 1.0 |
8773 |
|
|
}); |
8774 |
|
|
|
8775 |
|
|
runScript({ |
8776 |
|
|
.code = R"NKSP_CODE( |
8777 |
|
|
on init |
8778 |
|
|
exit( sin(~NI_MATH_PI) ) |
8779 |
|
|
end on |
8780 |
|
|
)NKSP_CODE", |
8781 |
|
|
.expectRealExitResult = 0.0 |
8782 |
|
|
}); |
8783 |
|
|
|
8784 |
|
|
runScript({ |
8785 |
|
|
.code = R"NKSP_CODE( |
8786 |
|
|
on init |
8787 |
|
|
exit( sin(1.5 * ~NI_MATH_PI) ) |
8788 |
|
|
end on |
8789 |
|
|
)NKSP_CODE", |
8790 |
|
|
.expectRealExitResult = -1.0 |
8791 |
|
|
}); |
8792 |
|
|
|
8793 |
|
|
// std unit tests ... |
8794 |
|
|
|
8795 |
|
|
runScript({ |
8796 |
|
|
.code = R"NKSP_CODE( |
8797 |
|
|
on init |
8798 |
|
|
exit( sin(0.0ms) ) |
8799 |
|
|
end on |
8800 |
|
|
)NKSP_CODE", |
8801 |
|
|
.expectRealExitResult = 0.0, |
8802 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8803 |
|
|
.expectExitResultUnit = VM_SECOND |
8804 |
|
|
}); |
8805 |
|
|
|
8806 |
|
|
runScript({ |
8807 |
|
|
.code = R"NKSP_CODE( |
8808 |
|
|
on init |
8809 |
|
|
exit( sin(0.0kHz) ) |
8810 |
|
|
end on |
8811 |
|
|
)NKSP_CODE", |
8812 |
|
|
.expectRealExitResult = 0.0, |
8813 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8814 |
|
|
.expectExitResultUnit = VM_HERTZ |
8815 |
|
|
}); |
8816 |
|
|
|
8817 |
|
|
// 'final' ('!') operator tests ... |
8818 |
|
|
|
8819 |
|
|
runScript({ |
8820 |
|
|
.code = R"NKSP_CODE( |
8821 |
|
|
on init |
8822 |
|
|
exit( sin(0.0) ) |
8823 |
|
|
end on |
8824 |
|
|
)NKSP_CODE", |
8825 |
|
|
.expectRealExitResult = 0.0, |
8826 |
|
|
.expectExitResultFinal = false |
8827 |
|
|
}); |
8828 |
|
|
|
8829 |
|
|
runScript({ |
8830 |
|
|
.code = R"NKSP_CODE( |
8831 |
|
|
on init |
8832 |
|
|
exit( sin(!0.0) ) |
8833 |
|
|
end on |
8834 |
|
|
)NKSP_CODE", |
8835 |
|
|
.expectRealExitResult = 0.0, |
8836 |
|
|
.expectExitResultFinal = true |
8837 |
|
|
}); |
8838 |
|
|
|
8839 |
|
|
#if !SILENT_TEST |
8840 |
|
|
std::cout << std::endl; |
8841 |
|
|
#endif |
8842 |
|
|
} |
8843 |
|
|
|
8844 |
|
|
static void testBuiltInCosFunction() { |
8845 |
|
|
#if !SILENT_TEST |
8846 |
|
|
std::cout << "UNIT TEST: built-in cos() function\n"; |
8847 |
|
|
#endif |
8848 |
|
|
|
8849 |
|
|
// integer tests ... |
8850 |
|
|
// (ATM not allowed for this function) |
8851 |
|
|
|
8852 |
|
|
runScript({ |
8853 |
|
|
.code = R"NKSP_CODE( |
8854 |
|
|
on init |
8855 |
|
|
declare $foo := 1 |
8856 |
|
|
exit( cos($foo) ) |
8857 |
|
|
end on |
8858 |
|
|
)NKSP_CODE", |
8859 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
8860 |
|
|
}); |
8861 |
|
|
|
8862 |
|
|
// real number tests ... |
8863 |
|
|
|
8864 |
|
|
runScript({ |
8865 |
|
|
.code = R"NKSP_CODE( |
8866 |
|
|
on init |
8867 |
|
|
exit( cos(0.0) ) |
8868 |
|
|
end on |
8869 |
|
|
)NKSP_CODE", |
8870 |
|
|
.expectRealExitResult = 1.0 |
8871 |
|
|
}); |
8872 |
|
|
|
8873 |
|
|
runScript({ |
8874 |
|
|
.code = R"NKSP_CODE( |
8875 |
|
|
on init |
8876 |
|
|
exit( cos(0.5 * ~NI_MATH_PI) ) |
8877 |
|
|
end on |
8878 |
|
|
)NKSP_CODE", |
8879 |
|
|
.expectRealExitResult = 0.0 |
8880 |
|
|
}); |
8881 |
|
|
|
8882 |
|
|
runScript({ |
8883 |
|
|
.code = R"NKSP_CODE( |
8884 |
|
|
on init |
8885 |
|
|
exit( cos(~NI_MATH_PI) ) |
8886 |
|
|
end on |
8887 |
|
|
)NKSP_CODE", |
8888 |
|
|
.expectRealExitResult = -1.0 |
8889 |
|
|
}); |
8890 |
|
|
|
8891 |
|
|
runScript({ |
8892 |
|
|
.code = R"NKSP_CODE( |
8893 |
|
|
on init |
8894 |
|
|
exit( cos(1.5 * ~NI_MATH_PI) ) |
8895 |
|
|
end on |
8896 |
|
|
)NKSP_CODE", |
8897 |
|
|
.expectRealExitResult = 0.0 |
8898 |
|
|
}); |
8899 |
|
|
|
8900 |
|
|
// std unit tests ... |
8901 |
|
|
|
8902 |
|
|
runScript({ |
8903 |
|
|
.code = R"NKSP_CODE( |
8904 |
|
|
on init |
8905 |
|
|
exit( cos(0.0ms) ) |
8906 |
|
|
end on |
8907 |
|
|
)NKSP_CODE", |
8908 |
|
|
.expectRealExitResult = 1.0, |
8909 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8910 |
|
|
.expectExitResultUnit = VM_SECOND |
8911 |
|
|
}); |
8912 |
|
|
|
8913 |
|
|
runScript({ |
8914 |
|
|
.code = R"NKSP_CODE( |
8915 |
|
|
on init |
8916 |
|
|
exit( cos(0.0kHz) ) |
8917 |
|
|
end on |
8918 |
|
|
)NKSP_CODE", |
8919 |
|
|
.expectRealExitResult = 1.0, |
8920 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8921 |
|
|
.expectExitResultUnit = VM_HERTZ |
8922 |
|
|
}); |
8923 |
|
|
|
8924 |
|
|
// 'final' ('!') operator tests ... |
8925 |
|
|
|
8926 |
|
|
runScript({ |
8927 |
|
|
.code = R"NKSP_CODE( |
8928 |
|
|
on init |
8929 |
|
|
exit( cos(0.0) ) |
8930 |
|
|
end on |
8931 |
|
|
)NKSP_CODE", |
8932 |
|
|
.expectRealExitResult = 1.0, |
8933 |
|
|
.expectExitResultFinal = false |
8934 |
|
|
}); |
8935 |
|
|
|
8936 |
|
|
runScript({ |
8937 |
|
|
.code = R"NKSP_CODE( |
8938 |
|
|
on init |
8939 |
|
|
exit( cos(!0.0) ) |
8940 |
|
|
end on |
8941 |
|
|
)NKSP_CODE", |
8942 |
|
|
.expectRealExitResult = 1.0, |
8943 |
|
|
.expectExitResultFinal = true |
8944 |
|
|
}); |
8945 |
|
|
|
8946 |
|
|
#if !SILENT_TEST |
8947 |
|
|
std::cout << std::endl; |
8948 |
|
|
#endif |
8949 |
|
|
} |
8950 |
|
|
|
8951 |
|
|
static void testBuiltInTanFunction() { |
8952 |
|
|
#if !SILENT_TEST |
8953 |
|
|
std::cout << "UNIT TEST: built-in tan() function\n"; |
8954 |
|
|
#endif |
8955 |
|
|
|
8956 |
|
|
// integer tests ... |
8957 |
|
|
// (ATM not allowed for this function) |
8958 |
|
|
|
8959 |
|
|
runScript({ |
8960 |
|
|
.code = R"NKSP_CODE( |
8961 |
|
|
on init |
8962 |
|
|
declare $foo := 1 |
8963 |
|
|
exit( tan($foo) ) |
8964 |
|
|
end on |
8965 |
|
|
)NKSP_CODE", |
8966 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
8967 |
|
|
}); |
8968 |
|
|
|
8969 |
|
|
// real number tests ... |
8970 |
|
|
|
8971 |
|
|
runScript({ |
8972 |
|
|
.code = R"NKSP_CODE( |
8973 |
|
|
on init |
8974 |
|
|
exit( tan(0.0) ) |
8975 |
|
|
end on |
8976 |
|
|
)NKSP_CODE", |
8977 |
|
|
.expectRealExitResult = 0.0 |
8978 |
|
|
}); |
8979 |
|
|
|
8980 |
|
|
runScript({ |
8981 |
|
|
.code = R"NKSP_CODE( |
8982 |
|
|
on init |
8983 |
|
|
exit( tan(0.25 * ~NI_MATH_PI) ) |
8984 |
|
|
end on |
8985 |
|
|
)NKSP_CODE", |
8986 |
|
|
.expectRealExitResult = 1.0 |
8987 |
|
|
}); |
8988 |
|
|
|
8989 |
|
|
// std unit tests ... |
8990 |
|
|
|
8991 |
|
|
runScript({ |
8992 |
|
|
.code = R"NKSP_CODE( |
8993 |
|
|
on init |
8994 |
|
|
exit( tan(0.0ms) ) |
8995 |
|
|
end on |
8996 |
|
|
)NKSP_CODE", |
8997 |
|
|
.expectRealExitResult = 0.0, |
8998 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8999 |
|
|
.expectExitResultUnit = VM_SECOND |
9000 |
|
|
}); |
9001 |
|
|
|
9002 |
|
|
runScript({ |
9003 |
|
|
.code = R"NKSP_CODE( |
9004 |
|
|
on init |
9005 |
|
|
exit( tan(0.0kHz) ) |
9006 |
|
|
end on |
9007 |
|
|
)NKSP_CODE", |
9008 |
|
|
.expectRealExitResult = 0.0, |
9009 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
9010 |
|
|
.expectExitResultUnit = VM_HERTZ |
9011 |
|
|
}); |
9012 |
|
|
|
9013 |
|
|
// 'final' ('!') operator tests ... |
9014 |
|
|
|
9015 |
|
|
runScript({ |
9016 |
|
|
.code = R"NKSP_CODE( |
9017 |
|
|
on init |
9018 |
|
|
exit( tan(0.0) ) |
9019 |
|
|
end on |
9020 |
|
|
)NKSP_CODE", |
9021 |
|
|
.expectRealExitResult = 0.0, |
9022 |
|
|
.expectExitResultFinal = false |
9023 |
|
|
}); |
9024 |
|
|
|
9025 |
|
|
runScript({ |
9026 |
|
|
.code = R"NKSP_CODE( |
9027 |
|
|
on init |
9028 |
|
|
exit( tan(!0.0) ) |
9029 |
|
|
end on |
9030 |
|
|
)NKSP_CODE", |
9031 |
|
|
.expectRealExitResult = 0.0, |
9032 |
|
|
.expectExitResultFinal = true |
9033 |
|
|
}); |
9034 |
|
|
|
9035 |
|
|
#if !SILENT_TEST |
9036 |
|
|
std::cout << std::endl; |
9037 |
|
|
#endif |
9038 |
|
|
} |
9039 |
|
|
|
9040 |
|
|
static void testBuiltInAsinFunction() { |
9041 |
|
|
#if !SILENT_TEST |
9042 |
|
|
std::cout << "UNIT TEST: built-in asin() function\n"; |
9043 |
|
|
#endif |
9044 |
|
|
|
9045 |
|
|
// integer tests ... |
9046 |
|
|
// (ATM not allowed for this function) |
9047 |
|
|
|
9048 |
|
|
runScript({ |
9049 |
|
|
.code = R"NKSP_CODE( |
9050 |
|
|
on init |
9051 |
|
|
declare $foo := 1 |
9052 |
|
|
exit( asin($foo) ) |
9053 |
|
|
end on |
9054 |
|
|
)NKSP_CODE", |
9055 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
9056 |
|
|
}); |
9057 |
|
|
|
9058 |
|
|
// real number tests ... |
9059 |
|
|
|
9060 |
|
|
runScript({ |
9061 |
|
|
.code = R"NKSP_CODE( |
9062 |
|
|
on init |
9063 |
|
|
exit( asin(0.0) ) |
9064 |
|
|
end on |
9065 |
|
|
)NKSP_CODE", |
9066 |
|
|
.expectRealExitResult = 0.0 |
9067 |
|
|
}); |
9068 |
|
|
|
9069 |
|
|
runScript({ |
9070 |
|
|
.code = R"NKSP_CODE( |
9071 |
|
|
on init |
9072 |
|
|
exit( asin(1.0) ) |
9073 |
|
|
end on |
9074 |
|
|
)NKSP_CODE", |
9075 |
|
|
.expectRealExitResult = 0.5 * M_PI |
9076 |
|
|
}); |
9077 |
|
|
|
9078 |
|
|
runScript({ |
9079 |
|
|
.code = R"NKSP_CODE( |
9080 |
|
|
on init |
9081 |
|
|
exit( asin(-1.0) ) |
9082 |
|
|
end on |
9083 |
|
|
)NKSP_CODE", |
9084 |
|
|
.expectRealExitResult = -0.5 * M_PI |
9085 |
|
|
}); |
9086 |
|
|
|
9087 |
|
|
// std unit tests ... |
9088 |
|
|
|
9089 |
|
|
runScript({ |
9090 |
|
|
.code = R"NKSP_CODE( |
9091 |
|
|
on init |
9092 |
|
|
exit( asin(0.0ms) ) |
9093 |
|
|
end on |
9094 |
|
|
)NKSP_CODE", |
9095 |
|
|
.expectRealExitResult = 0.0, |
9096 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
9097 |
|
|
.expectExitResultUnit = VM_SECOND |
9098 |
|
|
}); |
9099 |
|
|
|
9100 |
|
|
runScript({ |
9101 |
|
|
.code = R"NKSP_CODE( |
9102 |
|
|
on init |
9103 |
|
|
exit( asin(0.0kHz) ) |
9104 |
|
|
end on |
9105 |
|
|
)NKSP_CODE", |
9106 |
|
|
.expectRealExitResult = 0.0, |
9107 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
9108 |
|
|
.expectExitResultUnit = VM_HERTZ |
9109 |
|
|
}); |
9110 |
|
|
|
9111 |
|
|
// 'final' ('!') operator tests ... |
9112 |
|
|
|
9113 |
|
|
runScript({ |
9114 |
|
|
.code = R"NKSP_CODE( |
9115 |
|
|
on init |
9116 |
|
|
exit( asin(0.0) ) |
9117 |
|
|
end on |
9118 |
|
|
)NKSP_CODE", |
9119 |
|
|
.expectRealExitResult = 0.0, |
9120 |
|
|
.expectExitResultFinal = false |
9121 |
|
|
}); |
9122 |
|
|
|
9123 |
|
|
runScript({ |
9124 |
|
|
.code = R"NKSP_CODE( |
9125 |
|
|
on init |
9126 |
|
|
exit( asin(!0.0) ) |
9127 |
|
|
end on |
9128 |
|
|
)NKSP_CODE", |
9129 |
|
|
.expectRealExitResult = 0.0, |
9130 |
|
|
.expectExitResultFinal = true |
9131 |
|
|
}); |
9132 |
|
|
|
9133 |
|
|
#if !SILENT_TEST |
9134 |
|
|
std::cout << std::endl; |
9135 |
|
|
#endif |
9136 |
|
|
} |
9137 |
|
|
|
9138 |
|
|
static void testBuiltInAcosFunction() { |
9139 |
|
|
#if !SILENT_TEST |
9140 |
|
|
std::cout << "UNIT TEST: built-in acos() function\n"; |
9141 |
|
|
#endif |
9142 |
|
|
|
9143 |
|
|
// integer tests ... |
9144 |
|
|
// (ATM not allowed for this function) |
9145 |
|
|
|
9146 |
|
|
runScript({ |
9147 |
|
|
.code = R"NKSP_CODE( |
9148 |
|
|
on init |
9149 |
|
|
declare $foo := 1 |
9150 |
|
|
exit( acos($foo) ) |
9151 |
|
|
end on |
9152 |
|
|
)NKSP_CODE", |
9153 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
9154 |
|
|
}); |
9155 |
|
|
|
9156 |
|
|
// real number tests ... |
9157 |
|
|
|
9158 |
|
|
runScript({ |
9159 |
|
|
.code = R"NKSP_CODE( |
9160 |
|
|
on init |
9161 |
|
|
exit( acos(1.0) ) |
9162 |
|
|
end on |
9163 |
|
|
)NKSP_CODE", |
9164 |
|
|
.expectRealExitResult = 0.0 |
9165 |
|
|
}); |
9166 |
|
|
|
9167 |
|
|
runScript({ |
9168 |
|
|
.code = R"NKSP_CODE( |
9169 |
|
|
on init |
9170 |
|
|
exit( acos(0.0) ) |
9171 |
|
|
end on |
9172 |
|
|
)NKSP_CODE", |
9173 |
|
|
.expectRealExitResult = 0.5 * M_PI |
9174 |
|
|
}); |
9175 |
|
|
|
9176 |
|
|
runScript({ |
9177 |
|
|
.code = R"NKSP_CODE( |
9178 |
|
|
on init |
9179 |
|
|
exit( acos(-1.0) ) |
9180 |
|
|
end on |
9181 |
|
|
)NKSP_CODE", |
9182 |
|
|
.expectRealExitResult = M_PI |
9183 |
|
|
}); |
9184 |
|
|
|
9185 |
|
|
// std unit tests ... |
9186 |
|
|
|
9187 |
|
|
runScript({ |
9188 |
|
|
.code = R"NKSP_CODE( |
9189 |
|
|
on init |
9190 |
|
|
exit( acos(1.0ms) ) |
9191 |
|
|
end on |
9192 |
|
|
)NKSP_CODE", |
9193 |
|
|
.expectRealExitResult = 0.0, |
9194 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
9195 |
|
|
.expectExitResultUnit = VM_SECOND |
9196 |
|
|
}); |
9197 |
|
|
|
9198 |
|
|
runScript({ |
9199 |
|
|
.code = R"NKSP_CODE( |
9200 |
|
|
on init |
9201 |
|
|
exit( acos(1.0kHz) ) |
9202 |
|
|
end on |
9203 |
|
|
)NKSP_CODE", |
9204 |
|
|
.expectRealExitResult = 0.0, |
9205 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
9206 |
|
|
.expectExitResultUnit = VM_HERTZ |
9207 |
|
|
}); |
9208 |
|
|
|
9209 |
|
|
// 'final' ('!') operator tests ... |
9210 |
|
|
|
9211 |
|
|
runScript({ |
9212 |
|
|
.code = R"NKSP_CODE( |
9213 |
|
|
on init |
9214 |
|
|
exit( acos(1.0) ) |
9215 |
|
|
end on |
9216 |
|
|
)NKSP_CODE", |
9217 |
|
|
.expectRealExitResult = 0.0, |
9218 |
|
|
.expectExitResultFinal = false |
9219 |
|
|
}); |
9220 |
|
|
|
9221 |
|
|
runScript({ |
9222 |
|
|
.code = R"NKSP_CODE( |
9223 |
|
|
on init |
9224 |
|
|
exit( acos(!1.0) ) |
9225 |
|
|
end on |
9226 |
|
|
)NKSP_CODE", |
9227 |
|
|
.expectRealExitResult = 0.0, |
9228 |
|
|
.expectExitResultFinal = true |
9229 |
|
|
}); |
9230 |
|
|
|
9231 |
|
|
#if !SILENT_TEST |
9232 |
|
|
std::cout << std::endl; |
9233 |
|
|
#endif |
9234 |
|
|
} |
9235 |
|
|
|
9236 |
|
|
static void testBuiltInAtanFunction() { |
9237 |
|
|
#if !SILENT_TEST |
9238 |
|
|
std::cout << "UNIT TEST: built-in atan() function\n"; |
9239 |
|
|
#endif |
9240 |
|
|
|
9241 |
|
|
// integer tests ... |
9242 |
|
|
// (ATM not allowed for this function) |
9243 |
|
|
|
9244 |
|
|
runScript({ |
9245 |
|
|
.code = R"NKSP_CODE( |
9246 |
|
|
on init |
9247 |
|
|
declare $foo := 1 |
9248 |
|
|
exit( atan($foo) ) |
9249 |
|
|
end on |
9250 |
|
|
)NKSP_CODE", |
9251 |
|
|
.expectParseError = true // integer not allowed for this function ATM |
9252 |
|
|
}); |
9253 |
|
|
|
9254 |
|
|
// real number tests ... |
9255 |
|
|
|
9256 |
|
|
runScript({ |
9257 |
|
|
.code = R"NKSP_CODE( |
9258 |
|
|
on init |
9259 |
|
|
exit( atan(0.0) ) |
9260 |
|
|
end on |
9261 |
|
|
)NKSP_CODE", |
9262 |
|
|
.expectRealExitResult = 0.0 |
9263 |
|
|
}); |
9264 |
|
|
|
9265 |
|
|
runScript({ |
9266 |
|
|
.code = R"NKSP_CODE( |
9267 |
|
|
on init |
9268 |
|
|
exit( atan(1.0) ) |
9269 |
|
|
end on |
9270 |
|
|
)NKSP_CODE", |
9271 |
|
|
.expectRealExitResult = 0.25 * M_PI |
9272 |
|
|
}); |
9273 |
|
|
|
9274 |
|
|
// std unit tests ... |
9275 |
|
|
|
9276 |
|
|
runScript({ |
9277 |
|
|
.code = R"NKSP_CODE( |
9278 |
|
|
on init |
9279 |
|
|
exit( atan(0.0ms) ) |
9280 |
|
|
end on |
9281 |
|
|
)NKSP_CODE", |
9282 |
|
|
.expectRealExitResult = 0.0, |
9283 |
|
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
9284 |
|
|
.expectExitResultUnit = VM_SECOND |
9285 |
|
|
}); |
9286 |
|
|
|
9287 |
|
|
runScript({ |
9288 |
|
|
.code = R"NKSP_CODE( |
9289 |
|
|
on init |
9290 |
|
|
exit( atan(0.0kHz) ) |
9291 |
|
|
end on |
9292 |
|
|
)NKSP_CODE", |
9293 |
|
|
.expectRealExitResult = 0.0, |
9294 |
|
|
.expectExitResultUnitPrefix = { VM_KILO }, |
9295 |
|
|
.expectExitResultUnit = VM_HERTZ |
9296 |
|
|
}); |
9297 |
|
|
|
9298 |
|
|
// 'final' ('!') operator tests ... |
9299 |
|
|
|
9300 |
|
|
runScript({ |
9301 |
|
|
.code = R"NKSP_CODE( |
9302 |
|
|
on init |
9303 |
|
|
exit( atan(0.0) ) |
9304 |
|
|
end on |
9305 |
|
|
)NKSP_CODE", |
9306 |
|
|
.expectRealExitResult = 0.0, |
9307 |
|
|
.expectExitResultFinal = false |
9308 |
|
|
}); |
9309 |
|
|
|
9310 |
|
|
runScript({ |
9311 |
|
|
.code = R"NKSP_CODE( |
9312 |
|
|
on init |
9313 |
|
|
exit( atan(!0.0) ) |
9314 |
|
|
end on |
9315 |
|
|
)NKSP_CODE", |
9316 |
|
|
.expectRealExitResult = 0.0, |
9317 |
|
|
.expectExitResultFinal = true |
9318 |
|
|
}); |
9319 |
|
|
|
9320 |
|
|
#if !SILENT_TEST |
9321 |
|
|
std::cout << std::endl; |
9322 |
|
|
#endif |
9323 |
|
|
} |
9324 |
|
|
|
9325 |
schoenebeck |
3551 |
static void testBuiltInNumElementsFunction() { |
9326 |
|
|
#if !SILENT_TEST |
9327 |
|
|
std::cout << "UNIT TEST: built-in num_elements() function\n"; |
9328 |
|
|
#endif |
9329 |
|
|
|
9330 |
schoenebeck |
3581 |
// integer array tests ... |
9331 |
|
|
|
9332 |
schoenebeck |
3551 |
runScript({ |
9333 |
|
|
.code = R"NKSP_CODE( |
9334 |
|
|
on init |
9335 |
|
|
declare %foo[3] := ( 19, 3, 6 ) |
9336 |
|
|
exit( num_elements(%foo) ) |
9337 |
|
|
end on |
9338 |
|
|
)NKSP_CODE", |
9339 |
|
|
.expectIntExitResult = 3 |
9340 |
|
|
}); |
9341 |
|
|
|
9342 |
|
|
runScript({ |
9343 |
|
|
.code = R"NKSP_CODE( |
9344 |
|
|
on init |
9345 |
|
|
declare %foo[1] := ( 19 ) |
9346 |
|
|
exit( num_elements(%foo) ) |
9347 |
|
|
end on |
9348 |
|
|
)NKSP_CODE", |
9349 |
|
|
.expectIntExitResult = 1 |
9350 |
|
|
}); |
9351 |
|
|
|
9352 |
|
|
runScript({ |
9353 |
|
|
.code = R"NKSP_CODE( |
9354 |
|
|
on init |
9355 |
|
|
declare %foo[5] := ( 1, 2, 3, 4, 5 ) |
9356 |
|
|
exit( num_elements(%foo) ) |
9357 |
|
|
end on |
9358 |
|
|
)NKSP_CODE", |
9359 |
|
|
.expectIntExitResult = 5 |
9360 |
|
|
}); |
9361 |
|
|
|
9362 |
schoenebeck |
3581 |
// real array tests ... |
9363 |
|
|
|
9364 |
|
|
runScript({ |
9365 |
|
|
.code = R"NKSP_CODE( |
9366 |
|
|
on init |
9367 |
|
|
declare ?foo[3] := ( 19.0, 3.2, 6.5 ) |
9368 |
|
|
exit( num_elements(?foo) ) |
9369 |
|
|
end on |
9370 |
|
|
)NKSP_CODE", |
9371 |
|
|
.expectIntExitResult = 3 |
9372 |
|
|
}); |
9373 |
|
|
|
9374 |
|
|
runScript({ |
9375 |
|
|
.code = R"NKSP_CODE( |
9376 |
|
|
on init |
9377 |
|
|
declare ?foo[1] := ( 19.0 ) |
9378 |
|
|
exit( num_elements(?foo) ) |
9379 |
|
|
end on |
9380 |
|
|
)NKSP_CODE", |
9381 |
|
|
.expectIntExitResult = 1 |
9382 |
|
|
}); |
9383 |
|
|
|
9384 |
|
|
runScript({ |
9385 |
|
|
.code = R"NKSP_CODE( |
9386 |
|
|
on init |
9387 |
|
|
declare ?foo[5] := ( 1.1, 2.2, 3.3, 4.4, 5.5 ) |
9388 |
|
|
exit( num_elements(?foo) ) |
9389 |
|
|
end on |
9390 |
|
|
)NKSP_CODE", |
9391 |
|
|
.expectIntExitResult = 5 |
9392 |
|
|
}); |
9393 |
|
|
|
9394 |
schoenebeck |
3551 |
#if !SILENT_TEST |
9395 |
|
|
std::cout << std::endl; |
9396 |
|
|
#endif |
9397 |
|
|
} |
9398 |
|
|
|
9399 |
|
|
static void testBuiltInSearchFunction() { |
9400 |
|
|
#if !SILENT_TEST |
9401 |
|
|
std::cout << "UNIT TEST: built-in search() function\n"; |
9402 |
|
|
#endif |
9403 |
|
|
|
9404 |
schoenebeck |
3581 |
// integer array tests ... |
9405 |
|
|
|
9406 |
schoenebeck |
3551 |
runScript({ |
9407 |
|
|
.code = R"NKSP_CODE( |
9408 |
|
|
on init |
9409 |
|
|
declare %foo[3] := ( 19, 3, 6 ) |
9410 |
|
|
exit( search(%foo, 19) ) |
9411 |
|
|
end on |
9412 |
|
|
)NKSP_CODE", |
9413 |
|
|
.expectIntExitResult = 0 |
9414 |
|
|
}); |
9415 |
|
|
|
9416 |
|
|
runScript({ |
9417 |
|
|
.code = R"NKSP_CODE( |
9418 |
|
|
on init |
9419 |
|
|
declare %foo[3] := ( 19, 3, 6 ) |
9420 |
|
|
exit( search(%foo, 3) ) |
9421 |
|
|
end on |
9422 |
|
|
)NKSP_CODE", |
9423 |
|
|
.expectIntExitResult = 1 |
9424 |
|
|
}); |
9425 |
|
|
|
9426 |
|
|
runScript({ |
9427 |
|
|
.code = R"NKSP_CODE( |
9428 |
|
|
on init |
9429 |
|
|
declare %foo[3] := ( 19, 3, 6 ) |
9430 |
|
|
exit( search(%foo, 6) ) |
9431 |
|
|
end on |
9432 |
|
|
)NKSP_CODE", |
9433 |
|
|
.expectIntExitResult = 2 |
9434 |
|
|
}); |
9435 |
|
|
|
9436 |
|
|
runScript({ |
9437 |
|
|
.code = R"NKSP_CODE( |
9438 |
|
|
on init |
9439 |
|
|
declare %foo[3] := ( 19, 3, 6 ) |
9440 |
|
|
exit( search(%foo, 2) ) |
9441 |
|
|
end on |
9442 |
|
|
)NKSP_CODE", |
9443 |
|
|
.expectIntExitResult = -1 |
9444 |
|
|
}); |
9445 |
|
|
|
9446 |
schoenebeck |
3581 |
// real array tests ... |
9447 |
|
|
|
9448 |
|
|
runScript({ |
9449 |
|
|
.code = R"NKSP_CODE( |
9450 |
|
|
on init |
9451 |
|
|
declare ?foo[3] := ( 19.12, 3.45, 6.89 ) |
9452 |
|
|
exit( search(?foo, 19.12) ) |
9453 |
|
|
end on |
9454 |
|
|
)NKSP_CODE", |
9455 |
|
|
.expectIntExitResult = 0 |
9456 |
|
|
}); |
9457 |
|
|
|
9458 |
|
|
runScript({ |
9459 |
|
|
.code = R"NKSP_CODE( |
9460 |
|
|
on init |
9461 |
|
|
declare ?foo[3] := ( 19.12, 3.45, 6.89 ) |
9462 |
|
|
exit( search(?foo, 3.45) ) |
9463 |
|
|
end on |
9464 |
|
|
)NKSP_CODE", |
9465 |
|
|
.expectIntExitResult = 1 |
9466 |
|
|
}); |
9467 |
|
|
|
9468 |
|
|
runScript({ |
9469 |
|
|
.code = R"NKSP_CODE( |
9470 |
|
|
on init |
9471 |
|
|
declare ?foo[3] := ( 19.12, 3.45, 6.89 ) |
9472 |
|
|
exit( search(?foo, 6.89) ) |
9473 |
|
|
end on |
9474 |
|
|
)NKSP_CODE", |
9475 |
|
|
.expectIntExitResult = 2 |
9476 |
|
|
}); |
9477 |
|
|
|
9478 |
|
|
runScript({ |
9479 |
|
|
.code = R"NKSP_CODE( |
9480 |
|
|
on init |
9481 |
|
|
declare ?foo[3] := ( 19.12, 3.45, 6.89 ) |
9482 |
|
|
exit( search(?foo, 6.99) ) |
9483 |
|
|
end on |
9484 |
|
|
)NKSP_CODE", |
9485 |
|
|
.expectIntExitResult = -1 |
9486 |
|
|
}); |
9487 |
|
|
|
9488 |
schoenebeck |
3551 |
#if !SILENT_TEST |
9489 |
|
|
std::cout << std::endl; |
9490 |
|
|
#endif |
9491 |
|
|
} |
9492 |
|
|
|
9493 |
|
|
static void testIfStatement() { |
9494 |
|
|
#if !SILENT_TEST |
9495 |
|
|
std::cout << "UNIT TEST: if statement\n"; |
9496 |
|
|
#endif |
9497 |
|
|
|
9498 |
|
|
runScript({ |
9499 |
|
|
.code = R"NKSP_CODE( |
9500 |
|
|
on init |
9501 |
|
|
declare $foo := 1 |
9502 |
|
|
if ($foo) |
9503 |
|
|
exit(42) |
9504 |
|
|
end if |
9505 |
|
|
end on |
9506 |
|
|
)NKSP_CODE", |
9507 |
|
|
.expectIntExitResult = 42 |
9508 |
|
|
}); |
9509 |
|
|
|
9510 |
|
|
runScript({ |
9511 |
|
|
.code = R"NKSP_CODE( |
9512 |
|
|
on init |
9513 |
|
|
declare $foo := 0 |
9514 |
|
|
if ($foo) |
9515 |
|
|
exit(42) |
9516 |
|
|
end if |
9517 |
|
|
exit(3) |
9518 |
|
|
end on |
9519 |
|
|
)NKSP_CODE", |
9520 |
|
|
.expectIntExitResult = 3 |
9521 |
|
|
}); |
9522 |
|
|
|
9523 |
|
|
runScript({ |
9524 |
|
|
.code = R"NKSP_CODE( |
9525 |
|
|
on init |
9526 |
|
|
declare $foo := 1 |
9527 |
|
|
if ($foo) |
9528 |
|
|
exit(42) |
9529 |
|
|
else |
9530 |
|
|
exit(3) |
9531 |
|
|
end if |
9532 |
|
|
end on |
9533 |
|
|
)NKSP_CODE", |
9534 |
|
|
.expectIntExitResult = 42 |
9535 |
|
|
}); |
9536 |
|
|
|
9537 |
|
|
runScript({ |
9538 |
|
|
.code = R"NKSP_CODE( |
9539 |
|
|
on init |
9540 |
|
|
declare $foo := 0 |
9541 |
|
|
if ($foo) |
9542 |
|
|
exit(42) |
9543 |
|
|
else |
9544 |
|
|
exit(3) |
9545 |
|
|
end if |
9546 |
|
|
end on |
9547 |
|
|
)NKSP_CODE", |
9548 |
|
|
.expectIntExitResult = 3 |
9549 |
|
|
}); |
9550 |
|
|
|
9551 |
|
|
#if !SILENT_TEST |
9552 |
|
|
std::cout << std::endl; |
9553 |
|
|
#endif |
9554 |
|
|
} |
9555 |
|
|
|
9556 |
|
|
static void testWhileStatement() { |
9557 |
|
|
#if !SILENT_TEST |
9558 |
|
|
std::cout << "UNIT TEST: while statement\n"; |
9559 |
|
|
#endif |
9560 |
|
|
|
9561 |
|
|
runScript({ |
9562 |
|
|
.code = R"NKSP_CODE( |
9563 |
|
|
on init |
9564 |
|
|
declare $foo := 100 |
9565 |
|
|
declare $i := 50 |
9566 |
|
|
while ($i) |
9567 |
|
|
$foo := $foo + 1 |
9568 |
|
|
$i := $i - 1 |
9569 |
|
|
end while |
9570 |
|
|
exit($foo) |
9571 |
|
|
end on |
9572 |
|
|
)NKSP_CODE", |
9573 |
|
|
.expectIntExitResult = 150 |
9574 |
|
|
}); |
9575 |
|
|
|
9576 |
|
|
#if !SILENT_TEST |
9577 |
|
|
std::cout << std::endl; |
9578 |
|
|
#endif |
9579 |
|
|
} |
9580 |
|
|
|
9581 |
|
|
#if !NO_MAIN |
9582 |
|
|
|
9583 |
|
|
int main() { |
9584 |
|
|
testBuiltInExitFunction(); |
9585 |
|
|
testStringConcatOperator(); |
9586 |
schoenebeck |
3575 |
testNegOperator(); |
9587 |
schoenebeck |
3551 |
testPlusOperator(); |
9588 |
|
|
testMinusOperator(); |
9589 |
|
|
testModuloOperator(); |
9590 |
|
|
testMultiplyOperator(); |
9591 |
|
|
testDivideOperator(); |
9592 |
|
|
testSmallerThanOperator(); |
9593 |
|
|
testGreaterThanOperator(); |
9594 |
|
|
testSmallerOrEqualOperator(); |
9595 |
|
|
testGreaterOrEqualOperator(); |
9596 |
|
|
testEqualOperator(); |
9597 |
|
|
testUnequalOperator(); |
9598 |
|
|
testLogicalAndOperator(); |
9599 |
|
|
testLogicalOrOperator(); |
9600 |
|
|
testLogicalNotOperator(); |
9601 |
|
|
testBitwiseAndOperator(); |
9602 |
|
|
testBitwiseOrOperator(); |
9603 |
|
|
testBitwiseNotOperator(); |
9604 |
|
|
testPrecedenceOfOperators(); |
9605 |
|
|
testBuiltInMinFunction(); |
9606 |
|
|
testBuiltInMaxFunction(); |
9607 |
|
|
testBuiltInAbsFunction(); |
9608 |
|
|
testBuiltInIncFunction(); |
9609 |
|
|
testBuiltInDecFunction(); |
9610 |
|
|
testBuiltInInRangeFunction(); |
9611 |
|
|
testBuiltInRandomFunction(); |
9612 |
|
|
testBuiltInShiftLeftFunction(); |
9613 |
|
|
testBuiltInShiftRightFunction(); |
9614 |
schoenebeck |
3575 |
testBuiltInIntToRealFunction(); |
9615 |
|
|
testBuiltInRealFunction(); |
9616 |
|
|
testBuiltInRealToIntFunction(); |
9617 |
|
|
testBuiltInIntFunction(); |
9618 |
schoenebeck |
3590 |
testBuiltInRoundFunction(); |
9619 |
|
|
testBuiltInCeilFunction(); |
9620 |
|
|
testBuiltInFloorFunction(); |
9621 |
|
|
testBuiltInSqrtFunction(); |
9622 |
|
|
testBuiltInLogFunction(); |
9623 |
|
|
testBuiltInLog2Function(); |
9624 |
|
|
testBuiltInLog10Function(); |
9625 |
|
|
testBuiltInExpFunction(); |
9626 |
|
|
testBuiltInPowFunction(); |
9627 |
|
|
testBuiltInSinFunction(); |
9628 |
|
|
testBuiltInCosFunction(); |
9629 |
|
|
testBuiltInTanFunction(); |
9630 |
|
|
testBuiltInAsinFunction(); |
9631 |
|
|
testBuiltInAcosFunction(); |
9632 |
|
|
testBuiltInAtanFunction(); |
9633 |
schoenebeck |
3551 |
testBuiltInArrayEqualFunction(); |
9634 |
|
|
testBuiltInSortFunction(); |
9635 |
|
|
testBuiltInNumElementsFunction(); |
9636 |
|
|
testBuiltInSearchFunction(); |
9637 |
|
|
testIfStatement(); |
9638 |
|
|
testWhileStatement(); |
9639 |
|
|
std::cout << "\nAll tests passed successfully. :-)\n"; |
9640 |
|
|
return 0; |
9641 |
|
|
} |
9642 |
|
|
|
9643 |
|
|
#endif // !NO_MAIN |