diff options
| author | Jonas Maier <jonas@x77.dev> | 2026-06-02 22:00:57 +0200 |
|---|---|---|
| committer | Jonas Maier <jonas@x77.dev> | 2026-06-02 22:00:57 +0200 |
| commit | 10defcf9f7132bdcc88c1fe32d9550a0d5952042 (patch) | |
| tree | a12085cedd489bec1e73abb2c368474471894d42 | |
| parent | dbca276ac60af603209f62dcc2e0e1fcfbebae11 (diff) | |
| download | pish-10defcf9f7132bdcc88c1fe32d9550a0d5952042.tar.gz | |
split lookahead tests into positive and negative
| -rw-r--r-- | test-cases/case2_positive_lookahead/script.sh | 62 | ||||
| -rw-r--r-- | test-cases/case2_positive_lookahead/stdout.txt (renamed from test-cases/case2_lookahead/stdout.txt) | 0 | ||||
| -rw-r--r-- | test-cases/case3_negative_lookahead/script.sh (renamed from test-cases/case2_lookahead/script.sh) | 42 | ||||
| -rw-r--r-- | test-cases/case3_negative_lookahead/stdout.txt | 0 | ||||
| -rw-r--r-- | tests/scripts.rs | 9 |
5 files changed, 79 insertions, 34 deletions
diff --git a/test-cases/case2_positive_lookahead/script.sh b/test-cases/case2_positive_lookahead/script.sh new file mode 100644 index 0000000..e24cbcb --- /dev/null +++ b/test-cases/case2_positive_lookahead/script.sh @@ -0,0 +1,62 @@ +case foo { + f(?=o)oo {} + .* { echo fail 1 } +} + +case foo { + fo(?=x)o { echo fail 2 } + .* { } +} + +fun match { + set res = $($1 $2) + if [ $res != $3 ] { + echo "match $1 $2: expected $3, got $res" + } +} + +fun x0 { + case $1 { + a(?=b). { echo yes } + .* { echo no } + } +} +match x0 aa no +match x0 aaa no +match x0 ab yes + +fun x1 { + case $1 { + x(?=foo)(?=...bar).* { echo yes } + .* { echo no } + } +} +match x1 xfoobar yes +match x1 xfoobar_some_more_stuff yes +match x1 x___bar no +match x1 xfoo___ no +match x1 xfoo no + +fun x2 { + case $1 { + (?=foo).*(?=bar).* { echo yes } + .* { echo no } + } +} +match x2 foobar yes +match x2 foobarbaz yes +match x2 barfoo no +match x2 foobaz no +match x3 foo_stuff_bar yes +match x3 foo_stuff_bar_more_stuff yes + +fun x3 { + case $1 { + (?=abc).*(?=cde).* { echo yes } + .* { echo no } + } +} +match x3 abc_cde yes +match x3 abcde yes +match x3 abcdef yes +match x3 abde no diff --git a/test-cases/case2_lookahead/stdout.txt b/test-cases/case2_positive_lookahead/stdout.txt index e69de29..e69de29 100644 --- a/test-cases/case2_lookahead/stdout.txt +++ b/test-cases/case2_positive_lookahead/stdout.txt diff --git a/test-cases/case2_lookahead/script.sh b/test-cases/case3_negative_lookahead/script.sh index 891441b..3246f74 100644 --- a/test-cases/case2_lookahead/script.sh +++ b/test-cases/case3_negative_lookahead/script.sh @@ -1,13 +1,3 @@ -case foo { - f(?=o)oo {} - .* { echo fail 1 } -} - -case foo { - fo(?=x)o { echo fail 2 } - .* { } -} - fun match { set res = $($1 $2) if [ $res != $3 ] { @@ -15,16 +5,6 @@ fun match { } } -fun x0 { - case $1 { - a(?=b). { echo yes } - .* { echo no } - } -} -match x0 aa no -match x0 aaa no -match x0 ab yes - fun x1 { case $1 { a(?!x)x { echo yes } @@ -37,18 +17,6 @@ match x1 ax no match x1 axx no match x1 aax no -fun x2 { - case $1 { - x(?=foo)(?=...bar).* { echo yes } - .* { echo no } - } -} -match x2 xfoobar yes -match x2 xfoobar_some_more_stuff yes -match x2 x___bar no -match x2 xfoo___ no -match x2 xfoo no - fun x3 { case $1 { x(?!(a|b)).* { echo yes } @@ -63,3 +31,13 @@ match x3 xbx no match x3 xxa yes match x3 xxb yes match x3 xfoobar yes + +fun x4 { + case $1 { + x(?!a).* { echo yes } + .* { echo no } + } +} +match x4 x yes +match x4 xa no +match x4 xy no diff --git a/test-cases/case3_negative_lookahead/stdout.txt b/test-cases/case3_negative_lookahead/stdout.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test-cases/case3_negative_lookahead/stdout.txt diff --git a/tests/scripts.rs b/tests/scripts.rs index 945a506..2a7a6f8 100644 --- a/tests/scripts.rs +++ b/tests/scripts.rs @@ -12,8 +12,13 @@ fn case1() { } #[test] -fn case2_lookahead() { - common::test_case("case2_lookahead", include_bytes!("../test-cases/case2_lookahead/script.sh"), include_bytes!("../test-cases/case2_lookahead/stdout.txt")); +fn case2_positive_lookahead() { + common::test_case("case2_positive_lookahead", include_bytes!("../test-cases/case2_positive_lookahead/script.sh"), include_bytes!("../test-cases/case2_positive_lookahead/stdout.txt")); +} + +#[test] +fn case3_negative_lookahead() { + common::test_case("case3_negative_lookahead", include_bytes!("../test-cases/case3_negative_lookahead/script.sh"), include_bytes!("../test-cases/case3_negative_lookahead/stdout.txt")); } #[test] |
