12 |
|
|
13 |
#include "../../common/global.h" |
#include "../../common/global.h" |
14 |
#include "../../common/optional.h" |
#include "../../common/optional.h" |
15 |
|
#include "../../common/RTMath.h" |
16 |
#include "../ScriptVM.h" |
#include "../ScriptVM.h" |
17 |
#include "../common.h" |
#include "../common.h" |
18 |
#include <sstream> |
#include <sstream> |
34 |
bool expectRuntimeError; |
bool expectRuntimeError; |
35 |
bool expectNoExitResult; |
bool expectNoExitResult; |
36 |
bool prohibitExitFunctionArguments; |
bool prohibitExitFunctionArguments; |
37 |
optional<int> expectIntExitResult; |
optional<vmint> expectIntExitResult; |
38 |
optional<bool> expectBoolExitResult; |
optional<bool> expectBoolExitResult; |
39 |
|
optional<vmfloat> expectRealExitResult; |
40 |
optional<String> expectStringExitResult; |
optional<String> expectStringExitResult; |
41 |
}; |
}; |
42 |
|
|
80 |
TEST_ASSERT(resExpr->exprType() == INT_EXPR); |
TEST_ASSERT(resExpr->exprType() == INT_EXPR); |
81 |
TEST_ASSERT(resExpr->asInt()->evalInt() == *opt.expectIntExitResult); |
TEST_ASSERT(resExpr->asInt()->evalInt() == *opt.expectIntExitResult); |
82 |
} |
} |
83 |
|
if (opt.expectRealExitResult) { |
84 |
|
VMExpr* resExpr = execCtx->exitResult(); |
85 |
|
TEST_ASSERT(resExpr); |
86 |
|
TEST_ASSERT(resExpr->exprType() == REAL_EXPR); |
87 |
|
if (sizeof(vmfloat) == sizeof(float)) { |
88 |
|
TEST_ASSERT(RTMath::fEqual32(resExpr->asReal()->evalReal(), *opt.expectRealExitResult)); |
89 |
|
} else { |
90 |
|
TEST_ASSERT(RTMath::fEqual64(resExpr->asReal()->evalReal(), *opt.expectRealExitResult)); |
91 |
|
} |
92 |
|
} |
93 |
if (opt.expectBoolExitResult) { |
if (opt.expectBoolExitResult) { |
94 |
VMExpr* resExpr = execCtx->exitResult(); |
VMExpr* resExpr = execCtx->exitResult(); |
95 |
TEST_ASSERT(resExpr); |
TEST_ASSERT(resExpr); |
136 |
.expectNoExitResult = true |
.expectNoExitResult = true |
137 |
}); |
}); |
138 |
|
|
139 |
|
// integer tests ... |
140 |
|
|
141 |
runScript({ |
runScript({ |
142 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
143 |
on init |
on init |
172 |
.expectIntExitResult = 99 |
.expectIntExitResult = 99 |
173 |
}); |
}); |
174 |
|
|
175 |
|
// string tests ... |
176 |
|
|
177 |
runScript({ |
runScript({ |
178 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
179 |
on init |
on init |
195 |
.prohibitExitFunctionArguments = true // simulate production environment |
.prohibitExitFunctionArguments = true // simulate production environment |
196 |
}); |
}); |
197 |
|
|
198 |
|
// real number tests ... |
199 |
|
|
200 |
|
runScript({ |
201 |
|
.code = R"NKSP_CODE( |
202 |
|
on init |
203 |
|
exit(3.14) |
204 |
|
end on |
205 |
|
)NKSP_CODE", |
206 |
|
.expectRealExitResult = 3.14 |
207 |
|
}); |
208 |
|
|
209 |
|
runScript({ |
210 |
|
.code = R"NKSP_CODE( |
211 |
|
on init |
212 |
|
declare $foo := 1 |
213 |
|
if ($foo) |
214 |
|
exit(3.14) |
215 |
|
end if |
216 |
|
end on |
217 |
|
)NKSP_CODE", |
218 |
|
.expectRealExitResult = 3.14 |
219 |
|
}); |
220 |
|
|
221 |
|
runScript({ |
222 |
|
.code = R"NKSP_CODE( |
223 |
|
on init |
224 |
|
declare $foo := 0 |
225 |
|
if ($foo) |
226 |
|
exit(3.14) |
227 |
|
end if |
228 |
|
exit(6.9) |
229 |
|
end on |
230 |
|
)NKSP_CODE", |
231 |
|
.expectRealExitResult = 6.9 |
232 |
|
}); |
233 |
|
|
234 |
#if !SILENT_TEST |
#if !SILENT_TEST |
235 |
std::cout << std::endl; |
std::cout << std::endl; |
236 |
#endif |
#endif |
277 |
#endif |
#endif |
278 |
} |
} |
279 |
|
|
280 |
|
static void testNegOperator() { |
281 |
|
#if !SILENT_TEST |
282 |
|
std::cout << "UNIT TEST: negate (-) operator\n"; |
283 |
|
#endif |
284 |
|
|
285 |
|
// integer tests ... |
286 |
|
|
287 |
|
runScript({ |
288 |
|
.code = R"NKSP_CODE( |
289 |
|
on init |
290 |
|
exit(-87) |
291 |
|
end on |
292 |
|
)NKSP_CODE", |
293 |
|
.expectIntExitResult = -87 |
294 |
|
}); |
295 |
|
|
296 |
|
runScript({ |
297 |
|
.code = R"NKSP_CODE( |
298 |
|
on init |
299 |
|
declare $foo := -87 |
300 |
|
exit(-$foo) |
301 |
|
end on |
302 |
|
)NKSP_CODE", |
303 |
|
.expectIntExitResult = 87 |
304 |
|
}); |
305 |
|
|
306 |
|
// real number tests ... |
307 |
|
|
308 |
|
runScript({ |
309 |
|
.code = R"NKSP_CODE( |
310 |
|
on init |
311 |
|
exit(-99.3) |
312 |
|
end on |
313 |
|
)NKSP_CODE", |
314 |
|
.expectRealExitResult = -99.3 |
315 |
|
}); |
316 |
|
|
317 |
|
runScript({ |
318 |
|
.code = R"NKSP_CODE( |
319 |
|
on init |
320 |
|
declare ~foo := -99.3 |
321 |
|
exit(-~foo) |
322 |
|
end on |
323 |
|
)NKSP_CODE", |
324 |
|
.expectRealExitResult = 99.3 |
325 |
|
}); |
326 |
|
|
327 |
|
#if !SILENT_TEST |
328 |
|
std::cout << std::endl; |
329 |
|
#endif |
330 |
|
} |
331 |
|
|
332 |
static void testPlusOperator() { |
static void testPlusOperator() { |
333 |
#if !SILENT_TEST |
#if !SILENT_TEST |
334 |
std::cout << "UNIT TEST: plus (+) operator\n"; |
std::cout << "UNIT TEST: plus (+) operator\n"; |
335 |
#endif |
#endif |
336 |
|
|
337 |
|
// integer tests ... |
338 |
|
|
339 |
runScript({ |
runScript({ |
340 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
341 |
on init |
on init |
363 |
.expectIntExitResult = -2 |
.expectIntExitResult = -2 |
364 |
}); |
}); |
365 |
|
|
366 |
|
// real number tests ... |
367 |
|
|
368 |
|
runScript({ |
369 |
|
.code = R"NKSP_CODE( |
370 |
|
on init |
371 |
|
exit(4.0 + 3.0) |
372 |
|
end on |
373 |
|
)NKSP_CODE", |
374 |
|
.expectRealExitResult = 7.0 |
375 |
|
}); |
376 |
|
|
377 |
|
runScript({ |
378 |
|
.code = R"NKSP_CODE( |
379 |
|
on init |
380 |
|
exit(42.3 + 145.2) |
381 |
|
end on |
382 |
|
)NKSP_CODE", |
383 |
|
.expectRealExitResult = 187.5 |
384 |
|
}); |
385 |
|
|
386 |
|
runScript({ |
387 |
|
.code = R"NKSP_CODE( |
388 |
|
on init |
389 |
|
exit(-4.0 + 2.2) |
390 |
|
end on |
391 |
|
)NKSP_CODE", |
392 |
|
.expectRealExitResult = -1.8 |
393 |
|
}); |
394 |
|
|
395 |
#if !SILENT_TEST |
#if !SILENT_TEST |
396 |
std::cout << std::endl; |
std::cout << std::endl; |
397 |
#endif |
#endif |
402 |
std::cout << "UNIT TEST: minus (-) operator\n"; |
std::cout << "UNIT TEST: minus (-) operator\n"; |
403 |
#endif |
#endif |
404 |
|
|
405 |
|
// integer tests ... |
406 |
|
|
407 |
runScript({ |
runScript({ |
408 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
409 |
on init |
on init |
440 |
.expectIntExitResult = -21 |
.expectIntExitResult = -21 |
441 |
}); |
}); |
442 |
|
|
443 |
|
// real number tests ... |
444 |
|
|
445 |
|
runScript({ |
446 |
|
.code = R"NKSP_CODE( |
447 |
|
on init |
448 |
|
exit(4.0 - 0.2) |
449 |
|
end on |
450 |
|
)NKSP_CODE", |
451 |
|
.expectRealExitResult = 3.8 |
452 |
|
}); |
453 |
|
|
454 |
|
runScript({ |
455 |
|
.code = R"NKSP_CODE( |
456 |
|
on init |
457 |
|
exit(3.1 - 9.65) |
458 |
|
end on |
459 |
|
)NKSP_CODE", |
460 |
|
.expectRealExitResult = -6.55 |
461 |
|
}); |
462 |
|
|
463 |
|
runScript({ |
464 |
|
.code = R"NKSP_CODE( |
465 |
|
on init |
466 |
|
exit(-3.0 - 18.1) |
467 |
|
end on |
468 |
|
)NKSP_CODE", |
469 |
|
.expectRealExitResult = -21.1 |
470 |
|
}); |
471 |
|
|
472 |
#if !SILENT_TEST |
#if !SILENT_TEST |
473 |
std::cout << std::endl; |
std::cout << std::endl; |
474 |
#endif |
#endif |
479 |
std::cout << "UNIT TEST: modulo (mod) operator\n"; |
std::cout << "UNIT TEST: modulo (mod) operator\n"; |
480 |
#endif |
#endif |
481 |
|
|
482 |
|
// integer tests ... |
483 |
|
|
484 |
runScript({ |
runScript({ |
485 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
486 |
on init |
on init |
490 |
.expectIntExitResult = 2 |
.expectIntExitResult = 2 |
491 |
}); |
}); |
492 |
|
|
493 |
|
runScript({ |
494 |
|
.code = R"NKSP_CODE( |
495 |
|
on init |
496 |
|
declare $a := 10 |
497 |
|
declare $b := 8 |
498 |
|
exit($a mod $b) |
499 |
|
end on |
500 |
|
)NKSP_CODE", |
501 |
|
.expectIntExitResult = 2 |
502 |
|
}); |
503 |
|
|
504 |
|
// real number tests ... |
505 |
|
// (mod operator prohibits real numbers ATM) |
506 |
|
|
507 |
|
runScript({ |
508 |
|
.code = R"NKSP_CODE( |
509 |
|
on init |
510 |
|
exit(10.0 mod 8.0) |
511 |
|
end on |
512 |
|
)NKSP_CODE", |
513 |
|
.expectParseError = true // mod operator prohibits real numbers ATM |
514 |
|
}); |
515 |
|
|
516 |
|
runScript({ |
517 |
|
.code = R"NKSP_CODE( |
518 |
|
on init |
519 |
|
exit(10 mod 8.0) |
520 |
|
end on |
521 |
|
)NKSP_CODE", |
522 |
|
.expectParseError = true // mod operator prohibits real numbers ATM |
523 |
|
}); |
524 |
|
|
525 |
|
runScript({ |
526 |
|
.code = R"NKSP_CODE( |
527 |
|
on init |
528 |
|
exit(10.0 mod 8) |
529 |
|
end on |
530 |
|
)NKSP_CODE", |
531 |
|
.expectParseError = true // mod operator prohibits real numbers ATM |
532 |
|
}); |
533 |
|
|
534 |
|
runScript({ |
535 |
|
.code = R"NKSP_CODE( |
536 |
|
on init |
537 |
|
declare ~a := 10.0 |
538 |
|
declare ~b := 8.0 |
539 |
|
exit(~a mod ~b) |
540 |
|
end on |
541 |
|
)NKSP_CODE", |
542 |
|
.expectParseError = true // mod operator prohibits real numbers ATM |
543 |
|
}); |
544 |
|
|
545 |
#if !SILENT_TEST |
#if !SILENT_TEST |
546 |
std::cout << std::endl; |
std::cout << std::endl; |
547 |
#endif |
#endif |
552 |
std::cout << "UNIT TEST: multiply (*) operator\n"; |
std::cout << "UNIT TEST: multiply (*) operator\n"; |
553 |
#endif |
#endif |
554 |
|
|
555 |
|
// integer tests ... |
556 |
|
|
557 |
runScript({ |
runScript({ |
558 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
559 |
on init |
on init |
590 |
.expectIntExitResult = -7257 |
.expectIntExitResult = -7257 |
591 |
}); |
}); |
592 |
|
|
593 |
|
// real number tests ... |
594 |
|
|
595 |
|
runScript({ |
596 |
|
.code = R"NKSP_CODE( |
597 |
|
on init |
598 |
|
exit(10.2 * 8.4) |
599 |
|
end on |
600 |
|
)NKSP_CODE", |
601 |
|
.expectRealExitResult = 85.68 |
602 |
|
}); |
603 |
|
|
604 |
|
runScript({ |
605 |
|
.code = R"NKSP_CODE( |
606 |
|
on init |
607 |
|
exit(10.0 * -3.33) |
608 |
|
end on |
609 |
|
)NKSP_CODE", |
610 |
|
.expectRealExitResult = -33.3 |
611 |
|
}); |
612 |
|
|
613 |
|
runScript({ |
614 |
|
.code = R"NKSP_CODE( |
615 |
|
on init |
616 |
|
exit(-3.33 * 10.0) |
617 |
|
end on |
618 |
|
)NKSP_CODE", |
619 |
|
.expectRealExitResult = -33.3 |
620 |
|
}); |
621 |
|
|
622 |
|
runScript({ |
623 |
|
.code = R"NKSP_CODE( |
624 |
|
on init |
625 |
|
exit(-3.33 * -10.0) |
626 |
|
end on |
627 |
|
)NKSP_CODE", |
628 |
|
.expectRealExitResult = 33.3 |
629 |
|
}); |
630 |
|
|
631 |
|
// mixed type tests ... |
632 |
|
// (mixed int * real forbidden ATM) |
633 |
|
|
634 |
|
runScript({ |
635 |
|
.code = R"NKSP_CODE( |
636 |
|
on init |
637 |
|
exit(2 * 3.0) |
638 |
|
end on |
639 |
|
)NKSP_CODE", |
640 |
|
.expectParseError = true // mixed int * real forbidden ATM |
641 |
|
}); |
642 |
|
|
643 |
|
runScript({ |
644 |
|
.code = R"NKSP_CODE( |
645 |
|
on init |
646 |
|
exit(2.0 * 3) |
647 |
|
end on |
648 |
|
)NKSP_CODE", |
649 |
|
.expectParseError = true // mixed int * real forbidden ATM |
650 |
|
}); |
651 |
|
|
652 |
#if !SILENT_TEST |
#if !SILENT_TEST |
653 |
std::cout << std::endl; |
std::cout << std::endl; |
654 |
#endif |
#endif |
659 |
std::cout << "UNIT TEST: divide (/) operator\n"; |
std::cout << "UNIT TEST: divide (/) operator\n"; |
660 |
#endif |
#endif |
661 |
|
|
662 |
|
// integer tests ... |
663 |
|
|
664 |
runScript({ |
runScript({ |
665 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
666 |
on init |
on init |
697 |
.expectIntExitResult = -7 |
.expectIntExitResult = -7 |
698 |
}); |
}); |
699 |
|
|
700 |
|
// real number tests ... |
701 |
|
|
702 |
|
runScript({ |
703 |
|
.code = R"NKSP_CODE( |
704 |
|
on init |
705 |
|
exit(9.0 / 10.0) |
706 |
|
end on |
707 |
|
)NKSP_CODE", |
708 |
|
.expectRealExitResult = 0.9 |
709 |
|
}); |
710 |
|
|
711 |
|
runScript({ |
712 |
|
.code = R"NKSP_CODE( |
713 |
|
on init |
714 |
|
exit(-9.0 / 10.0) |
715 |
|
end on |
716 |
|
)NKSP_CODE", |
717 |
|
.expectRealExitResult = -0.9 |
718 |
|
}); |
719 |
|
|
720 |
|
runScript({ |
721 |
|
.code = R"NKSP_CODE( |
722 |
|
on init |
723 |
|
exit(9.0 / -10.0) |
724 |
|
end on |
725 |
|
)NKSP_CODE", |
726 |
|
.expectRealExitResult = -0.9 |
727 |
|
}); |
728 |
|
|
729 |
|
runScript({ |
730 |
|
.code = R"NKSP_CODE( |
731 |
|
on init |
732 |
|
exit(-9.0 / -10.0) |
733 |
|
end on |
734 |
|
)NKSP_CODE", |
735 |
|
.expectRealExitResult = 0.9 |
736 |
|
}); |
737 |
|
|
738 |
|
// mixed type tests ... |
739 |
|
// (mixed int / real forbidden ATM) |
740 |
|
|
741 |
|
runScript({ |
742 |
|
.code = R"NKSP_CODE( |
743 |
|
on init |
744 |
|
exit(9 / 10.0) |
745 |
|
end on |
746 |
|
)NKSP_CODE", |
747 |
|
.expectParseError = true // mixed int / real forbidden ATM |
748 |
|
}); |
749 |
|
|
750 |
|
runScript({ |
751 |
|
.code = R"NKSP_CODE( |
752 |
|
on init |
753 |
|
exit(9.0 / 10) |
754 |
|
end on |
755 |
|
)NKSP_CODE", |
756 |
|
.expectParseError = true // mixed int / real forbidden ATM |
757 |
|
}); |
758 |
|
|
759 |
#if !SILENT_TEST |
#if !SILENT_TEST |
760 |
std::cout << std::endl; |
std::cout << std::endl; |
761 |
#endif |
#endif |
766 |
std::cout << "UNIT TEST: smaller than (<) operator\n"; |
std::cout << "UNIT TEST: smaller than (<) operator\n"; |
767 |
#endif |
#endif |
768 |
|
|
769 |
|
// integer tests ... |
770 |
|
|
771 |
runScript({ |
runScript({ |
772 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
773 |
on init |
on init |
822 |
.expectBoolExitResult = true |
.expectBoolExitResult = true |
823 |
}); |
}); |
824 |
|
|
825 |
|
// real number tests ... |
826 |
|
|
827 |
|
runScript({ |
828 |
|
.code = R"NKSP_CODE( |
829 |
|
on init |
830 |
|
exit(3.0 < 4.0) |
831 |
|
end on |
832 |
|
)NKSP_CODE", |
833 |
|
.expectBoolExitResult = true |
834 |
|
}); |
835 |
|
|
836 |
|
runScript({ |
837 |
|
.code = R"NKSP_CODE( |
838 |
|
on init |
839 |
|
exit(4.0 < 3.0) |
840 |
|
end on |
841 |
|
)NKSP_CODE", |
842 |
|
.expectBoolExitResult = false |
843 |
|
}); |
844 |
|
|
845 |
|
runScript({ |
846 |
|
.code = R"NKSP_CODE( |
847 |
|
on init |
848 |
|
exit(1.2 < 1.23) |
849 |
|
end on |
850 |
|
)NKSP_CODE", |
851 |
|
.expectBoolExitResult = true |
852 |
|
}); |
853 |
|
|
854 |
|
runScript({ |
855 |
|
.code = R"NKSP_CODE( |
856 |
|
on init |
857 |
|
exit(1.23 < 1.2) |
858 |
|
end on |
859 |
|
)NKSP_CODE", |
860 |
|
.expectBoolExitResult = false |
861 |
|
}); |
862 |
|
|
863 |
|
runScript({ |
864 |
|
.code = R"NKSP_CODE( |
865 |
|
on init |
866 |
|
exit(-4.0 < 3.0) |
867 |
|
end on |
868 |
|
)NKSP_CODE", |
869 |
|
.expectBoolExitResult = true |
870 |
|
}); |
871 |
|
|
872 |
|
runScript({ |
873 |
|
.code = R"NKSP_CODE( |
874 |
|
on init |
875 |
|
exit(3.0 < -4.0) |
876 |
|
end on |
877 |
|
)NKSP_CODE", |
878 |
|
.expectBoolExitResult = false |
879 |
|
}); |
880 |
|
|
881 |
|
runScript({ |
882 |
|
.code = R"NKSP_CODE( |
883 |
|
on init |
884 |
|
exit(123.0 < -45.0) |
885 |
|
end on |
886 |
|
)NKSP_CODE", |
887 |
|
.expectBoolExitResult = false |
888 |
|
}); |
889 |
|
|
890 |
|
runScript({ |
891 |
|
.code = R"NKSP_CODE( |
892 |
|
on init |
893 |
|
exit(-45.0 < 123.0) |
894 |
|
end on |
895 |
|
)NKSP_CODE", |
896 |
|
.expectBoolExitResult = true |
897 |
|
}); |
898 |
|
|
899 |
|
// mixed type tests ... |
900 |
|
|
901 |
|
runScript({ |
902 |
|
.code = R"NKSP_CODE( |
903 |
|
on init |
904 |
|
exit(9 < 9.1) |
905 |
|
end on |
906 |
|
)NKSP_CODE", |
907 |
|
.expectBoolExitResult = true |
908 |
|
}); |
909 |
|
|
910 |
|
runScript({ |
911 |
|
.code = R"NKSP_CODE( |
912 |
|
on init |
913 |
|
exit(9.1 < 9) |
914 |
|
end on |
915 |
|
)NKSP_CODE", |
916 |
|
.expectBoolExitResult = false |
917 |
|
}); |
918 |
|
|
919 |
#if !SILENT_TEST |
#if !SILENT_TEST |
920 |
std::cout << std::endl; |
std::cout << std::endl; |
921 |
#endif |
#endif |
926 |
std::cout << "UNIT TEST: greater than (>) operator\n"; |
std::cout << "UNIT TEST: greater than (>) operator\n"; |
927 |
#endif |
#endif |
928 |
|
|
929 |
|
// integer tests ... |
930 |
|
|
931 |
runScript({ |
runScript({ |
932 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
933 |
on init |
on init |
982 |
.expectBoolExitResult = false |
.expectBoolExitResult = false |
983 |
}); |
}); |
984 |
|
|
985 |
|
// real number tests ... |
986 |
|
|
987 |
|
runScript({ |
988 |
|
.code = R"NKSP_CODE( |
989 |
|
on init |
990 |
|
exit(3.0 > 4.0) |
991 |
|
end on |
992 |
|
)NKSP_CODE", |
993 |
|
.expectBoolExitResult = false |
994 |
|
}); |
995 |
|
|
996 |
|
runScript({ |
997 |
|
.code = R"NKSP_CODE( |
998 |
|
on init |
999 |
|
exit(4.0 > 3.0) |
1000 |
|
end on |
1001 |
|
)NKSP_CODE", |
1002 |
|
.expectBoolExitResult = true |
1003 |
|
}); |
1004 |
|
|
1005 |
|
runScript({ |
1006 |
|
.code = R"NKSP_CODE( |
1007 |
|
on init |
1008 |
|
exit(1.2 > 1.23) |
1009 |
|
end on |
1010 |
|
)NKSP_CODE", |
1011 |
|
.expectBoolExitResult = false |
1012 |
|
}); |
1013 |
|
|
1014 |
|
runScript({ |
1015 |
|
.code = R"NKSP_CODE( |
1016 |
|
on init |
1017 |
|
exit(1.23 > 1.2) |
1018 |
|
end on |
1019 |
|
)NKSP_CODE", |
1020 |
|
.expectBoolExitResult = true |
1021 |
|
}); |
1022 |
|
|
1023 |
|
runScript({ |
1024 |
|
.code = R"NKSP_CODE( |
1025 |
|
on init |
1026 |
|
exit(-4.0 > 3.0) |
1027 |
|
end on |
1028 |
|
)NKSP_CODE", |
1029 |
|
.expectBoolExitResult = false |
1030 |
|
}); |
1031 |
|
|
1032 |
|
runScript({ |
1033 |
|
.code = R"NKSP_CODE( |
1034 |
|
on init |
1035 |
|
exit(3.0 > -4.0) |
1036 |
|
end on |
1037 |
|
)NKSP_CODE", |
1038 |
|
.expectBoolExitResult = true |
1039 |
|
}); |
1040 |
|
|
1041 |
|
runScript({ |
1042 |
|
.code = R"NKSP_CODE( |
1043 |
|
on init |
1044 |
|
exit(123.0 > -45.0) |
1045 |
|
end on |
1046 |
|
)NKSP_CODE", |
1047 |
|
.expectBoolExitResult = true |
1048 |
|
}); |
1049 |
|
|
1050 |
|
runScript({ |
1051 |
|
.code = R"NKSP_CODE( |
1052 |
|
on init |
1053 |
|
exit(-45.0 > 123.0) |
1054 |
|
end on |
1055 |
|
)NKSP_CODE", |
1056 |
|
.expectBoolExitResult = false |
1057 |
|
}); |
1058 |
|
|
1059 |
|
// mixed type tests ... |
1060 |
|
|
1061 |
|
runScript({ |
1062 |
|
.code = R"NKSP_CODE( |
1063 |
|
on init |
1064 |
|
exit(9 > 9.1) |
1065 |
|
end on |
1066 |
|
)NKSP_CODE", |
1067 |
|
.expectBoolExitResult = false |
1068 |
|
}); |
1069 |
|
|
1070 |
|
runScript({ |
1071 |
|
.code = R"NKSP_CODE( |
1072 |
|
on init |
1073 |
|
exit(9.1 > 9) |
1074 |
|
end on |
1075 |
|
)NKSP_CODE", |
1076 |
|
.expectBoolExitResult = true |
1077 |
|
}); |
1078 |
|
|
1079 |
#if !SILENT_TEST |
#if !SILENT_TEST |
1080 |
std::cout << std::endl; |
std::cout << std::endl; |
1081 |
#endif |
#endif |
1086 |
std::cout << "UNIT TEST: smaller-or-equal (<=) operator\n"; |
std::cout << "UNIT TEST: smaller-or-equal (<=) operator\n"; |
1087 |
#endif |
#endif |
1088 |
|
|
1089 |
|
// integer tests ... |
1090 |
|
|
1091 |
runScript({ |
runScript({ |
1092 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
1093 |
on init |
on init |
1178 |
.expectBoolExitResult = true |
.expectBoolExitResult = true |
1179 |
}); |
}); |
1180 |
|
|
1181 |
|
// real number tests ... |
1182 |
|
|
1183 |
|
runScript({ |
1184 |
|
.code = R"NKSP_CODE( |
1185 |
|
on init |
1186 |
|
exit(3.0 <= 3.0) |
1187 |
|
end on |
1188 |
|
)NKSP_CODE", |
1189 |
|
.expectBoolExitResult = true |
1190 |
|
}); |
1191 |
|
|
1192 |
|
runScript({ |
1193 |
|
.code = R"NKSP_CODE( |
1194 |
|
on init |
1195 |
|
exit(4.33 <= 4.33) |
1196 |
|
end on |
1197 |
|
)NKSP_CODE", |
1198 |
|
.expectBoolExitResult = true |
1199 |
|
}); |
1200 |
|
|
1201 |
|
runScript({ |
1202 |
|
.code = R"NKSP_CODE( |
1203 |
|
on init |
1204 |
|
exit(-23.1 <= -23.1) |
1205 |
|
end on |
1206 |
|
)NKSP_CODE", |
1207 |
|
.expectBoolExitResult = true |
1208 |
|
}); |
1209 |
|
|
1210 |
|
runScript({ |
1211 |
|
.code = R"NKSP_CODE( |
1212 |
|
on init |
1213 |
|
exit(23.3 <= -23.3) |
1214 |
|
end on |
1215 |
|
)NKSP_CODE", |
1216 |
|
.expectBoolExitResult = false |
1217 |
|
}); |
1218 |
|
|
1219 |
|
runScript({ |
1220 |
|
.code = R"NKSP_CODE( |
1221 |
|
on init |
1222 |
|
exit(3.0 <= 4.0) |
1223 |
|
end on |
1224 |
|
)NKSP_CODE", |
1225 |
|
.expectBoolExitResult = true |
1226 |
|
}); |
1227 |
|
|
1228 |
|
runScript({ |
1229 |
|
.code = R"NKSP_CODE( |
1230 |
|
on init |
1231 |
|
exit(4.0 <= 3.0) |
1232 |
|
end on |
1233 |
|
)NKSP_CODE", |
1234 |
|
.expectBoolExitResult = false |
1235 |
|
}); |
1236 |
|
|
1237 |
|
runScript({ |
1238 |
|
.code = R"NKSP_CODE( |
1239 |
|
on init |
1240 |
|
exit(-4.0 <= 3.0) |
1241 |
|
end on |
1242 |
|
)NKSP_CODE", |
1243 |
|
.expectBoolExitResult = true |
1244 |
|
}); |
1245 |
|
|
1246 |
|
runScript({ |
1247 |
|
.code = R"NKSP_CODE( |
1248 |
|
on init |
1249 |
|
exit(3.0 <= -4.0) |
1250 |
|
end on |
1251 |
|
)NKSP_CODE", |
1252 |
|
.expectBoolExitResult = false |
1253 |
|
}); |
1254 |
|
|
1255 |
|
runScript({ |
1256 |
|
.code = R"NKSP_CODE( |
1257 |
|
on init |
1258 |
|
exit(123.0 <= -45.0) |
1259 |
|
end on |
1260 |
|
)NKSP_CODE", |
1261 |
|
.expectBoolExitResult = false |
1262 |
|
}); |
1263 |
|
|
1264 |
|
runScript({ |
1265 |
|
.code = R"NKSP_CODE( |
1266 |
|
on init |
1267 |
|
exit(-45.0 <= 123.0) |
1268 |
|
end on |
1269 |
|
)NKSP_CODE", |
1270 |
|
.expectBoolExitResult = true |
1271 |
|
}); |
1272 |
|
|
1273 |
|
// mixed type tests ... |
1274 |
|
|
1275 |
|
runScript({ |
1276 |
|
.code = R"NKSP_CODE( |
1277 |
|
on init |
1278 |
|
exit(9 <= 9.1) |
1279 |
|
end on |
1280 |
|
)NKSP_CODE", |
1281 |
|
.expectBoolExitResult = true |
1282 |
|
}); |
1283 |
|
|
1284 |
|
runScript({ |
1285 |
|
.code = R"NKSP_CODE( |
1286 |
|
on init |
1287 |
|
exit(9.1 <= 9) |
1288 |
|
end on |
1289 |
|
)NKSP_CODE", |
1290 |
|
.expectBoolExitResult = false |
1291 |
|
}); |
1292 |
|
|
1293 |
|
runScript({ |
1294 |
|
.code = R"NKSP_CODE( |
1295 |
|
on init |
1296 |
|
exit(9 <= 9.0) |
1297 |
|
end on |
1298 |
|
)NKSP_CODE", |
1299 |
|
.expectBoolExitResult = true |
1300 |
|
}); |
1301 |
|
|
1302 |
|
runScript({ |
1303 |
|
.code = R"NKSP_CODE( |
1304 |
|
on init |
1305 |
|
exit(9.0 <= 9) |
1306 |
|
end on |
1307 |
|
)NKSP_CODE", |
1308 |
|
.expectBoolExitResult = true |
1309 |
|
}); |
1310 |
|
|
1311 |
#if !SILENT_TEST |
#if !SILENT_TEST |
1312 |
std::cout << std::endl; |
std::cout << std::endl; |
1313 |
#endif |
#endif |
1318 |
std::cout << "UNIT TEST: greater-or-equal (>=) operator\n"; |
std::cout << "UNIT TEST: greater-or-equal (>=) operator\n"; |
1319 |
#endif |
#endif |
1320 |
|
|
1321 |
|
// integer tests ... |
1322 |
|
|
1323 |
runScript({ |
runScript({ |
1324 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
1325 |
on init |
on init |
1410 |
.expectBoolExitResult = false |
.expectBoolExitResult = false |
1411 |
}); |
}); |
1412 |
|
|
1413 |
|
// real number tests ... |
1414 |
|
|
1415 |
|
runScript({ |
1416 |
|
.code = R"NKSP_CODE( |
1417 |
|
on init |
1418 |
|
exit(3.0 >= 3.0) |
1419 |
|
end on |
1420 |
|
)NKSP_CODE", |
1421 |
|
.expectBoolExitResult = true |
1422 |
|
}); |
1423 |
|
|
1424 |
|
runScript({ |
1425 |
|
.code = R"NKSP_CODE( |
1426 |
|
on init |
1427 |
|
exit(3.1 >= 3.1) |
1428 |
|
end on |
1429 |
|
)NKSP_CODE", |
1430 |
|
.expectBoolExitResult = true |
1431 |
|
}); |
1432 |
|
|
1433 |
|
runScript({ |
1434 |
|
.code = R"NKSP_CODE( |
1435 |
|
on init |
1436 |
|
exit(3.1 >= 3.0) |
1437 |
|
end on |
1438 |
|
)NKSP_CODE", |
1439 |
|
.expectBoolExitResult = true |
1440 |
|
}); |
1441 |
|
|
1442 |
|
runScript({ |
1443 |
|
.code = R"NKSP_CODE( |
1444 |
|
on init |
1445 |
|
exit(3.0 >= 3.1) |
1446 |
|
end on |
1447 |
|
)NKSP_CODE", |
1448 |
|
.expectBoolExitResult = false |
1449 |
|
}); |
1450 |
|
|
1451 |
|
runScript({ |
1452 |
|
.code = R"NKSP_CODE( |
1453 |
|
on init |
1454 |
|
exit(-23.33 >= -23.33) |
1455 |
|
end on |
1456 |
|
)NKSP_CODE", |
1457 |
|
.expectBoolExitResult = true |
1458 |
|
}); |
1459 |
|
|
1460 |
|
runScript({ |
1461 |
|
.code = R"NKSP_CODE( |
1462 |
|
on init |
1463 |
|
exit(23.0 >= -23.0) |
1464 |
|
end on |
1465 |
|
)NKSP_CODE", |
1466 |
|
.expectBoolExitResult = true |
1467 |
|
}); |
1468 |
|
|
1469 |
|
runScript({ |
1470 |
|
.code = R"NKSP_CODE( |
1471 |
|
on init |
1472 |
|
exit(3.0 >= 4.0) |
1473 |
|
end on |
1474 |
|
)NKSP_CODE", |
1475 |
|
.expectBoolExitResult = false |
1476 |
|
}); |
1477 |
|
|
1478 |
|
runScript({ |
1479 |
|
.code = R"NKSP_CODE( |
1480 |
|
on init |
1481 |
|
exit(4.0 >= 3.0) |
1482 |
|
end on |
1483 |
|
)NKSP_CODE", |
1484 |
|
.expectBoolExitResult = true |
1485 |
|
}); |
1486 |
|
|
1487 |
|
runScript({ |
1488 |
|
.code = R"NKSP_CODE( |
1489 |
|
on init |
1490 |
|
exit(-4.0 >= 3.0) |
1491 |
|
end on |
1492 |
|
)NKSP_CODE", |
1493 |
|
.expectBoolExitResult = false |
1494 |
|
}); |
1495 |
|
|
1496 |
|
runScript({ |
1497 |
|
.code = R"NKSP_CODE( |
1498 |
|
on init |
1499 |
|
exit(3.0 >= -4.0) |
1500 |
|
end on |
1501 |
|
)NKSP_CODE", |
1502 |
|
.expectBoolExitResult = true |
1503 |
|
}); |
1504 |
|
|
1505 |
|
runScript({ |
1506 |
|
.code = R"NKSP_CODE( |
1507 |
|
on init |
1508 |
|
exit(123.0 >= -45.0) |
1509 |
|
end on |
1510 |
|
)NKSP_CODE", |
1511 |
|
.expectBoolExitResult = true |
1512 |
|
}); |
1513 |
|
|
1514 |
|
runScript({ |
1515 |
|
.code = R"NKSP_CODE( |
1516 |
|
on init |
1517 |
|
exit(-45.0 >= 123.0) |
1518 |
|
end on |
1519 |
|
)NKSP_CODE", |
1520 |
|
.expectBoolExitResult = false |
1521 |
|
}); |
1522 |
|
|
1523 |
|
// mixed type tests ... |
1524 |
|
|
1525 |
|
runScript({ |
1526 |
|
.code = R"NKSP_CODE( |
1527 |
|
on init |
1528 |
|
exit(9 >= 9.1) |
1529 |
|
end on |
1530 |
|
)NKSP_CODE", |
1531 |
|
.expectBoolExitResult = false |
1532 |
|
}); |
1533 |
|
|
1534 |
|
runScript({ |
1535 |
|
.code = R"NKSP_CODE( |
1536 |
|
on init |
1537 |
|
exit(9.1 >= 9) |
1538 |
|
end on |
1539 |
|
)NKSP_CODE", |
1540 |
|
.expectBoolExitResult = true |
1541 |
|
}); |
1542 |
|
|
1543 |
|
runScript({ |
1544 |
|
.code = R"NKSP_CODE( |
1545 |
|
on init |
1546 |
|
exit(9 >= 9.0) |
1547 |
|
end on |
1548 |
|
)NKSP_CODE", |
1549 |
|
.expectBoolExitResult = true |
1550 |
|
}); |
1551 |
|
|
1552 |
|
runScript({ |
1553 |
|
.code = R"NKSP_CODE( |
1554 |
|
on init |
1555 |
|
exit(9.0 >= 9) |
1556 |
|
end on |
1557 |
|
)NKSP_CODE", |
1558 |
|
.expectBoolExitResult = true |
1559 |
|
}); |
1560 |
|
|
1561 |
#if !SILENT_TEST |
#if !SILENT_TEST |
1562 |
std::cout << std::endl; |
std::cout << std::endl; |
1563 |
#endif |
#endif |
1568 |
std::cout << "UNIT TEST: equal (=) operator\n"; |
std::cout << "UNIT TEST: equal (=) operator\n"; |
1569 |
#endif |
#endif |
1570 |
|
|
1571 |
|
// integer tests ... |
1572 |
|
|
1573 |
runScript({ |
runScript({ |
1574 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
1575 |
on init |
on init |
1606 |
.expectBoolExitResult = false |
.expectBoolExitResult = false |
1607 |
}); |
}); |
1608 |
|
|
1609 |
|
// real number tests ... |
1610 |
|
|
1611 |
|
runScript({ |
1612 |
|
.code = R"NKSP_CODE( |
1613 |
|
on init |
1614 |
|
exit(3.0 = 3.0) |
1615 |
|
end on |
1616 |
|
)NKSP_CODE", |
1617 |
|
.expectBoolExitResult = true |
1618 |
|
}); |
1619 |
|
|
1620 |
|
runScript({ |
1621 |
|
.code = R"NKSP_CODE( |
1622 |
|
on init |
1623 |
|
exit(4.33 = 4.33) |
1624 |
|
end on |
1625 |
|
)NKSP_CODE", |
1626 |
|
.expectBoolExitResult = true |
1627 |
|
}); |
1628 |
|
|
1629 |
|
runScript({ |
1630 |
|
.code = R"NKSP_CODE( |
1631 |
|
on init |
1632 |
|
exit(4.31 = 4.35) |
1633 |
|
end on |
1634 |
|
)NKSP_CODE", |
1635 |
|
.expectBoolExitResult = false |
1636 |
|
}); |
1637 |
|
|
1638 |
|
runScript({ |
1639 |
|
.code = R"NKSP_CODE( |
1640 |
|
on init |
1641 |
|
exit(3.0 = 4.0) |
1642 |
|
end on |
1643 |
|
)NKSP_CODE", |
1644 |
|
.expectBoolExitResult = false |
1645 |
|
}); |
1646 |
|
|
1647 |
|
runScript({ |
1648 |
|
.code = R"NKSP_CODE( |
1649 |
|
on init |
1650 |
|
exit(23.0 = -23.0) |
1651 |
|
end on |
1652 |
|
)NKSP_CODE", |
1653 |
|
.expectBoolExitResult = false |
1654 |
|
}); |
1655 |
|
|
1656 |
|
// mixed type tests ... |
1657 |
|
|
1658 |
|
runScript({ |
1659 |
|
.code = R"NKSP_CODE( |
1660 |
|
on init |
1661 |
|
exit(23 = 23.0) |
1662 |
|
end on |
1663 |
|
)NKSP_CODE", |
1664 |
|
.expectBoolExitResult = true |
1665 |
|
}); |
1666 |
|
|
1667 |
|
runScript({ |
1668 |
|
.code = R"NKSP_CODE( |
1669 |
|
on init |
1670 |
|
exit(23.0 = 23) |
1671 |
|
end on |
1672 |
|
)NKSP_CODE", |
1673 |
|
.expectBoolExitResult = true |
1674 |
|
}); |
1675 |
|
|
1676 |
|
runScript({ |
1677 |
|
.code = R"NKSP_CODE( |
1678 |
|
on init |
1679 |
|
exit(23 = 23.1) |
1680 |
|
end on |
1681 |
|
)NKSP_CODE", |
1682 |
|
.expectBoolExitResult = false |
1683 |
|
}); |
1684 |
|
|
1685 |
|
runScript({ |
1686 |
|
.code = R"NKSP_CODE( |
1687 |
|
on init |
1688 |
|
exit(23.1 = 23) |
1689 |
|
end on |
1690 |
|
)NKSP_CODE", |
1691 |
|
.expectBoolExitResult = false |
1692 |
|
}); |
1693 |
|
|
1694 |
#if !SILENT_TEST |
#if !SILENT_TEST |
1695 |
std::cout << std::endl; |
std::cout << std::endl; |
1696 |
#endif |
#endif |
1701 |
std::cout << "UNIT TEST: unequal (#) operator\n"; |
std::cout << "UNIT TEST: unequal (#) operator\n"; |
1702 |
#endif |
#endif |
1703 |
|
|
1704 |
|
// integer tests ... |
1705 |
|
|
1706 |
runScript({ |
runScript({ |
1707 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
1708 |
on init |
on init |
1739 |
.expectBoolExitResult = true |
.expectBoolExitResult = true |
1740 |
}); |
}); |
1741 |
|
|
1742 |
|
// real number tests ... |
1743 |
|
|
1744 |
|
runScript({ |
1745 |
|
.code = R"NKSP_CODE( |
1746 |
|
on init |
1747 |
|
exit(3.0 # 3.0) |
1748 |
|
end on |
1749 |
|
)NKSP_CODE", |
1750 |
|
.expectBoolExitResult = false |
1751 |
|
}); |
1752 |
|
|
1753 |
|
runScript({ |
1754 |
|
.code = R"NKSP_CODE( |
1755 |
|
on init |
1756 |
|
exit(3.14 # 3.14) |
1757 |
|
end on |
1758 |
|
)NKSP_CODE", |
1759 |
|
.expectBoolExitResult = false |
1760 |
|
}); |
1761 |
|
|
1762 |
|
runScript({ |
1763 |
|
.code = R"NKSP_CODE( |
1764 |
|
on init |
1765 |
|
exit(3.19 # 3.12) |
1766 |
|
end on |
1767 |
|
)NKSP_CODE", |
1768 |
|
.expectBoolExitResult = true |
1769 |
|
}); |
1770 |
|
|
1771 |
|
runScript({ |
1772 |
|
.code = R"NKSP_CODE( |
1773 |
|
on init |
1774 |
|
exit(23.0 # -23.0) |
1775 |
|
end on |
1776 |
|
)NKSP_CODE", |
1777 |
|
.expectBoolExitResult = true |
1778 |
|
}); |
1779 |
|
|
1780 |
|
// mixed type tests ... |
1781 |
|
|
1782 |
|
runScript({ |
1783 |
|
.code = R"NKSP_CODE( |
1784 |
|
on init |
1785 |
|
exit(3 # 3.0) |
1786 |
|
end on |
1787 |
|
)NKSP_CODE", |
1788 |
|
.expectBoolExitResult = false |
1789 |
|
}); |
1790 |
|
|
1791 |
|
runScript({ |
1792 |
|
.code = R"NKSP_CODE( |
1793 |
|
on init |
1794 |
|
exit(3.0 # 3) |
1795 |
|
end on |
1796 |
|
)NKSP_CODE", |
1797 |
|
.expectBoolExitResult = false |
1798 |
|
}); |
1799 |
|
|
1800 |
|
runScript({ |
1801 |
|
.code = R"NKSP_CODE( |
1802 |
|
on init |
1803 |
|
exit(3.1 # 3) |
1804 |
|
end on |
1805 |
|
)NKSP_CODE", |
1806 |
|
.expectBoolExitResult = true |
1807 |
|
}); |
1808 |
|
|
1809 |
|
runScript({ |
1810 |
|
.code = R"NKSP_CODE( |
1811 |
|
on init |
1812 |
|
exit(3 # 3.1) |
1813 |
|
end on |
1814 |
|
)NKSP_CODE", |
1815 |
|
.expectBoolExitResult = true |
1816 |
|
}); |
1817 |
|
|
1818 |
#if !SILENT_TEST |
#if !SILENT_TEST |
1819 |
std::cout << std::endl; |
std::cout << std::endl; |
1820 |
#endif |
#endif |
1825 |
std::cout << "UNIT TEST: logical and (and) operator\n"; |
std::cout << "UNIT TEST: logical and (and) operator\n"; |
1826 |
#endif |
#endif |
1827 |
|
|
1828 |
|
// integer tests ... |
1829 |
|
|
1830 |
runScript({ |
runScript({ |
1831 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
1832 |
on init |
on init |
1881 |
.expectBoolExitResult = false |
.expectBoolExitResult = false |
1882 |
}); |
}); |
1883 |
|
|
1884 |
|
// real number tests ... |
1885 |
|
// (not allowed for this operator) |
1886 |
|
|
1887 |
|
runScript({ |
1888 |
|
.code = R"NKSP_CODE( |
1889 |
|
on init |
1890 |
|
exit(1.0 and 1.0) |
1891 |
|
end on |
1892 |
|
)NKSP_CODE", |
1893 |
|
.expectParseError = true // real numbers not allowed for this operator |
1894 |
|
}); |
1895 |
|
|
1896 |
|
// mixed type tests ... |
1897 |
|
// (not allowed for this operator) |
1898 |
|
|
1899 |
|
runScript({ |
1900 |
|
.code = R"NKSP_CODE( |
1901 |
|
on init |
1902 |
|
exit(1.0 and 1) |
1903 |
|
end on |
1904 |
|
)NKSP_CODE", |
1905 |
|
.expectParseError = true // real numbers not allowed for this operator |
1906 |
|
}); |
1907 |
|
|
1908 |
|
runScript({ |
1909 |
|
.code = R"NKSP_CODE( |
1910 |
|
on init |
1911 |
|
exit(1 and 1.0) |
1912 |
|
end on |
1913 |
|
)NKSP_CODE", |
1914 |
|
.expectParseError = true // real numbers not allowed for this operator |
1915 |
|
}); |
1916 |
|
|
1917 |
#if !SILENT_TEST |
#if !SILENT_TEST |
1918 |
std::cout << std::endl; |
std::cout << std::endl; |
1919 |
#endif |
#endif |
1924 |
std::cout << "UNIT TEST: logical or (or) operator\n"; |
std::cout << "UNIT TEST: logical or (or) operator\n"; |
1925 |
#endif |
#endif |
1926 |
|
|
1927 |
|
// integer tests ... |
1928 |
|
|
1929 |
runScript({ |
runScript({ |
1930 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
1931 |
on init |
on init |
1980 |
.expectBoolExitResult = false |
.expectBoolExitResult = false |
1981 |
}); |
}); |
1982 |
|
|
1983 |
|
// real number tests ... |
1984 |
|
// (not allowed for this operator) |
1985 |
|
|
1986 |
|
runScript({ |
1987 |
|
.code = R"NKSP_CODE( |
1988 |
|
on init |
1989 |
|
exit(1.0 or 1.0) |
1990 |
|
end on |
1991 |
|
)NKSP_CODE", |
1992 |
|
.expectParseError = true // real numbers not allowed for this operator |
1993 |
|
}); |
1994 |
|
|
1995 |
|
// mixed type tests ... |
1996 |
|
// (not allowed for this operator) |
1997 |
|
|
1998 |
|
runScript({ |
1999 |
|
.code = R"NKSP_CODE( |
2000 |
|
on init |
2001 |
|
exit(1.0 or 1) |
2002 |
|
end on |
2003 |
|
)NKSP_CODE", |
2004 |
|
.expectParseError = true // real numbers not allowed for this operator |
2005 |
|
}); |
2006 |
|
|
2007 |
|
runScript({ |
2008 |
|
.code = R"NKSP_CODE( |
2009 |
|
on init |
2010 |
|
exit(1 or 1.0) |
2011 |
|
end on |
2012 |
|
)NKSP_CODE", |
2013 |
|
.expectParseError = true // real numbers not allowed for this operator |
2014 |
|
}); |
2015 |
|
|
2016 |
#if !SILENT_TEST |
#if !SILENT_TEST |
2017 |
std::cout << std::endl; |
std::cout << std::endl; |
2018 |
#endif |
#endif |
2023 |
std::cout << "UNIT TEST: logical not (not) operator\n"; |
std::cout << "UNIT TEST: logical not (not) operator\n"; |
2024 |
#endif |
#endif |
2025 |
|
|
2026 |
|
// integer tests ... |
2027 |
|
|
2028 |
runScript({ |
runScript({ |
2029 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
2030 |
on init |
on init |
2052 |
.expectBoolExitResult = true |
.expectBoolExitResult = true |
2053 |
}); |
}); |
2054 |
|
|
2055 |
|
// real number tests ... |
2056 |
|
// (not allowed for this operator) |
2057 |
|
|
2058 |
|
runScript({ |
2059 |
|
.code = R"NKSP_CODE( |
2060 |
|
on init |
2061 |
|
exit(not 1.0) |
2062 |
|
end on |
2063 |
|
)NKSP_CODE", |
2064 |
|
.expectParseError = true // real numbers not allowed for this operator |
2065 |
|
}); |
2066 |
|
|
2067 |
#if !SILENT_TEST |
#if !SILENT_TEST |
2068 |
std::cout << std::endl; |
std::cout << std::endl; |
2069 |
#endif |
#endif |
2074 |
std::cout << "UNIT TEST: bitwise and (.and.) operator\n"; |
std::cout << "UNIT TEST: bitwise and (.and.) operator\n"; |
2075 |
#endif |
#endif |
2076 |
|
|
2077 |
|
// integer tests ... |
2078 |
|
|
2079 |
runScript({ |
runScript({ |
2080 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
2081 |
on init |
on init |
2094 |
.expectIntExitResult = 10 |
.expectIntExitResult = 10 |
2095 |
}); |
}); |
2096 |
|
|
2097 |
|
// real number tests ... |
2098 |
|
// (not allowed for this operator) |
2099 |
|
|
2100 |
|
runScript({ |
2101 |
|
.code = R"NKSP_CODE( |
2102 |
|
on init |
2103 |
|
exit(1.0 .and. 1.0) |
2104 |
|
end on |
2105 |
|
)NKSP_CODE", |
2106 |
|
.expectParseError = true // real numbers not allowed for this operator |
2107 |
|
}); |
2108 |
|
|
2109 |
|
// mixed type tests ... |
2110 |
|
// (not allowed for this operator) |
2111 |
|
|
2112 |
|
runScript({ |
2113 |
|
.code = R"NKSP_CODE( |
2114 |
|
on init |
2115 |
|
exit(1.0 .and. 1) |
2116 |
|
end on |
2117 |
|
)NKSP_CODE", |
2118 |
|
.expectParseError = true // real numbers not allowed for this operator |
2119 |
|
}); |
2120 |
|
|
2121 |
|
runScript({ |
2122 |
|
.code = R"NKSP_CODE( |
2123 |
|
on init |
2124 |
|
exit(1 .and. 1.0) |
2125 |
|
end on |
2126 |
|
)NKSP_CODE", |
2127 |
|
.expectParseError = true // real numbers not allowed for this operator |
2128 |
|
}); |
2129 |
|
|
2130 |
#if !SILENT_TEST |
#if !SILENT_TEST |
2131 |
std::cout << std::endl; |
std::cout << std::endl; |
2132 |
#endif |
#endif |
2137 |
std::cout << "UNIT TEST: bitwise or (.or.) operator\n"; |
std::cout << "UNIT TEST: bitwise or (.or.) operator\n"; |
2138 |
#endif |
#endif |
2139 |
|
|
2140 |
|
// integer tests ... |
2141 |
|
|
2142 |
runScript({ |
runScript({ |
2143 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
2144 |
on init |
on init |
2166 |
.expectIntExitResult = 175 |
.expectIntExitResult = 175 |
2167 |
}); |
}); |
2168 |
|
|
2169 |
|
// real number tests ... |
2170 |
|
// (not allowed for this operator) |
2171 |
|
|
2172 |
|
runScript({ |
2173 |
|
.code = R"NKSP_CODE( |
2174 |
|
on init |
2175 |
|
exit(1.0 .or. 1.0) |
2176 |
|
end on |
2177 |
|
)NKSP_CODE", |
2178 |
|
.expectParseError = true // real numbers not allowed for this operator |
2179 |
|
}); |
2180 |
|
|
2181 |
|
// mixed type tests ... |
2182 |
|
// (not allowed for this operator) |
2183 |
|
|
2184 |
|
runScript({ |
2185 |
|
.code = R"NKSP_CODE( |
2186 |
|
on init |
2187 |
|
exit(1.0 .or. 1) |
2188 |
|
end on |
2189 |
|
)NKSP_CODE", |
2190 |
|
.expectParseError = true // real numbers not allowed for this operator |
2191 |
|
}); |
2192 |
|
|
2193 |
|
runScript({ |
2194 |
|
.code = R"NKSP_CODE( |
2195 |
|
on init |
2196 |
|
exit(1 .or. 1.0) |
2197 |
|
end on |
2198 |
|
)NKSP_CODE", |
2199 |
|
.expectParseError = true // real numbers not allowed for this operator |
2200 |
|
}); |
2201 |
|
|
2202 |
#if !SILENT_TEST |
#if !SILENT_TEST |
2203 |
std::cout << std::endl; |
std::cout << std::endl; |
2204 |
#endif |
#endif |
2209 |
std::cout << "UNIT TEST: bitwise not (.not.) operator\n"; |
std::cout << "UNIT TEST: bitwise not (.not.) operator\n"; |
2210 |
#endif |
#endif |
2211 |
|
|
2212 |
|
// integer tests ... |
2213 |
|
|
2214 |
runScript({ |
runScript({ |
2215 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
2216 |
on init |
on init |
2238 |
.expectIntExitResult = ssize_t(size_t(-1) << 2) |
.expectIntExitResult = ssize_t(size_t(-1) << 2) |
2239 |
}); |
}); |
2240 |
|
|
2241 |
|
// real number tests ... |
2242 |
|
// (not allowed for this operator) |
2243 |
|
|
2244 |
|
runScript({ |
2245 |
|
.code = R"NKSP_CODE( |
2246 |
|
on init |
2247 |
|
exit(.not. 1.0) |
2248 |
|
end on |
2249 |
|
)NKSP_CODE", |
2250 |
|
.expectParseError = true // real numbers not allowed for this operator |
2251 |
|
}); |
2252 |
|
|
2253 |
|
runScript({ |
2254 |
|
.code = R"NKSP_CODE( |
2255 |
|
on init |
2256 |
|
exit(.not. -1.0) |
2257 |
|
end on |
2258 |
|
)NKSP_CODE", |
2259 |
|
.expectParseError = true // real numbers not allowed for this operator |
2260 |
|
}); |
2261 |
|
|
2262 |
#if !SILENT_TEST |
#if !SILENT_TEST |
2263 |
std::cout << std::endl; |
std::cout << std::endl; |
2264 |
#endif |
#endif |
2269 |
std::cout << "UNIT TEST: precedence of operators\n"; |
std::cout << "UNIT TEST: precedence of operators\n"; |
2270 |
#endif |
#endif |
2271 |
|
|
2272 |
|
// integer tests ... |
2273 |
|
|
2274 |
runScript({ |
runScript({ |
2275 |
.code = R"NKSP_CODE( |
.code = R"NKSP_CODE( |
2276 |
on init |
on init |
2307 |
.expectIntExitResult = 20 |
.expectIntExitResult = 20 |
2308 |
}); |
}); |
2309 |
|
|
2310 |
|
// real number tests ... |
2311 |
|
|
2312 |
|
runScript({ |
2313 |
|
.code = R"NKSP_CODE( |
2314 |
|
on init |
2315 |
|
exit(3.2 + 4.0 * 2.0) |
2316 |
|
end on |
2317 |
|
)NKSP_CODE", |
2318 |
|
.expectRealExitResult = 11.2 |
2319 |
|
}); |
2320 |
|
|
2321 |
|
runScript({ |
2322 |
|
.code = R"NKSP_CODE( |
2323 |
|
on init |
2324 |
|
exit(4.0 * 2.0 + 3.2) |
2325 |
|
end on |
2326 |
|
)NKSP_CODE", |
2327 |
|
.expectRealExitResult = 11.2 |
2328 |
|
}); |
2329 |
|
|
2330 |
|
runScript({ |
2331 |
|
.code = R"NKSP_CODE( |
2332 |
|
on init |
2333 |
|
exit((3.2 + 4.0) * 2.0) |
2334 |
|
end on |
2335 |
|
)NKSP_CODE", |
2336 |
|
.expectRealExitResult = 14.4 |
2337 |
|
}); |
2338 |
|
|
2339 |
|
runScript({ |
2340 |
|
.code = R"NKSP_CODE( |
2341 |
|
on init |
2342 |
|
exit(4.0 * (2.0 + 3.2)) |
2343 |
|
end on |
2344 |
|
)NKSP_CODE", |
2345 |
|
.expectRealExitResult = 20.8 |
2346 |
|
}); |
2347 |
|
|
2348 |
#if !SILENT_TEST |
#if !SILENT_TEST |
2349 |
std::cout << std::endl; |
std::cout << std::endl; |
2350 |
#endif |
#endif |
2816 |
#endif |
#endif |
2817 |
} |
} |
2818 |
|
|
2819 |
|
static void testBuiltInIntToRealFunction() { |
2820 |
|
#if !SILENT_TEST |
2821 |
|
std::cout << "UNIT TEST: built-in int_to_real() function\n"; |
2822 |
|
#endif |
2823 |
|
|
2824 |
|
runScript({ |
2825 |
|
.code = R"NKSP_CODE( |
2826 |
|
on init |
2827 |
|
exit( int_to_real(8) ) |
2828 |
|
end on |
2829 |
|
)NKSP_CODE", |
2830 |
|
.expectRealExitResult = 8.0 |
2831 |
|
}); |
2832 |
|
|
2833 |
|
runScript({ |
2834 |
|
.code = R"NKSP_CODE( |
2835 |
|
on init |
2836 |
|
declare $foo := 23 |
2837 |
|
exit( int_to_real($foo) ) |
2838 |
|
end on |
2839 |
|
)NKSP_CODE", |
2840 |
|
.expectRealExitResult = 23.0 |
2841 |
|
}); |
2842 |
|
|
2843 |
|
#if !SILENT_TEST |
2844 |
|
std::cout << std::endl; |
2845 |
|
#endif |
2846 |
|
} |
2847 |
|
|
2848 |
|
static void testBuiltInRealFunction() { |
2849 |
|
#if !SILENT_TEST |
2850 |
|
std::cout << "UNIT TEST: built-in real() function\n"; |
2851 |
|
#endif |
2852 |
|
|
2853 |
|
runScript({ |
2854 |
|
.code = R"NKSP_CODE( |
2855 |
|
on init |
2856 |
|
exit( real(8) ) |
2857 |
|
end on |
2858 |
|
)NKSP_CODE", |
2859 |
|
.expectRealExitResult = 8.0 |
2860 |
|
}); |
2861 |
|
|
2862 |
|
runScript({ |
2863 |
|
.code = R"NKSP_CODE( |
2864 |
|
on init |
2865 |
|
declare $foo := 23 |
2866 |
|
exit( real($foo) ) |
2867 |
|
end on |
2868 |
|
)NKSP_CODE", |
2869 |
|
.expectRealExitResult = 23.0 |
2870 |
|
}); |
2871 |
|
|
2872 |
|
#if !SILENT_TEST |
2873 |
|
std::cout << std::endl; |
2874 |
|
#endif |
2875 |
|
} |
2876 |
|
|
2877 |
|
static void testBuiltInRealToIntFunction() { |
2878 |
|
#if !SILENT_TEST |
2879 |
|
std::cout << "UNIT TEST: built-in real_to_int() function\n"; |
2880 |
|
#endif |
2881 |
|
|
2882 |
|
runScript({ |
2883 |
|
.code = R"NKSP_CODE( |
2884 |
|
on init |
2885 |
|
exit( real_to_int(8.9) ) |
2886 |
|
end on |
2887 |
|
)NKSP_CODE", |
2888 |
|
.expectIntExitResult = 8 |
2889 |
|
}); |
2890 |
|
|
2891 |
|
runScript({ |
2892 |
|
.code = R"NKSP_CODE( |
2893 |
|
on init |
2894 |
|
declare ~foo := 8.9 |
2895 |
|
exit( real_to_int(~foo) ) |
2896 |
|
end on |
2897 |
|
)NKSP_CODE", |
2898 |
|
.expectIntExitResult = 8 |
2899 |
|
}); |
2900 |
|
|
2901 |
|
#if !SILENT_TEST |
2902 |
|
std::cout << std::endl; |
2903 |
|
#endif |
2904 |
|
} |
2905 |
|
|
2906 |
|
static void testBuiltInIntFunction() { |
2907 |
|
#if !SILENT_TEST |
2908 |
|
std::cout << "UNIT TEST: built-in int() function\n"; |
2909 |
|
#endif |
2910 |
|
|
2911 |
|
runScript({ |
2912 |
|
.code = R"NKSP_CODE( |
2913 |
|
on init |
2914 |
|
exit( int(8.9) ) |
2915 |
|
end on |
2916 |
|
)NKSP_CODE", |
2917 |
|
.expectIntExitResult = 8 |
2918 |
|
}); |
2919 |
|
|
2920 |
|
runScript({ |
2921 |
|
.code = R"NKSP_CODE( |
2922 |
|
on init |
2923 |
|
declare ~foo := 8.9 |
2924 |
|
exit( int(~foo) ) |
2925 |
|
end on |
2926 |
|
)NKSP_CODE", |
2927 |
|
.expectIntExitResult = 8 |
2928 |
|
}); |
2929 |
|
|
2930 |
|
#if !SILENT_TEST |
2931 |
|
std::cout << std::endl; |
2932 |
|
#endif |
2933 |
|
} |
2934 |
|
|
2935 |
static void testBuiltInArrayEqualFunction() { |
static void testBuiltInArrayEqualFunction() { |
2936 |
#if !SILENT_TEST |
#if !SILENT_TEST |
2937 |
std::cout << "UNIT TEST: built-in array_equal() function\n"; |
std::cout << "UNIT TEST: built-in array_equal() function\n"; |
3214 |
int main() { |
int main() { |
3215 |
testBuiltInExitFunction(); |
testBuiltInExitFunction(); |
3216 |
testStringConcatOperator(); |
testStringConcatOperator(); |
3217 |
|
testNegOperator(); |
3218 |
testPlusOperator(); |
testPlusOperator(); |
3219 |
testMinusOperator(); |
testMinusOperator(); |
3220 |
testModuloOperator(); |
testModuloOperator(); |
3242 |
testBuiltInRandomFunction(); |
testBuiltInRandomFunction(); |
3243 |
testBuiltInShiftLeftFunction(); |
testBuiltInShiftLeftFunction(); |
3244 |
testBuiltInShiftRightFunction(); |
testBuiltInShiftRightFunction(); |
3245 |
|
testBuiltInIntToRealFunction(); |
3246 |
|
testBuiltInRealFunction(); |
3247 |
|
testBuiltInRealToIntFunction(); |
3248 |
|
testBuiltInIntFunction(); |
3249 |
testBuiltInArrayEqualFunction(); |
testBuiltInArrayEqualFunction(); |
3250 |
testBuiltInSortFunction(); |
testBuiltInSortFunction(); |
3251 |
testBuiltInNumElementsFunction(); |
testBuiltInNumElementsFunction(); |