diff --git a/README.md b/README.md index 8f49edd..60ededf 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ cmake -B build -DCMAKE_BUILD_TYPE=Debug -DSANITIZE=YES cmake --build build --parallel $(nproc) ``` -should be enough (you can also change the build type for Release and disable sanitize in case it's too slow) +should be enough (you can also change the build type for Release and disable sanitize in case it's too slow, also in +case of problems you can look at the `.gitlab-ci.yml`) Pro-tip: all these snippets can be conveniently run from an IDE if it supports it (at least clion does) @@ -74,19 +75,19 @@ instruction and the machine state before/after See the GC in action: ```shell -build/src/psil -f clitests/fib.psil --repl- --log:Compiler:3 --command_strs+ --cell_limit:10000 --gc_threshold:10 --log:MemoryContext:2 +build/src/psil -f clitests/fib.test.psil --repl- --log:Compiler:3 --command_strs+ --cell_limit:10000 --gc_threshold:10 --log:MemoryContext:2 ``` See a tree of function applications: ```shell -build/src/psil -f clitests/coffee.psil --repl- --log:Compiler:3 --command_strs+ --log:VM:3 +build/src/psil -f clitests/coffee.test.psil --repl- --log:Compiler:3 --command_strs+ --log:VM:3 ``` Super debug mode: ```shell -build/src/psil -f clitests/decorate.psil --repl- --command_strs+ --default_log_level:4 --log:MemoryContext:3 +build/src/psil -f clitests/decorate.test.psil --repl- --command_strs+ --default_log_level:4 --log:MemoryContext:3 ``` # Some notes on the implementation @@ -98,7 +99,8 @@ using `define`, quoting using `(quote value)`, and a simple concurrent garbage c There are three basic value types which is a string atom, number atom, and a cons cell. -String atoms are basically used only internally, and you can't do much with them other than printing them. With number +String atoms are basically used only internally, and you can't do much with them other than printing and comparing them. +With number atoms you can do all the usual arithmetic, and they also serve as bools - any value greater than 0 is considered true for the purposes of `if`. And of course, all the usual stuff with cons cells - `car`, `cdr`, `cons`... diff --git a/clitests/replexample.testi.psil b/clitests/replexample.testi.psil new file mode 100644 index 0000000..c7efc03 --- /dev/null +++ b/clitests/replexample.testi.psil @@ -0,0 +1,9 @@ +(+ 2 3) +(if (= testin (read)) ok bad) +testin +(eval (read)) +(+ 4 5) +(define (equal a b)(if (nil? a) (if (nil? b) 1 0)(if (atom a)(if (atom b) (= a b) 0)(if (atom b) 0 (if (equal (car a) (car b)) (equal (cdr a) (cdr b)) 0))))) +(if (equal (quote(a b)) (read)) ok bad) +(a b) +(quit) \ No newline at end of file diff --git a/clitests/replexample.testi.psil.ex b/clitests/replexample.testi.psil.ex new file mode 100644 index 0000000..1e9d892 --- /dev/null +++ b/clitests/replexample.testi.psil.ex @@ -0,0 +1,5 @@ +> 5 +> ok +> 9 +> > ok +> \ No newline at end of file diff --git a/clitests/testall.sh b/clitests/testall.sh index 554ef72..b99fbfd 100755 --- a/clitests/testall.sh +++ b/clitests/testall.sh @@ -22,6 +22,25 @@ for FILE in *.test.psil; do rm $FILE.res done +for FILE in *.testi.psil; do + echo "TESTING INTERACTIVE $FILE" + $PSIL --repl+ --default_log_level:0 < $FILE > $FILE.res + if [ $? -ne 0 ]; then + FAILED+=("test-"$FILE) + continue + fi + + diff -w $FILE.res $FILE.ex + + if [ $? -ne 0 ]; then + FAILED+=("test-"$FILE) + continue + fi + + echo "$FILE OK" + rm $FILE.res +done + if [ ${#FAILED[@]} -eq 0 ]; then echo "ALL TESTS PASSED" else