test-generator.sh 884 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. #
  3. # Run generator tests
  4. #
  5. # Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
  6. # License: GPLv3+
  7. #####
  8. input=tests/parser/output
  9. output=tests/generator/output
  10. log=test-generator.log
  11. rm -f $log
  12. ret=0
  13. run_test ()
  14. {
  15. base="$1"
  16. echo "$base: " >>$log
  17. tmp=test-generator-$base.tmp
  18. timeout 5s ./generator < "$input/$base.out" >$tmp 2>/dev/null
  19. if diff -Naub $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 assign
  28. run_test choice
  29. run_test big-choice
  30. run_test else
  31. run_test expr
  32. run_test print
  33. run_test test-case-1
  34. run_test test-case-2
  35. run_test test-case-4
  36. run_test count
  37. run_test 100_doors
  38. run_test negative
  39. run_test deep
  40. run_test gcd
  41. run_test factorial
  42. run_test fibonacci
  43. run_test fizzbuzz
  44. run_test 99bottles
  45. run_test primes
  46. run_test mandelbrot
  47. exit $ret