fix REPL treating a regex literal as an unbalanced form
repl-form-complete? entered the :regex state on '#' but only consumed the '#', so the opening '"' was then read by the :regex handler as the CLOSING quote. The regex body got scanned in :code state, and any delimiter or quote inside it (a group like #"(a)", a char class #"[0-9]+") threw off the paren/string count — so a one-line regex form was judged incomplete and the REPL hung waiting for continuation lines. Consume the '#"' together. Adds a self-checking predicate test (test/chez/repl-reader-test.clj, run via joltc so jolt.main resolves) and an end-to-end regex REPL case in smoke.sh.
This commit is contained in:
parent
4889505204
commit
e4cbbb8912
3 changed files with 53 additions and 2 deletions
|
|
@ -75,6 +75,18 @@ else
|
|||
fails=$((fails + 1))
|
||||
fi
|
||||
|
||||
# Unit-checks the REPL read-until-complete predicate over balanced/unbalanced,
|
||||
# string, comment and regex-literal inputs. A multi-form `joltc run` so jolt.main
|
||||
# is loaded and its private var resolves; the file self-checks and prints a sentinel.
|
||||
rr_out="$(bin/joltc run test/chez/repl-reader-test.clj 2>/dev/null)"
|
||||
if printf '%s' "$rr_out" | grep -q 'REPL-READER OK'; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
echo " FAIL: repl-form-complete? predicate"
|
||||
echo " $(printf '%s' "$rr_out" | grep REPL-READER | tail -1)"
|
||||
fails=$((fails + 1))
|
||||
fi
|
||||
|
||||
# REPL must exit on :repl/quit / :exit — a reliable exit that works in any
|
||||
# terminal, unlike ^D (which some terminals/editors don't deliver as EOF).
|
||||
# Pipe: an evaluable form, the quit keyword, then a sentinel that must NOT run.
|
||||
|
|
@ -107,5 +119,16 @@ else
|
|||
fails=$((fails + 1))
|
||||
fi
|
||||
|
||||
# A single-line regex literal is complete on its own — the #" opens a regex whose
|
||||
# body (delimiters, quotes and all) must not be miscounted as unbalanced parens.
|
||||
repl_out="$(printf '(re-find #"(a)(b)" "ab")\n:exit\n' | bin/joltc repl 2>/dev/null)"
|
||||
if printf '%s' "$repl_out" | grep -q 'ab' && ! printf '%s' "$repl_out" | grep -q 'error'; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
echo " FAIL: repl should evaluate a one-line regex literal, not wait for more input"
|
||||
printf '%s\n' "$repl_out" | sed 's/^/ | /'
|
||||
fails=$((fails + 1))
|
||||
fi
|
||||
|
||||
echo "cli smoke: $pass passed, $fails failed"
|
||||
[ "$fails" -eq 0 ]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue