From a91195af0d5c0e29c37fd2c953d3f51657dfa5fe Mon Sep 17 00:00:00 2001 From: Stoney Jackson Date: Sat, 25 May 2024 02:21:51 +0000 Subject: [PATCH] fix: scan reads files passed on command-line --- src/plcc/bin/scan | 2 +- .../reads-files-given-on-command-line.bats | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/end-to-end/scan/reads-files-given-on-command-line.bats diff --git a/src/plcc/bin/scan b/src/plcc/bin/scan index 72c0d066..83950ab5 100755 --- a/src/plcc/bin/scan +++ b/src/plcc/bin/scan @@ -2,4 +2,4 @@ source "$(dirname -- "${BASH_SOURCE[0]}" )/common.bash" && init assert_file_exists Java/Scan.class -java Scan +java Scan "$@" diff --git a/tests/end-to-end/scan/reads-files-given-on-command-line.bats b/tests/end-to-end/scan/reads-files-given-on-command-line.bats new file mode 100644 index 00000000..55a63096 --- /dev/null +++ b/tests/end-to-end/scan/reads-files-given-on-command-line.bats @@ -0,0 +1,25 @@ +#!/usr/bin/env bats + +load '../relocate_to_temp.bash' + +@test "scan reads files passed on command-line" { + relocate_to_temp + + cat << EOF > grammar +skip WHITESPACE '\s' +token FOO 'foo' +token BAR 'bar' +token ID '[A-Za-z]\w*' +EOF + + echo "foo bar \n foobar" > in.file + + TOKENS="$( + plccmk -c grammar && + scan in.file + )" + + [[ "$TOKENS" =~ "FOO 'foo'" ]] + [[ "$TOKENS" =~ "BAR 'bar'" ]] + [[ "$TOKENS" =~ "ID 'foobar'" ]] +}