aboutsummaryrefslogtreecommitdiffstats
path: root/test-cases/case2_positive_lookahead/script.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test-cases/case2_positive_lookahead/script.sh')
-rw-r--r--test-cases/case2_positive_lookahead/script.sh62
1 files changed, 62 insertions, 0 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