#!/usr/local/bin/zsh -f
setopt extendedglob badpattern
unsetopt kshglob
failed=0
while read res str pat; do
[[ $res = ' [[ $str = ${~pat} ]]
ts=$?
[[ $1 = -q ]] || print "$ts: [[ $str = $pat ]]"
if [[ ( $ts -gt 0 && $res = t) || ($ts -eq 0 && $res = f) ]]; then
print "Test failed: [[ $str = $pat ]]"
(( failed++ ))
fi
done <<EOT
t foo~ foo~
t foo~ (foo~)
t foo~ (foo~|)
t foo.c *.c~boo*
f foo.c *.c~boo*~foo*
t fofo (fot ffo (fot foooofo (fot foooofof (fot fooofoofofooo (fof foooofof (fof xfoooofof (fof foooofofx (fot ofxoofxo ((ofof ofooofoofofooo (fot foooxfooxfoxfooox (fof foooxfooxofoxfooox (fot foooxfooxfxfooox (fot ofxoofxo ((ofot ofoooxoofxo ((ofot ofoooxoofxoofoooxoofxo ((ofot ofoooxoofxoofoooxoofxoo ((ofof ofoooxoofxoofoooxoofxofo ((ofot ofoooxoofxoofoooxoofxooofxofxo ((ofot aac ((a))t ac ((a))f c ((a))t aaac ((a))f baaac ((a))t abcd ?(a|b)ct abcd (ab|abt acd (ab|abt abbcd (ab|abt effgz (bct efgz (bct egz (bct egzefffgzbcdij (bcf egz (bct ofoofo (ofot oxfoxoxfox (oxf(ox)f oxfoxfox (oxf(ox)t ofoofo (ofot foofoofo (foo|f|fo)(f|ofot oofooofo (of|oofot fffooofoooooffoofffooofff (ff fffooofoooooffoofffooofffx (ft fofoofoofofoo (fo|foo)t foo ((^x))
t foo ((^x)*)
f foo ((^foo))
t foo ((^foo)*)
t foobar ((^foo))
t foobar ((^foo)*)
f foot z*~*x
t zoot z*~*x
f foox z*~*x
f zoox z*~*x
t moo.cow (*~*.*).(*~*.*)
f mad.moo.cow (*~*.*).(*~*.*)
t moo.cow (^*.*).(^*.*)
f sane.moo.cow (^*.*).(^*.*)
f mucca.pazza mu(^cf _foo~ _(|*[^~])
t fff ((^f))
t fff ((^f)t fff ((^f)t ooo ((^f))
t ooo ((^f)t ooo ((^f)t foo ((^f))
t foo ((^f)t foo ((^f)f f ((^f))
f f ((^f)f f ((^f)t foot (^z*|*x)
f zoot (^z*|*x)
t foox (^z*|*x)
t zoox (^z*|*x)
t foo (^foo)f foob (^foo)b*
t foobb (^foo)b*
f foob (*~foo)b*
t foobb (*~foo)b*
f zsh ^z*
t a%1X [[:alpha:][:punct:]]f a%1 [[:alpha:][:punct:]]t [: [[:]t :] []:]t :] [:]]t [ [[]
t ] []]
t [] [^]]]
t fooxx (f fooxx (t FOOXX (f fooxx (t fooXx (t fooxx ((f fooxx ((f BAR (bar|(t FOO (bar|(t Modules (t fooGRUD (f FOOGRUD (t readme (t readme (t 633 <1-1000>33
t 633 <-1000>33
t 633 <1->33
t 633 <->33
t 12345678901234567890123456789012345678901234567890123456789012345678901234567890foo <42->foo
t READ.ME (f READ..ME (t README (t READM (t README (t EADME (t READEM (f ADME (f README (t bob (f bob (t bob (f bob (t abcd (t abcd (t ad (t abcd (t bd (t badc (t adbc (f dcba (t dcba (t aabaXaaabY (t aabaXaaabY (t aaXaaaaabY (t aaaXaaabY (t aaaXbaabY (f read.me (t read.me (f read.me (t test *((t test/path *((t path/test *((t path/test/ohyes *((f atest *((f testy *((f testy/path *((f path/atest *((f atest/path *((f path/testy *((f path/testy/ohyes *((f path/atest/ohyes *((t XabcdabcY X(ab|c|d)(t XabcdabcY X(ab|c|d)(t XabcdabcY X(ab|c|d)(t XabcdabcY X(ab|c|d)(f XabcdabcY X(ab|c|d)(f XabcdabcY X(ab|c|d)(t ZX Z(|)(t froofroo (fro(f froofroofroo (fro(f froofro (fro(t ax ?(t ax ?(t ax ?(f ax ?(f ax ?(t aa a(t aa a(t aa a(f aa a(f aa a(t test.zsh *.?(t test.bash *.?(t test.bash *.?(t test.bash *.?(t test.zsh *.?(EOT
print "$failed tests failed."