From 0591d3db3a10f5b7e8788a856b708dd0c14a971e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 24 Feb 2024 15:32:02 -0500 Subject: Rename folder --- Makefile | 2 +- test/arrays.nl | 33 +++++++++++++++++++++++++++++++++ test/enums.nl | 20 ++++++++++++++++++++ test/integers.nl | 33 +++++++++++++++++++++++++++++++++ test/structs.nl | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/arrays.nl | 33 --------------------------------- tests/enums.nl | 20 -------------------- tests/integers.nl | 33 --------------------------------- tests/structs.nl | 52 ---------------------------------------------------- 9 files changed, 139 insertions(+), 139 deletions(-) create mode 100644 test/arrays.nl create mode 100644 test/enums.nl create mode 100644 test/integers.nl create mode 100644 test/structs.nl delete mode 100644 tests/arrays.nl delete mode 100644 tests/enums.nl delete mode 100644 tests/integers.nl delete mode 100644 tests/structs.nl diff --git a/Makefile b/Makefile index e44a17e4..4325c358 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ tags: ctags *.[ch] **/*.[ch] test: nextlang - for f in tests/*; do echo -e "\x1b[1;4m$$f\x1b[m"; VERBOSE=0 CC=tcc ./nextlang "$$f" || break; done + for f in test/*; do echo -e "\x1b[1;4m$$f\x1b[m"; VERBOSE=0 CC=tcc ./nextlang "$$f" || break; done clean: rm -f nextlang *.o SipHash/halfsiphash.o builtins/*.o libnext.so diff --git a/test/arrays.nl b/test/arrays.nl new file mode 100644 index 00000000..5484d5e2 --- /dev/null +++ b/test/arrays.nl @@ -0,0 +1,33 @@ +>> [:Num32] += [] : [Num32] + +>> arr := [10, 20, 30] += [10, 20, 30] + +>> arr[1] += 10 +>> arr[-1] += 30 + +sum := 0 +for x in arr + sum += x +>> sum += 60 + +str := "" +for i,x in arr + str ++= "({i},{x})" +>> str += "(1,10)(2,20)(3,30)" + +>> arr2 := [10, 20] ++ [30, 40] += [10, 20, 30, 40] + +>> arr2 ++= [50, 60] +>> arr2 += [10, 20, 30, 40, 50, 60] + +>> arr2 ++= 70 +>> arr2 += [10, 20, 30, 40, 50, 60, 70] diff --git a/test/enums.nl b/test/enums.nl new file mode 100644 index 00000000..8ba90fe6 --- /dev/null +++ b/test/enums.nl @@ -0,0 +1,20 @@ +enum Foo(Zero, One(x:Int), Two(x,y:Int)) + +>> Foo__Zero() += Foo.Zero() +>> Foo__One(123) += Foo.One(x=123) +>> Foo__Two(123, 456) += Foo.Two(x=123, y=456) + +>> Foo__One(10) == Foo__One(10) += yes + +>> Foo__One(10) == Foo__Zero() += no + +>> Foo__One(10) == Foo__One(-1) += no + +>> Foo__One(10) < Foo__Two(1, 2) += yes diff --git a/test/integers.nl b/test/integers.nl new file mode 100644 index 00000000..c20d08e6 --- /dev/null +++ b/test/integers.nl @@ -0,0 +1,33 @@ + +>> 2 + 3 += 5 + +>> 2 * 3 += 6 + +>> 2 + 3 * 4 += 14 + +>> 2 * 3 + 4 += 10 + +>> 1i8 + 2i16 += 3_i16 + +>> 2 ^ 10 += 1024 : Num64 + +>> 3 and 2 += 2 + +>> 3 or 4 += 7 + +>> 3 xor 2 += 1 + +nums := "" +for x in 5 + nums ++= "{x}," +>> nums += "1,2,3,4,5," diff --git a/test/structs.nl b/test/structs.nl new file mode 100644 index 00000000..a9bb545f --- /dev/null +++ b/test/structs.nl @@ -0,0 +1,52 @@ + +struct Pair(x,y:Int) +struct Mixed(x:Int, str:Str) + +func test_literals() + >> x := Pair(10, 20) + = Pair(x=10, y=20) + >> y := Pair(y=20, 10) + = Pair(x=10, y=20) + >> x == y + = yes + >> x == Pair(-1, -2) + = no +test_literals() + +func test_metamethods() + >> x := Pair(10, 20) + >> y := Pair(100, 200) + >> x == y + = no + >> x == Pair(10, 20) + = yes + >> x == Pair(10, 30) + = no + + >> x < Pair(11, 20) + = yes + >> t2 := {x=> "found"; default="missing"} + >> t2[x] + = "found" + >> t2[y] + = "missing" +test_metamethods() + +func test_mixed() + >> x := Mixed(10, "Hello") + >> y := Mixed(99, "Hello") + >> x == y + = no + >> x == Mixed(10, "Hello") + = yes + >> x == Mixed(10, "Bye") + = no + >> x < Mixed(11, "Hello") + = yes + >> t := {x=> "found"; default="missing"} + >> t[x] + = "found" + >> t[y] + = "missing" +test_mixed() + diff --git a/tests/arrays.nl b/tests/arrays.nl deleted file mode 100644 index 5484d5e2..00000000 --- a/tests/arrays.nl +++ /dev/null @@ -1,33 +0,0 @@ ->> [:Num32] -= [] : [Num32] - ->> arr := [10, 20, 30] -= [10, 20, 30] - ->> arr[1] -= 10 ->> arr[-1] -= 30 - -sum := 0 -for x in arr - sum += x ->> sum -= 60 - -str := "" -for i,x in arr - str ++= "({i},{x})" ->> str -= "(1,10)(2,20)(3,30)" - ->> arr2 := [10, 20] ++ [30, 40] -= [10, 20, 30, 40] - ->> arr2 ++= [50, 60] ->> arr2 -= [10, 20, 30, 40, 50, 60] - ->> arr2 ++= 70 ->> arr2 -= [10, 20, 30, 40, 50, 60, 70] diff --git a/tests/enums.nl b/tests/enums.nl deleted file mode 100644 index 8ba90fe6..00000000 --- a/tests/enums.nl +++ /dev/null @@ -1,20 +0,0 @@ -enum Foo(Zero, One(x:Int), Two(x,y:Int)) - ->> Foo__Zero() -= Foo.Zero() ->> Foo__One(123) -= Foo.One(x=123) ->> Foo__Two(123, 456) -= Foo.Two(x=123, y=456) - ->> Foo__One(10) == Foo__One(10) -= yes - ->> Foo__One(10) == Foo__Zero() -= no - ->> Foo__One(10) == Foo__One(-1) -= no - ->> Foo__One(10) < Foo__Two(1, 2) -= yes diff --git a/tests/integers.nl b/tests/integers.nl deleted file mode 100644 index c20d08e6..00000000 --- a/tests/integers.nl +++ /dev/null @@ -1,33 +0,0 @@ - ->> 2 + 3 -= 5 - ->> 2 * 3 -= 6 - ->> 2 + 3 * 4 -= 14 - ->> 2 * 3 + 4 -= 10 - ->> 1i8 + 2i16 -= 3_i16 - ->> 2 ^ 10 -= 1024 : Num64 - ->> 3 and 2 -= 2 - ->> 3 or 4 -= 7 - ->> 3 xor 2 -= 1 - -nums := "" -for x in 5 - nums ++= "{x}," ->> nums -= "1,2,3,4,5," diff --git a/tests/structs.nl b/tests/structs.nl deleted file mode 100644 index a9bb545f..00000000 --- a/tests/structs.nl +++ /dev/null @@ -1,52 +0,0 @@ - -struct Pair(x,y:Int) -struct Mixed(x:Int, str:Str) - -func test_literals() - >> x := Pair(10, 20) - = Pair(x=10, y=20) - >> y := Pair(y=20, 10) - = Pair(x=10, y=20) - >> x == y - = yes - >> x == Pair(-1, -2) - = no -test_literals() - -func test_metamethods() - >> x := Pair(10, 20) - >> y := Pair(100, 200) - >> x == y - = no - >> x == Pair(10, 20) - = yes - >> x == Pair(10, 30) - = no - - >> x < Pair(11, 20) - = yes - >> t2 := {x=> "found"; default="missing"} - >> t2[x] - = "found" - >> t2[y] - = "missing" -test_metamethods() - -func test_mixed() - >> x := Mixed(10, "Hello") - >> y := Mixed(99, "Hello") - >> x == y - = no - >> x == Mixed(10, "Hello") - = yes - >> x == Mixed(10, "Bye") - = no - >> x < Mixed(11, "Hello") - = yes - >> t := {x=> "found"; default="missing"} - >> t[x] - = "found" - >> t[y] - = "missing" -test_mixed() - -- cgit v1.2.3