test-parser.sh 914 B

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