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.
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.
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/>.
15 # More ksh-like extended globbing tests, cribbed from zsh-3.1.5
20 while read res str pat; do
21 [[ $res = '#' ]] && continue
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 ]]"
34 t fooofoofofooo *(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)
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))
64 t oxfoxoxfox *(oxf+(ox))
65 f oxfoxfox *(oxf+(ox))
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)
80 t moo.cow !(*.*).!(*.*)
81 f mad.moo.cow !(*.*).!(*.*)
82 f mucca.pazza mu!(*(c))?.pa!(*(z))?
103 echo "$failed tests failed."