1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-18 09:17:40 +00:00

Add optional form to peg (shorthand for (between 0 1 patt)).

This commit is contained in:
Calvin Rose
2019-01-15 14:08:03 -05:00
parent f0fcdf6bc5
commit 4eeadd7463
3 changed files with 20 additions and 1 deletions

View File

@@ -319,4 +319,13 @@
(check-match janet-longstring "``` `` ```" true)
(check-match janet-longstring "`` ```" false)
# Optional
(check-match '(* (opt "hi") -1) "" true)
(check-match '(* (opt "hi") -1) "hi" true)
(check-match '(* (opt "hi") -1) "no" false)
(check-match '(* (? "hi") -1) "" true)
(check-match '(* (? "hi") -1) "hi" true)
(check-match '(* (? "hi") -1) "no" false)
(end-suite)