dc.tests 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. # Copyright 2015 by Bernhard Reutner-Fischer
  3. # Licensed under GPLv2 or later, see file LICENSE in this source tree.
  4. . ./testing.sh
  5. # testing "test name" "command" "expected result" "file input" "stdin"
  6. testing "dc basic syntax (stdin, multiple args)" \
  7. "dc" \
  8. "30\n" \
  9. "" "10 20+p"
  10. testing "dc basic syntax (argv, single arg)" \
  11. "dc '10 20+p'" \
  12. "30\n" \
  13. "" ""
  14. testing "dc basic syntax (argv, multiple args)" \
  15. "dc 10 20+p" \
  16. "30\n" \
  17. "" ""
  18. testing "dc complex with spaces (single arg)" \
  19. "dc '8 8 * 2 2 + / p'" \
  20. "16\n" \
  21. "" ""
  22. testing "dc complex without spaces (single arg)" \
  23. "dc '8 8*2 2+/p'" \
  24. "16\n" \
  25. "" ""
  26. testing "dc complex with spaces (multiple args)" \
  27. "dc 8 8 \* 2 2 + / p" \
  28. "16\n" \
  29. "" ""
  30. testing "dc complex without spaces (multiple args)" \
  31. "dc 8 8\*2 2+/p" \
  32. "16\n" \
  33. "" ""
  34. exit $FAILCOUNT
  35. # we do not support arguments
  36. testing "dc -e <exprs>" \
  37. "dc -e '10 2+f'" \
  38. "12\n" \
  39. "" ""
  40. testing "dc -f <exprs-from-given-file>" \
  41. "dc -f input" \
  42. "12\n" \
  43. "10 2+f" ""