Add first test
This commit is contained in:
parent
87bc0cfdbd
commit
5d654490be
3
Makefile
3
Makefile
@ -39,6 +39,9 @@ SipHash/halfsiphash.c:
|
|||||||
tags:
|
tags:
|
||||||
ctags *.[ch] **/*.[ch]
|
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:
|
clean:
|
||||||
rm -f nextlang *.o builtins/*.o libnext.so
|
rm -f nextlang *.o builtins/*.o libnext.so
|
||||||
|
|
||||||
|
27
tests/arrays.nl
Normal file
27
tests/arrays.nl
Normal file
@ -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]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user