Skip to content

Commit

Permalink
Make auto-test actually compare output.
Browse files Browse the repository at this point in the history
  • Loading branch information
xy-kasumi committed Apr 11, 2014
1 parent 54d2ef1 commit 243635d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 29 deletions.
38 changes: 23 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,51 @@ But lack of class/instance does mean you can't do things like `show :: Show a =>
## Compilation & Testing
Run `./conv` followed by `./auto-test` (you'll need fish shell for both).

If it's ok, the result will look like below (the ordering and runtime may differ):
If it's ok, the result will look like below (the runtime may differ):

```
=== test/Halt.hs ===
71330 steps
user:0.00 sys:0.00
PASSED
=== test/Const.hs ===
~2422548 steps
2422548 steps
user:0.01 sys:0.00
PASSED
=== test/ExplicitCase.hs ===
o2873704 steps
user:0.01 sys:0.00
2873704 steps
user:0.02 sys:0.00
PASSED
=== test/Hello.hs ===
Hello!540952260 steps
user:2.76 sys:0.00
540952260 steps
user:2.82 sys:0.00
PASSED
=== test/LocalFun.hs ===
~14103014 steps
14103014 steps
user:0.08 sys:0.00
PASSED
=== test/Lambda.hs ===
A12416333 steps
12416333 steps
user:0.07 sys:0.00
PASSED
=== test/Arithmetic.hs ===
o441625467 steps
user:2.22 sys:0.00
441625467 steps
user:2.27 sys:0.00
PASSED
=== test/ShowList.hs ===
123
2421699790 steps
user:12.13 sys:0.01
1031462671 steps
user:5.36 sys:0.00
PASSED
=== test/QuickSort.hs ===
best28503865233 steps
user:141.97 sys:0.40
28503865233 steps
user:144.20 sys:0.17
PASSED
```
49 changes: 36 additions & 13 deletions auto-test
Original file line number Diff line number Diff line change
@@ -1,23 +1,46 @@
#!/bin/env fish

# test_bf ::
# FilePath -> -- ^ Haskell code to be compiled and run
# String -> -- ^ Expected output
# IO ()
function test_bf
echo "=== $argv[1] ==="
rm -f test/(basename $argv[1] .hs).bf
dist/build/hs2bf/hs2bf --make $argv[1] > test/(basename $argv[1] .hs).bf
time -f 'user:%U sys:%S' bfi/bfi test/(basename $argv[1] .hs).bf
set hs_path $argv[1]
set bf_path test/(basename $argv[1] .hs).bf
set expected $argv[2]

echo "=== $hs_path ==="

rm -f $bf_path
dist/build/hs2bf/hs2bf --make $hs_path > $bf_path

set result (time -f 'user:%U sys:%S' bfi/bfi $bf_path)

if test "$result" = "$expected"
set_color green
echo "PASSED"
set_color normal
else
set_color red
echo "FAILED"
set_color normal
echo "expected: " $expected
echo "actual: " $result
end

echo ""
end


test_bf test/Halt.hs
and test_bf test/Const.hs
and test_bf test/ExplicitCase.hs
and test_bf test/Hello.hs
and test_bf test/LocalFun.hs
and test_bf test/Lambda.hs
and test_bf test/Arithmetic.hs
and test_bf test/ShowList.hs
and test_bf test/QuickSort.hs
test_bf test/Halt.hs ""
and test_bf test/Const.hs "~"
and test_bf test/ExplicitCase.hs "o"
and test_bf test/Hello.hs "Hello!"
and test_bf test/LocalFun.hs "~"
and test_bf test/Lambda.hs "A"
and test_bf test/Arithmetic.hs "o"
and test_bf test/ShowList.hs "123"
and test_bf test/QuickSort.hs "best"
# and test_bf test/TypeClass.hs
# and test_bf test/ConstPattern.hs
# and test_bf test/
2 changes: 1 addition & 1 deletion test/ShowList.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


main=outputStr Halt ((map showByte1 [1,2,3])++"\n")
main=outputStr Halt (map showByte1 [1,2,3])

showByte1 x=addByte '0' x

Expand Down

0 comments on commit 243635d

Please sign in to comment.