#!/usr/local/bin/zsh -f setopt extendedglob badpattern unsetopt kshglob failed=0 while read res str pat; do [[ $res = '#' ]] && continue [[ $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 <33 t 633 <-1000>33 t 633 <1->33 t 633 <->33 # An open top end of a range will match any integer, even # if not representable in the internal integer type. t 12345678901234567890123456789012345678901234567890123456789012345678901234567890foo <42->foo # Approximate matching t READ.ME (#ia1)readme f READ..ME (#ia1)readme t README (#ia1)readm t READM (#ia1)readme t README (#ia1)eadme t EADME (#ia1)readme t READEM (#ia1)readme f ADME (#ia1)readme f README (#ia1)read t bob (#a1)[b][b] f bob (#a1)[b][b]a t bob (#a1)[b]o[b]a f bob (#a1)[c]o[b] t abcd (#a2)XbcX t abcd (#a2)ad t ad (#a2)abcd t abcd (#a2)bd t bd (#a2)abcd t badc (#a2)abcd # This next one is a little tricky: a[d]bc[] = a[]bc[d] t adbc (#a2)abcd f dcba (#a2)abcd # the next one is [d][cb][a] = [a][bc][d] with a transposition t dcba (#a3)abcd t aabaXaaabY (#a1)(a#b)#Y t aabaXaaabY (#a1)(a#b)(a#b)Y t aaXaaaaabY (#a1)(a#b)(a#b)Y t aaaXaaabY (#a1)(a##b)##Y t aaaXbaabY (#a1)(a##b)##Y f read.me (#ia1)README~READ.ME t read.me (#ia1)README~READ_ME f read.me (#ia1)README~(#a1)READ_ME t test *((#s)|/)test((#e)|/)* t test/path *((#s)|/)test((#e)|/)* t path/test *((#s)|/)test((#e)|/)* t path/test/ohyes *((#s)|/)test((#e)|/)* f atest *((#s)|/)test((#e)|/)* f testy *((#s)|/)test((#e)|/)* f testy/path *((#s)|/)test((#e)|/)* f path/atest *((#s)|/)test((#e)|/)* f atest/path *((#s)|/)test((#e)|/)* f path/testy *((#s)|/)test((#e)|/)* f path/testy/ohyes *((#s)|/)test((#e)|/)* f path/atest/ohyes *((#s)|/)test((#e)|/)* t XabcdabcY X(ab|c|d)(#c5)Y t XabcdabcY X(ab|c|d)(#c1,5)Y t XabcdabcY X(ab|c|d)(#c5,8)Y t XabcdabcY X(ab|c|d)(#c4,)Y f XabcdabcY X(ab|c|d)(#c6,)Y f XabcdabcY X(ab|c|d)(#c1,4)Y t ZX Z(|)(#c1)X t froofroo (fro(#c2))(#c2) f froofroofroo (fro(#c2))(#c2) f froofro (fro(#c2))(#c2) t ax ?(#c1,2)x t ax ?(#c1,)x t ax ?(#c0,1)x f ax ?(#c0,0)x f ax ?(#c2,)x t aa a(#c1,2)a t aa a(#c1,)a t aa a(#c0,1)a f aa a(#c0,0)a f aa a(#c2,)a t test.zsh *.?(#c1)sh t test.bash *.?(#c2)sh t test.bash *.?(#c1,2)sh t test.bash *.?(#c1,)sh t test.zsh *.?(#c1,)sh EOT print "$failed tests failed."