aboutsummaryrefslogtreecommitdiffstats
path: root/test-cases/case2_positive_lookahead/script.sh
blob: 053461dde0030d8370141a5a5ebe66331ca6ffc6 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
echo begin

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
echo x0

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
echo x1

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 x2 foo_stuff_bar yes
match x2 foo_stuff_bar_more_stuff yes
echo x2

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
echo x3

fun x4 {
    case $1 {
        (?=((a.)*e))(?=((a..)*e)).* { echo yes }
        .* { echo no }
    }
}
match x4 '' no
match x4 e yes
match x4 a no
match x4 ab no
match x4 abe no
match x4 abaaabe yes
match x4 aaaaaae yes
match x4 aaaaaaae no
match x4 aaaaaaaae no
match x4 aaaaaaaaae no
match x4 aaaaaaaaaae no
match x4 aaaaaaaaaaae no
match x4 aaaaaaaaaaaae yes
echo x4

fun x5 {
    case $1 {
        (?=(a.)*e)(?=(a..)*e)(?=(a....)*e).*e { echo yes }
        .* { echo no }
    }
}
match x5 e yes
match x5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaae no
match x5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaae yes
match x5 a.aaaaaaaaaaaaaaaaaaaaaaaaaaa.e yes
match x5 .aaaaaaaaaaaaaaaaaaaaaaaaaaaaae no
match x5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae no
echo x5

echo done