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