From 18ae3824146af27e9223118c6f38fe3b5ac8d246 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Mon, 31 Oct 2022 15:50:51 +0100 Subject: [PATCH] Add test for if --- src/CMakeLists.txt | 1 + src/functional-tests/if.at | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/functional-tests/if.at diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b3ce7d1..429017c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,6 +63,7 @@ functionaltest("mathops") functionaltest("len") functionaltest("not") functionaltest("type") +functionaltest("if") install(TARGETS apfl DESTINATION lib) install(TARGETS apfl-bin DESTINATION bin) diff --git a/src/functional-tests/if.at b/src/functional-tests/if.at new file mode 100644 index 0000000..01c98bf --- /dev/null +++ b/src/functional-tests/if.at @@ -0,0 +1,39 @@ +===== script ===== +i = 1 +if (== i 1) { + print "1: ok" +} + +if (not (== i 1)) { + print "2: fail" +} { + print "2: ok" +} + +if false { + print "3: fail" +} nil { + print "3: fail" +} { + print "3: ok" +} + +print (if true { + "4: ok" +} { + "4: fail" +}) + +if false { + print "5: fail" +} nil { + print "5: fail" +} (== 1 2) { + print "5: fail" +} + +===== output ===== +1: ok +2: ok +3: ok +4: ok