repl test

This commit is contained in:
2024-01-04 13:06:05 +01:00
parent 49de281083
commit 7fef17ca01
4 changed files with 40 additions and 5 deletions

View File

@@ -11,7 +11,8 @@ cmake -B build -DCMAKE_BUILD_TYPE=Debug -DSANITIZE=YES
cmake --build build --parallel $(nproc) 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) 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: See the GC in action:
```shell ```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: See a tree of function applications:
```shell ```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: Super debug mode:
```shell ```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 # 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. 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 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`... for the purposes of `if`. And of course, all the usual stuff with cons cells - `car`, `cdr`, `cons`...

View File

@@ -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)

View File

@@ -0,0 +1,5 @@
> 5
> ok
> 9
> > ok
>

View File

@@ -22,6 +22,25 @@ for FILE in *.test.psil; do
rm $FILE.res rm $FILE.res
done 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 if [ ${#FAILED[@]} -eq 0 ]; then
echo "ALL TESTS PASSED" echo "ALL TESTS PASSED"
else else