mirror of
https://github.com/usatiuk/psil.git
synced 2025-10-28 10:47:49 +01:00
simple tests
This commit is contained in:
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -4,6 +4,7 @@
|
||||
<component name="CidrRootsConfiguration">
|
||||
<excludeRoots>
|
||||
<file path="$PROJECT_DIR$/cmake-build-debug" />
|
||||
<file path="$PROJECT_DIR$/cmake-build-release" />
|
||||
<file path="$PROJECT_DIR$/cmake-build-relwithdebinfo" />
|
||||
</excludeRoots>
|
||||
</component>
|
||||
|
||||
12
clitests/fib.psil
Normal file
12
clitests/fib.psil
Normal file
@@ -0,0 +1,12 @@
|
||||
(define (fib n)
|
||||
(if (> n 0)
|
||||
(if (> n 1)
|
||||
(+ (fib (- n 1))
|
||||
(fib (- n 2)))
|
||||
1)
|
||||
0)
|
||||
)
|
||||
|
||||
(fib 10)
|
||||
(fib 11)
|
||||
(fib 12)
|
||||
3
clitests/fib.psil.ex
Normal file
3
clitests/fib.psil.ex
Normal file
@@ -0,0 +1,3 @@
|
||||
55
|
||||
89
|
||||
144
|
||||
31
clitests/testall.sh
Executable file
31
clitests/testall.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#! /bin/bash
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
FAILED=()
|
||||
|
||||
PSIL="../cmake-build-debug/src/psil"
|
||||
|
||||
for FILE in *.psil; do
|
||||
echo "TESTING $FILE"
|
||||
$PSIL -f $FILE --repl- > $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
|
||||
|
||||
rm $FILE.res
|
||||
done
|
||||
|
||||
if [ ${#FAILED[@]} -eq 0 ]; then
|
||||
echo "ALL TESTS PASSED"
|
||||
else
|
||||
echo "FAILED: ${FAILED[@]}"
|
||||
exit -1
|
||||
fi
|
||||
@@ -149,8 +149,8 @@ void VM::step() {
|
||||
Logger::log(
|
||||
"Compiler",
|
||||
[&](std::ostream &out) {
|
||||
out << "Compiled (" << code << ")\n";
|
||||
out << "to\n";
|
||||
out << "Compiled (" << code << ")";
|
||||
out << " to ";
|
||||
out << "(" << newc << ")";
|
||||
},
|
||||
Logger::DEBUG);
|
||||
|
||||
Reference in New Issue
Block a user