]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/extglob2.tests
Bash-4.3 patch 7
[thirdparty/bash.git] / tests / extglob2.tests
CommitLineData
bb70624e
JA
1#
2# More ksh-like extended globbing tests, cribbed from zsh-3.1.5
3#
4shopt -s extglob
5
6failed=0
7while read res str pat; do
8 [[ $res = '#' ]] && continue
9 [[ $str = ${pat} ]]
10 ts=$?
11 [[ $1 = -q ]] || echo "$ts: [[ $str = $pat ]]"
12 if [[ ( $ts -gt 0 && $res = t) || ($ts -eq 0 && $res = f) ]]; then
13 echo "Test failed: [[ $str = $pat ]]"
14 (( failed += 1 ))
15 fi
16done <<EOT
17t fofo *(f*(o))
18t ffo *(f*(o))
19t foooofo *(f*(o))
20t foooofof *(f*(o))
21t fooofoofofooo *(f*(o))
22f foooofof *(f+(o))
23f xfoooofof *(f*(o))
24f foooofofx *(f*(o))
25t ofxoofxo *(*(of*(o)x)o)
26f ofooofoofofooo *(f*(o))
27t foooxfooxfoxfooox *(f*(o)x)
28f foooxfooxofoxfooox *(f*(o)x)
29t foooxfooxfxfooox *(f*(o)x)
30t ofxoofxo *(*(of*(o)x)o)
31t ofoooxoofxo *(*(of*(o)x)o)
32t ofoooxoofxoofoooxoofxo *(*(of*(o)x)o)
33t ofoooxoofxoofoooxoofxoo *(*(of*(o)x)o)
34f ofoooxoofxoofoooxoofxofo *(*(of*(o)x)o)
35t ofoooxoofxoofoooxoofxooofxofxo *(*(of*(o)x)o)
36t aac *(@(a))a@(c)
37t ac *(@(a))a@(c)
38f c *(@(a))a@(c)
39t aaac *(@(a))a@(c)
40f baaac *(@(a))a@(c)
41t abcd ?@(a|b)*@(c)d
42t abcd @(ab|a*@(b))*(c)d
43t acd @(ab|a*(b))*(c)d
44t abbcd @(ab|a*(b))*(c)d
45t effgz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
46t efgz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
47t egz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
48t egzefffgzbcdij *(b+(c)d|e*(f)g?|?(h)i@(j|k))
49f egz @(b+(c)d|e+(f)g?|?(h)i@(j|k))
50t ofoofo *(of+(o))
51t oxfoxoxfox *(oxf+(ox))
52f oxfoxfox *(oxf+(ox))
53t ofoofo *(of+(o)|f)
54# The following is supposed to match only as fo+ofo+ofo
55t foofoofo @(foo|f|fo)*(f|of+(o))
56t oofooofo *(of|oof+(o))
57t fffooofoooooffoofffooofff *(*(f)*(o))
58# The following tests backtracking in alternation matches
59t fofoofoofofoo *(fo|foo)
60# Exclusion
61t foo !(x)
62t foo !(x)*
63f foo !(foo)
64t foo !(foo)*
65t foobar !(foo)
66t foobar !(foo)*
67t moo.cow !(*.*).!(*.*)
68f mad.moo.cow !(*.*).!(*.*)
69f mucca.pazza mu!(*(c))?.pa!(*(z))?
70t fff !(f)
71t fff *(!(f))
72t fff +(!(f))
73t ooo !(f)
74t ooo *(!(f))
75t ooo +(!(f))
76t foo !(f)
77t foo *(!(f))
78t foo +(!(f))
79f f !(f)
80f f *(!(f))
81f f +(!(f))
82t foot @(!(z*)|*x)
83f zoot @(!(z*)|*x)
84t foox @(!(z*)|*x)
85t zoox @(!(z*)|*x)
86t foo *(!(foo))
87f foob !(foo)b*
88t foobb !(foo)b*
89EOT
90echo "$failed tests failed."