Add a testsuite using beef bf interpreter
This commit is contained in:
parent
6ab1331032
commit
f5bebc56b8
6 changed files with 39 additions and 0 deletions
33
runtests.sh
Executable file
33
runtests.sh
Executable file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
bfc="./bfc"
|
||||||
|
beef="beef"
|
||||||
|
|
||||||
|
make || exit 1
|
||||||
|
|
||||||
|
for bftest in tests/*.bf
|
||||||
|
do
|
||||||
|
for input in tests/*.in
|
||||||
|
do
|
||||||
|
beefres=$(tempfile)
|
||||||
|
bfcelf=$(tempfile)
|
||||||
|
bfcelfres=$(tempfile)
|
||||||
|
$beef -i $input $bftest > $beefres
|
||||||
|
$bfc -o $bfcelf $bftest 2>/dev/null
|
||||||
|
chmod +x $bfcelf
|
||||||
|
$bfcelf < $input > $bfcelfres
|
||||||
|
|
||||||
|
diff=$(diff $bfcelfres $beefres)
|
||||||
|
if [ -n "$diff" ]
|
||||||
|
then
|
||||||
|
echo "========"
|
||||||
|
echo "Error : $bftest on $input differs between bfc and beef"
|
||||||
|
diff $bfcelfres $beefres
|
||||||
|
hexdump -C $bfcres
|
||||||
|
hexdump -C $beefres
|
||||||
|
echo "========"
|
||||||
|
fi
|
||||||
|
echo "$bftest $input [OK]"
|
||||||
|
rm $beefres $bfcres $bfcelf $bfcelfres
|
||||||
|
done
|
||||||
|
done
|
||||||
1
tests/echo.bf
Normal file
1
tests/echo.bf
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
+[,[.>]<]
|
||||||
2
tests/hello.in
Normal file
2
tests/hello.in
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
Hello world !
|
||||||
|
|
||||||
1
tests/helloworld.bf
Normal file
1
tests/helloworld.bf
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
|
||||||
1
tests/reverse.bf
Normal file
1
tests/reverse.bf
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
+[<,]# >[>]<-<[<]#>[.>]
|
||||||
1
tests/rot13.bf
Normal file
1
tests/rot13.bf
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
>++++++++[>+++++++++++[<<+>>-]<-]<-.++++++++++++++++++++++++..+++++.>++++++++++++[>+++++++[<<->>-]<-]<.>++++++++[>+++++++++++[<<+>>-]<-]<-.--------..+++++.>++++++++++++[>+++++++[<<->>-]<-]<.+.-.++++++++++++++++++++++++++.++++++++++.>+++[>+++++++++++++++++++[<<->>-]<-]<-.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue