test-vm.sh 867 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. #
  3. # Run interpreter tests
  4. #
  5. # Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
  6. # License: GPLv3+
  7. #####
  8. input=tests/generator/output
  9. output=tests/interpreter/output # output should be the same
  10. log=test-vm.log
  11. rm -f $log
  12. ret=0
  13. run_test ()
  14. {
  15. base="$1"
  16. echo "$base: " >>$log
  17. tmp=test-vm-$base.tmp
  18. timeout 5s ./vm < "$input/$base.out" >$tmp 2>/dev/null
  19. if diff -Nau $output/$base.out $tmp >>$log; then
  20. printf "$base: PASS\n\n" >>$log
  21. else
  22. printf "$base: FAIL\n\n" >>$log
  23. ret=1
  24. fi
  25. rm $tmp
  26. }
  27. run_test choice
  28. run_test big-choice
  29. run_test else
  30. run_test print
  31. run_test test-case-1
  32. run_test test-case-2
  33. run_test test-case-4
  34. run_test count
  35. run_test 100_doors
  36. run_test negative
  37. run_test deep
  38. run_test gcd
  39. run_test factorial
  40. run_test fibonacci
  41. run_test fizzbuzz
  42. run_test 99bottles
  43. run_test primes
  44. run_test mandelbrot
  45. exit $ret