From d7234091b43710cc0f3df038d7625eefcfa0ec92 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 25 Jan 2024 13:54:18 +0100 Subject: [PATCH 1/2] added more testcases --- tests/and.lgx | 22 ++++++++ tests/biggeras.lgx | 5 ++ tests/bool.lgx | 2 + tests/divide.lgx | 9 +++ tests/expressions.lgx | 7 +++ tests/minus.lgx | 1 + tests/modulo.lgx | 27 +++++++++ tests/multi.lgx | 11 ++++ tests/notsorted.lgx | 127 ++++++++++++++++++++++++++++++++++++++++++ tests/or.lgx | 23 ++++++++ tests/plus.lgx | 26 +++++++++ tests/smalleras.lgx | 20 +++++++ tests/vars.lgx | 18 ++++++ 13 files changed, 298 insertions(+) create mode 100644 tests/and.lgx create mode 100644 tests/biggeras.lgx create mode 100644 tests/bool.lgx create mode 100644 tests/divide.lgx create mode 100644 tests/minus.lgx create mode 100644 tests/modulo.lgx create mode 100644 tests/multi.lgx create mode 100644 tests/notsorted.lgx create mode 100644 tests/or.lgx create mode 100644 tests/plus.lgx create mode 100644 tests/smalleras.lgx diff --git a/tests/and.lgx b/tests/and.lgx new file mode 100644 index 0000000..3e2c7ab --- /dev/null +++ b/tests/and.lgx @@ -0,0 +1,22 @@ +"hello" and "world" + 4 +#EXPECT:"world4" + +"hello" or "world" and "kaputt" + 4 +#EXPECT:"hello" + +"hello" and "world" or "kaputt" and + 4 +#EXPECT:"world" + +x >= 10 and x < 20 +#EXPECT:False + +a and not b +#EXPECT:None + +#SET:year:2000 +(year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) +#EXPECT:True + +#SET:year:2023 +(year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) +#EXPECT:False diff --git a/tests/biggeras.lgx b/tests/biggeras.lgx new file mode 100644 index 0000000..ebeda85 --- /dev/null +++ b/tests/biggeras.lgx @@ -0,0 +1,5 @@ + 2 == 2 > 1 == 2 +#EXPECT:False + +x >= 10 and x < 20 +#EXPECT:False diff --git a/tests/bool.lgx b/tests/bool.lgx new file mode 100644 index 0000000..9976db2 --- /dev/null +++ b/tests/bool.lgx @@ -0,0 +1,2 @@ +bool(700/4) +#EXPECT:True diff --git a/tests/divide.lgx b/tests/divide.lgx new file mode 100644 index 0000000..43b32fe --- /dev/null +++ b/tests/divide.lgx @@ -0,0 +1,9 @@ + +bool(700/4) +#EXPECT:True + +"string" / 1 +#EXPECT:0 + +6000/49 +#EXPECT:122.44897959183673 diff --git a/tests/expressions.lgx b/tests/expressions.lgx index e77e078..e9833bf 100644 --- a/tests/expressions.lgx +++ b/tests/expressions.lgx @@ -6,3 +6,10 @@ 3 * "HelloWorld" #EXPECT:"HelloWorldHelloWorldHelloWorld" + +6000/49 +#EXPECT:122.44897959183673 + +(3*"arbeit")+7*90 +#EXPECT:"arbeitarbeitarbeit630" + diff --git a/tests/minus.lgx b/tests/minus.lgx new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/tests/minus.lgx @@ -0,0 +1 @@ + diff --git a/tests/modulo.lgx b/tests/modulo.lgx new file mode 100644 index 0000000..29cb0f9 --- /dev/null +++ b/tests/modulo.lgx @@ -0,0 +1,27 @@ +n % 5 == 0 or n % 7 == 0 +#EXPECT:True + +x % 2 == 0 +#EXPECT:True + +x % 2 != 0 +#EXPECT:False + +x % 4 == 0 +#EXPECT:True + +x % 3 == 0 and x % 5 == 0 +#EXPECT:True + +#calculate the switching year +#SET:year:2020 +(year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) +#EXPECT:True + +#SET:year:2000 +(year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) +#EXPECT:True + +#SET:year:2023 +(year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) +#EXPECT:False diff --git a/tests/multi.lgx b/tests/multi.lgx new file mode 100644 index 0000000..d2cb6ff --- /dev/null +++ b/tests/multi.lgx @@ -0,0 +1,11 @@ + "arbeit" + "tag" + 300 ** 4 +#EXPECT:"arbeittag8100000000" + +700 * "Mäuse" + "Fallen" < 700 * "Katzen" +#EXPECT:False + +32769 * "a" +#EXPECT:"#ERR limit of 32768 reached" + +(3*"arbeit")+7*90 +#EXPECT:"arbeitarbeitarbeit630" diff --git a/tests/notsorted.lgx b/tests/notsorted.lgx new file mode 100644 index 0000000..31e31d2 --- /dev/null +++ b/tests/notsorted.lgx @@ -0,0 +1,127 @@ +"Hund" + "Leine" == "Katze" + "Fisch" +#EXPECT:False + +20 * "Äpfel" == 20 * "Bananen" +#EXPECT:False + +2 ** 8 == 256 +#EXPECT:True + +1.1 + 2.2 == 3.3 +#EXPECT:False + +10 == "10" +#EXPECT:True + +(True and False) or (False or True) +#EXPECT:True + +(x > 5 or x < 2) and (y == 10 or y > 20) +#EXPECT:False + +True and False == False +#EXPECT:True + +x % 2 == 0 or x % 3 == 0 or x % 5 == 0 +#EXPECT:True + +(x > 5 and y < 10) or (x > 20 and y < 30) +#EXPECT:False + +(x > 5 and "hello" or y < 10) and (x > 20 and y < 30) +#EXPECT:False + +10 < x <= 20 +#EXPECT:False + +("apple" + "orange" != "banana") or (len("coding") == 6) +#EXPECT:True + +(20 - 10 == 5 + 5) and (2 ** 3 == 8) +#EXPECT:True + +(27 / 3 == 9) and (17 == 17) +#EXPECT:True + +(36 / 6 == 6) and (7 * 5 == 35) or ("chat" in "chatbot") +#EXPECT:True + +(2 ** 10 == 1024) and (85 - 13 > 42 + 17) +#EXPECT:True + +(len("hello") == 5) and (3 * 7 == 20 + 10) or (100 / 5 == 20) +#EXPECT:True + +(10 + 13 == 23) and (92 / 4 == 23) or (len("apple") == 5) +#EXPECT:True + +(len("world") == 5) and (4 * 6 == 24 + 12) or (81 / 3 == 27) +#EXPECT:True + +(len("python") == 6) and (5 * 8 == 40 + 20) or (125 / 5 == 25) +#EXPECT:True + +(len("testing") == 7) and (2 * 9 == 18 + 9) or (64 / 4 == 16) +#EXPECT:True + +(len("kakapups") == 7) and (3 * 5 == 15 + 10) or (144 / 6 == 24) +#EXPECT:True + +int("7") == 7 +#EXPECT:True + +float("3.14") == 3.14 +#EXPECT:True + +round(3.7) == 4 +#EXPECT:True + +str(42) == "42" +#EXPECT:True + +str(int("42")) == "42" +#EXPECT:True + +"code" + str(42) == "code42" +#EXPECT:True + +round(float("5.67")) == 6 +#EXPECT:True + +max(int("10"), round(8.5), float("7.3")) == 10 +#EXPECT:True + +int(float("9.8")) == 9 +#EXPECT:True + +str(round(float("7.89"))) == "8" +#EXPECT:True + +float(str(round(6.789))) == 7.0 +#EXPECT:True + +not ((x > 10 and y < 20) or (x > 30 and y < 40) or (x == 15)) +#EXPECT:True + +(x * 3 + y / 2) > 20 and (x % 5 == 0 or y % 3 == 0) or ("test" + "case" == "testcase") +#EXPECT:True + +len("Short") >= 5 and len("Short") < 15 or (3.0 / 2 == 1.5) +#EXPECT:True + +len("Medium Length") >= 15 and len("Medium Length") < 25 or (7.5 / 2 == 3.75) +#EXPECT:True + +len("A Really Long Text with Many Words") >= 30 and len("A Really Long Text with Many Words") < 40 or (12.0 / 2 == 6.0) +#EXPECT:True + +len("1234567890") >= 10 and len("1234567890") < 20 or (5.0 / 2 == 2.5) +#EXPECT:True + +len("!@#$%^&*") >= 7 and len("!@#$%^&*") < 17 or (8.5 / 2 == 4.25) +#EXPECT:True + +len("Spaces Between") >= 10 and len("Spaces Between") < 20 or (11.5 / 2 == 5.75) +#EXPECT:True + + diff --git a/tests/or.lgx b/tests/or.lgx new file mode 100644 index 0000000..4bd5f4c --- /dev/null +++ b/tests/or.lgx @@ -0,0 +1,23 @@ + "hello" or "world" and "kaputt" + 4 +#EXPECT:"hello" + +"hello" and "world" or "kaputt" and + 4 +#EXPECT:"world" + +s == "apple" or s == "banana" +#EXPECT:False + +n % 5 == 0 or n % 7 == 0 +#EXPECT:True + +#SET:year:2020 +(year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) +#EXPECT:True + +#SET:year:2000 +(year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) +#EXPECT:True + +#SET:year:2023 +(year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) +#EXPECT:False diff --git a/tests/plus.lgx b/tests/plus.lgx new file mode 100644 index 0000000..cf31838 --- /dev/null +++ b/tests/plus.lgx @@ -0,0 +1,26 @@ + "arbeit" + "tag" + 300 ** 4 +#EXPECT:"arbeittag8100000000" + +"Maus" + "Brand" < "Nager" + "Clown" +#EXPECT:True + +700 * "Mäuse" + "Fallen" < 700 * "Katzen" +#EXPECT:False + +(3*"arbeit")+7*90 +#EXPECT:"arbeitarbeitarbeit630" + +700 < (200 + 499) +#EXPECT:False + +"hello" and "world" + 4 +#EXPECT:"world4" + +"hello" or "world" and "kaputt" + 4 +#EXPECT:"hello" + +"hello" and "world" or "kaputt" and + 4 +#EXPECT:"world" + +700 + 1 if True else "b" +#EXPECT:701 diff --git a/tests/smalleras.lgx b/tests/smalleras.lgx new file mode 100644 index 0000000..105fe6e --- /dev/null +++ b/tests/smalleras.lgx @@ -0,0 +1,20 @@ + "Maus" + "Brand" < "Nager" + "Clown" +#EXPECT:True + +700 * "Mäuse" + "Fallen" < 700 * "Katzen" +#EXPECT:False + +700 < (200 + 499) +#EXPECT:False + +700 < 1 if True else "b" +#EXPECT:False + +x >= 10 and x < 20 +#EXPECT:False + +not (30 <= y <= 40) +#EXPECT:True + +not (100 <= z <= 200) +#EXPECT:True diff --git a/tests/vars.lgx b/tests/vars.lgx index ef8fbc9..bac44ed 100644 --- a/tests/vars.lgx +++ b/tests/vars.lgx @@ -1,6 +1,24 @@ #set:i:10 + i + i #expect:20 i * "Logics" #expect:"LogicsLogicsLogicsLogicsLogicsLogicsLogicsLogicsLogicsLogics" + +#set:y:25 +#set:x:8 +(x > 10 and y < 30) or (x < 5 or y == 25) and (x != 7) or not (x == 10) +#EXPECT:True + +#set:x:25 +(x % 3 == 0 and x % 5 == 0) or (x % 2 == 0) and ("foo" + "bar" == "foobar") or (100 / 5 == 20) +#EXPECT:True + +#set:value:15 +"even" if value % 2 == 0 else ("positive" if value > 0 else "negative") +#EXPECT:"positive" + +#set:text_length:len("This is a long text") +text_length >= 10 and text_length < 20 or (5.5 /2 ==2.75) +#EXPECT:True From 8316d3d8a4b9e2ec9f269d909db83fff171d29b0 Mon Sep 17 00:00:00 2001 From: Jan Max Meyer Date: Mon, 10 Mar 2025 13:29:11 +0100 Subject: [PATCH 2/2] Rename some testcases --- tests/{ => testsuite-pumuckl}/expressions.lgx | 0 tests/{ => testsuite-pumuckl}/notsorted.lgx | 0 tests/{ => testsuite-pumuckl}/vars.lgx | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename tests/{ => testsuite-pumuckl}/expressions.lgx (100%) rename tests/{ => testsuite-pumuckl}/notsorted.lgx (100%) rename tests/{ => testsuite-pumuckl}/vars.lgx (100%) diff --git a/tests/expressions.lgx b/tests/testsuite-pumuckl/expressions.lgx similarity index 100% rename from tests/expressions.lgx rename to tests/testsuite-pumuckl/expressions.lgx diff --git a/tests/notsorted.lgx b/tests/testsuite-pumuckl/notsorted.lgx similarity index 100% rename from tests/notsorted.lgx rename to tests/testsuite-pumuckl/notsorted.lgx diff --git a/tests/vars.lgx b/tests/testsuite-pumuckl/vars.lgx similarity index 100% rename from tests/vars.lgx rename to tests/testsuite-pumuckl/vars.lgx