]>
Commit | Line | Data |
---|---|---|
8868edaf CR |
1 | # This program is free software: you can redistribute it and/or modify |
2 | # it under the terms of the GNU General Public License as published by | |
3 | # the Free Software Foundation, either version 3 of the License, or | |
4 | # (at your option) any later version. | |
5 | # | |
6 | # This program is distributed in the hope that it will be useful, | |
7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
9 | # GNU General Public License for more details. | |
10 | # | |
11 | # You should have received a copy of the GNU General Public License | |
12 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
13 | # | |
bb70624e JA |
14 | # |
15 | # More ksh-like extended globbing tests, cribbed from zsh-3.1.5 | |
16 | # | |
17 | shopt -s extglob | |
18 | ||
19 | failed=0 | |
20 | while read res str pat; do | |
21 | [[ $res = '#' ]] && continue | |
22 | [[ $str = ${pat} ]] | |
23 | ts=$? | |
24 | [[ $1 = -q ]] || echo "$ts: [[ $str = $pat ]]" | |
25 | if [[ ( $ts -gt 0 && $res = t) || ($ts -eq 0 && $res = f) ]]; then | |
26 | echo "Test failed: [[ $str = $pat ]]" | |
27 | (( failed += 1 )) | |
28 | fi | |
29 | done <<EOT | |
30 | t fofo *(f*(o)) | |
31 | t ffo *(f*(o)) | |
32 | t foooofo *(f*(o)) | |
33 | t foooofof *(f*(o)) | |
34 | t fooofoofofooo *(f*(o)) | |
35 | f foooofof *(f+(o)) | |
36 | f xfoooofof *(f*(o)) | |
37 | f foooofofx *(f*(o)) | |
38 | t ofxoofxo *(*(of*(o)x)o) | |
39 | f ofooofoofofooo *(f*(o)) | |
40 | t foooxfooxfoxfooox *(f*(o)x) | |
41 | f foooxfooxofoxfooox *(f*(o)x) | |
42 | t foooxfooxfxfooox *(f*(o)x) | |
43 | t ofxoofxo *(*(of*(o)x)o) | |
44 | t ofoooxoofxo *(*(of*(o)x)o) | |
45 | t ofoooxoofxoofoooxoofxo *(*(of*(o)x)o) | |
46 | t ofoooxoofxoofoooxoofxoo *(*(of*(o)x)o) | |
47 | f ofoooxoofxoofoooxoofxofo *(*(of*(o)x)o) | |
48 | t ofoooxoofxoofoooxoofxooofxofxo *(*(of*(o)x)o) | |
49 | t aac *(@(a))a@(c) | |
50 | t ac *(@(a))a@(c) | |
51 | f c *(@(a))a@(c) | |
52 | t aaac *(@(a))a@(c) | |
53 | f baaac *(@(a))a@(c) | |
54 | t abcd ?@(a|b)*@(c)d | |
55 | t abcd @(ab|a*@(b))*(c)d | |
56 | t acd @(ab|a*(b))*(c)d | |
57 | t abbcd @(ab|a*(b))*(c)d | |
58 | t effgz @(b+(c)d|e*(f)g?|?(h)i@(j|k)) | |
59 | t efgz @(b+(c)d|e*(f)g?|?(h)i@(j|k)) | |
60 | t egz @(b+(c)d|e*(f)g?|?(h)i@(j|k)) | |
61 | t egzefffgzbcdij *(b+(c)d|e*(f)g?|?(h)i@(j|k)) | |
62 | f egz @(b+(c)d|e+(f)g?|?(h)i@(j|k)) | |
63 | t ofoofo *(of+(o)) | |
64 | t oxfoxoxfox *(oxf+(ox)) | |
65 | f oxfoxfox *(oxf+(ox)) | |
66 | t ofoofo *(of+(o)|f) | |
67 | # The following is supposed to match only as fo+ofo+ofo | |
68 | t foofoofo @(foo|f|fo)*(f|of+(o)) | |
69 | t oofooofo *(of|oof+(o)) | |
70 | t fffooofoooooffoofffooofff *(*(f)*(o)) | |
71 | # The following tests backtracking in alternation matches | |
72 | t fofoofoofofoo *(fo|foo) | |
73 | # Exclusion | |
74 | t foo !(x) | |
75 | t foo !(x)* | |
76 | f foo !(foo) | |
77 | t foo !(foo)* | |
78 | t foobar !(foo) | |
79 | t foobar !(foo)* | |
80 | t moo.cow !(*.*).!(*.*) | |
81 | f mad.moo.cow !(*.*).!(*.*) | |
82 | f mucca.pazza mu!(*(c))?.pa!(*(z))? | |
83 | t fff !(f) | |
84 | t fff *(!(f)) | |
85 | t fff +(!(f)) | |
86 | t ooo !(f) | |
87 | t ooo *(!(f)) | |
88 | t ooo +(!(f)) | |
89 | t foo !(f) | |
90 | t foo *(!(f)) | |
91 | t foo +(!(f)) | |
92 | f f !(f) | |
93 | f f *(!(f)) | |
94 | f f +(!(f)) | |
95 | t foot @(!(z*)|*x) | |
96 | f zoot @(!(z*)|*x) | |
97 | t foox @(!(z*)|*x) | |
98 | t zoox @(!(z*)|*x) | |
99 | t foo *(!(foo)) | |
100 | f foob !(foo)b* | |
101 | t foobb !(foo)b* | |
102 | EOT | |
103 | echo "$failed tests failed." |