1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-19 09:38:28 +03:00
mal/impls/tests/run_argv_test.sh
Joel Martin 8a19f60386 Move implementations into impls/ dir
- Reorder README to have implementation list after "learning tool"
  bullet.

- This also moves tests/ and libs/ into impls. It would be preferrable
  to have these directories at the top level.  However, this causes
  difficulties with the wasm implementations which need pre-open
  directories and have trouble with paths starting with "../../". So
  in lieu of that, symlink those directories to the top-level.

- Move the run_argv_test.sh script into the tests directory for
  general hygiene.
2020-02-10 23:50:16 -06:00

40 lines
817 B
Bash
Executable File

#!/bin/bash
#
# Usage: run_argv_test.sh <command line arguments to run mal>
#
# Example: run_argv_test.sh python step6_file.py
#
assert_equal() {
if [ "$1" = "$2" ] ; then
echo "OK: '$1'"
else
echo "FAIL: Expected '$1' but got '$2'"
echo
exit 1
fi
}
if [ -z "$1" ] ; then
echo "Usage: $0 <command line arguments to run mal>"
exit 1
fi
root="$(dirname $0)"
out="$( $@ $root/print_argv.mal aaa bbb ccc | tr -d '\r' )"
assert_equal '("aaa" "bbb" "ccc")' "$out"
# Note: The 'make' implementation cannot handle arguments with spaces in them,
# so for now we skip this test.
#
# out="$( $@ $root/print_argv.mal aaa 'bbb ccc' ddd )"
# assert_equal '("aaa" "bbb ccc" "ddd")' "$out"
out="$( $@ $root/print_argv.mal | tr -d '\r' )"
assert_equal '()' "$out"
echo 'Passed all *ARGV* tests'
echo