aboutsummaryrefslogtreecommitdiffstats
path: root/test-cases/case3_negative_lookahead/script.sh
blob: 987a8862ac9dc29ac1497b7f1f0b0991bc587827 (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
51
52
53
54
55
fun match {
    set res = $($1 $2)
    if [ $res != $3 ] {
        echo "match $1 $2: expected $3, got $res"
    }
}

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 x3 {
    case $1 {
        x(?!(a|b)).* { echo yes }
        .* { echo no }
    }
}
match x3 x yes
match x3 xa no
match x3 xb no
match x3 xax no
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 yes

fun x5 {
    case $1 {
        (?!foo)... { echo yes }
        .* { echo no }
    }
}
match x5 x no
match x5 xy no
match x5 xyz yes
match x5 foo no
match x5 abc yes