mirror of
https://github.com/usatiuk/psil.git
synced 2025-10-28 02:37:48 +01:00
repl test
This commit is contained in:
12
README.md
12
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`...
|
||||
|
||||
|
||||
9
clitests/replexample.testi.psil
Normal file
9
clitests/replexample.testi.psil
Normal 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)
|
||||
5
clitests/replexample.testi.psil.ex
Normal file
5
clitests/replexample.testi.psil.ex
Normal file
@@ -0,0 +1,5 @@
|
||||
> 5
|
||||
> ok
|
||||
> 9
|
||||
> > ok
|
||||
>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user