Browse Source

Add a testsuite using beef bf interpreter

Yann Weber 2 years ago
parent
commit
f5bebc56b8
6 changed files with 39 additions and 0 deletions
  1. 33
    0
      runtests.sh
  2. 1
    0
      tests/echo.bf
  3. 2
    0
      tests/hello.in
  4. 1
    0
      tests/helloworld.bf
  5. 1
    0
      tests/reverse.bf
  6. 1
    0
      tests/rot13.bf

+ 33
- 0
runtests.sh View File

@@ -0,0 +1,33 @@
1
+#!/bin/sh
2
+
3
+bfc="./bfc"
4
+beef="beef"
5
+
6
+make || exit 1
7
+
8
+for bftest in tests/*.bf
9
+do
10
+	for input in tests/*.in
11
+	do
12
+		beefres=$(tempfile)
13
+		bfcelf=$(tempfile)
14
+		bfcelfres=$(tempfile)
15
+		$beef -i $input $bftest > $beefres
16
+		$bfc -o $bfcelf $bftest 2>/dev/null
17
+		chmod +x $bfcelf
18
+		$bfcelf < $input > $bfcelfres
19
+
20
+		diff=$(diff $bfcelfres $beefres)
21
+		if [ -n "$diff" ]
22
+		then
23
+			echo "========"
24
+			echo "Error : $bftest on $input differs between bfc and beef"
25
+			diff $bfcelfres $beefres
26
+			hexdump -C $bfcres 
27
+			hexdump -C $beefres
28
+			echo "========"
29
+		fi
30
+		echo "$bftest $input [OK]"
31
+		rm $beefres $bfcres $bfcelf $bfcelfres
32
+	done
33
+done

+ 1
- 0
tests/echo.bf View File

@@ -0,0 +1 @@
1
++[,[.>]<]

+ 2
- 0
tests/hello.in View File

@@ -0,0 +1,2 @@
1
+Hello world !
2
+

+ 1
- 0
tests/helloworld.bf View File

@@ -0,0 +1 @@
1
+++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

+ 1
- 0
tests/reverse.bf View File

@@ -0,0 +1 @@
1
++[<,]# >[>]<-<[<]#>[.>]

+ 1
- 0
tests/rot13.bf View File

@@ -0,0 +1 @@
1
+>++++++++[>+++++++++++[<<+>>-]<-]<-.++++++++++++++++++++++++..+++++.>++++++++++++[>+++++++[<<->>-]<-]<.>++++++++[>+++++++++++[<<+>>-]<-]<-.--------..+++++.>++++++++++++[>+++++++[<<->>-]<-]<.+.-.++++++++++++++++++++++++++.++++++++++.>+++[>+++++++++++++++++++[<<->>-]<-]<-.

Loading…
Cancel
Save