aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-23 13:31:35 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-23 13:31:35 -0500
commit5d654490bee273bcd6afe612100dafac08199218 (patch)
treeae150f3f955faec7affdf841f86b488a73e54327
parent87bc0cfdbddeb550b7d7959c88088ef9658a5e2d (diff)
Add first test
-rw-r--r--Makefile3
-rw-r--r--tests/arrays.nl27
2 files changed, 30 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index a5b37b5a..584c56e7 100644
--- a/Makefile
+++ b/Makefile
@@ -39,6 +39,9 @@ SipHash/halfsiphash.c:
tags:
ctags *.[ch] **/*.[ch]
+test: nextlang
+ for f in tests/*; do echo -e "\x1b[1;4m$$f\x1b[m"; VERBOSE=0 ./nextlang "$$f" || break; done
+
clean:
rm -f nextlang *.o builtins/*.o libnext.so
diff --git a/tests/arrays.nl b/tests/arrays.nl
new file mode 100644
index 00000000..bbe36e42
--- /dev/null
+++ b/tests/arrays.nl
@@ -0,0 +1,27 @@
+>> 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]
+