aboutsummaryrefslogtreecommitdiffstats
path: root/test-cases/case2_lookahead/script.sh
blob: a77eb85fb8dcf866f2b8ebe9d3883bd6be99d63c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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 {
        a(?!x)x { echo yes }
        .* { echo no }
    }
}
match x1 a no
match x1 aa no
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