text: function alpha(e,n){return e>n?1:-1}var tap=require("tap"),globalBefore=Object.keys(global),mm=require("../"),files=["a","b","c","d","abc","abd","abe","bb","bcd","ca","cb","dd","de","bdir/","bdir/cfile"],next=files.concat(["a-b","aXb",".x",".y"]),patterns=["http://www.bashcookbook.com/bashinfo/source/bash-1.14.7/tests/glob-test",["a*",["a","abc","abd","abe"]],["X*",["X*"],{nonull:!0}],["X*",[]],["\\*",["\\*"],{nonull:!0}],["\\**",["\\**"],{nonull:!0}],["\\*\\*",["\\*\\*"],{nonull:!0}],["b*/",["bdir/"]],["c*",["c","ca","cb"]],["**",files],["\\.\\./*/",["\\.\\./*/"],{nonull:!0}],["s/\\..*//",["s/\\..*//"],{nonull:!0}],"legendary larry crashes bashes",["/^root:/{s/^[^:]*:[^:]*:([^:]*).*$/\\1/",["/^root:/{s/^[^:]*:[^:]*:([^:]*).*$/\\1/"],{nonull:!0}],["/^root:/{s/^[^:]*:[^:]*:([^:]*).*$//",["/^root:/{s/^[^:]*:[^:]*:([^:]*).*$//"],{nonull:!0}],"character classes",["[a-c]b*",["abc","abd","abe","bb","cb"]],["[a-y]*[^c]",["abd","abe","bb","bcd","bdir/","ca","cb","dd","de"]],["a*[^c]",["abd","abe"]],function(){files.push("a-b","aXb")},["a[X-]b",["a-b","aXb"]],function(){files.push(".x",".y")},["[^a-c]*",["d","dd","de"]],function(){files.push("a*b/","a*b/ooo")},["a\\*b/*",["a*b/ooo"]],["a\\*?/*",["a*b/ooo"]],["*\\\\!*",[],{"null":!0},["echo !7"]],["*\\!*",["echo !7"],null,["echo !7"]],["*.\\*",["r.*"],null,["r.*"]],["a[b]c",["abc"]],["a[\\b]c",["abc"]],["a?c",["abc"]],["a\\*c",[],{"null":!0},["abc"]],["",[""],{"null":!0},[""]],"http://www.opensource.apple.com/source/bash/bash-23/bash/tests/glob-test",function(){files.push("man/","man/man1/","man/man1/bash.1")},["*/man*/bash.*",["man/man1/bash.1"]],["man/man1/bash.1",["man/man1/bash.1"]],["a***c",["abc"],null,["abc"]],["a*****?c",["abc"],null,["abc"]],["?*****??",["abc"],null,["abc"]],["*****??",["abc"],null,["abc"]],["?*****?c",["abc"],null,["abc"]],["?***?****c",["abc"],null,["abc"]],["?***?****?",["abc"],null,["abc"]],["?***?****",["abc"],null,["abc"]],["*******c",["abc"],null,["abc"]],["*******?",["abc"],null,["abc"]],["a*cd**?**??k",["abcdecdhjk"],null,["abcdecdhjk"]],["a**?**cd**?**??k",["abcdecdhjk"],null,["abcdecdhjk"]],["a**?**cd**?**??k***",["abcdecdhjk"],null,["abcdecdhjk"]],["a**?**cd**?**??***k",["abcdecdhjk"],null,["abcdecdhjk"]],["a**?**cd**?**??***k**",["abcdecdhjk"],null,["abcdecdhjk"]],["a****c**?**??*****",["abcdecdhjk"],null,["abcdecdhjk"]],["[-abc]",["-"],null,["-"]],["[abc-]",["-"],null,["-"]],["\\",["\\"],null,["\\"]],["[\\\\]",["\\"],null,["\\"]],["[[]",["["],null,["["]],["[",["["],null,["["]],["[*",["[abc"],null,["[abc"]],"a right bracket shall lose its special meaning and\nrepresent itself in a bracket expression if it occurs\nfirst in the list.  -- POSIX.2 2.8.3.2",["[]]",["]"],null,["]"]],["[]-]",["]"],null,["]"]],["[a-z]",["p"],null,["p"]],["??**********?****?",[],{"null":!0},["abc"]],["??**********?****c",[],{"null":!0},["abc"]],["?************c****?****",[],{"null":!0},["abc"]],["*c*?**",[],{"null":!0},["abc"]],["a*****c*?**",[],{"null":!0},["abc"]],["a********???*******",[],{"null":!0},["abc"]],["[]",[],{"null":!0},["a"]],["[abc",[],{"null":!0},["["]],"nocase tests",["XYZ",["xYz"],{nocase:!0,"null":!0},["xYz","ABC","IjK"]],["ab*",["ABC"],{nocase:!0,"null":!0},["xYz","ABC","IjK"]],["[ia]?[ck]",["ABC","IjK"],{nocase:!0,"null":!0},["xYz","ABC","IjK"]],"onestar/twostar",["{/*,*}",[],{"null":!0},["/asdf/asdf/asdf"]],["{/?,*}",["/a","bb"],{"null":!0},["/a","/b/b","/a/b/c","bb"]],"dots should not match unless requested",["**",["a/b"],{},["a/b","a/.d",".a/.d"]],function(){files=["a/./b","a/../b","a/c/b","a/.d/b"]},["a/*/b",["a/c/b","a/.d/b"],{dot:!0}],["a/.*/b",["a/./b","a/../b","a/.d/b"],{dot:!0}],["a/*/b",["a/c/b"],{dot:!1}],["a/.*/b",["a/./b","a/../b","a/.d/b"],{dot:!1}],["**",["a/b","a/.d",".a/.d"],{dot:!0},[".a/.d","a/.d","a/b"]],"paren sets cannot contain slashes",["*(a/b)",["*(a/b)"],{nonull:!0},["a/b"]],["*(a|{b),c)}",["a","ab","ac"],{},["a","ab","ac","ad"]],["[!a*",["[!ab"],{},["[!ab","[ab"]],["[#a*",["[#ab"],{},["[#ab","[ab"]],["+(a|*\\|c\\\\|d\\\\\\|e\\\\\\\\|f\\\\\\\\\\|g",["+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g"],{},["+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g","a","b\\c"]],function(){files=["a","b","c","d","ab","ac","ad","bc","cb","bc,d","c,db","c,d","d)","(b|c","*(b|c","b|c","b|cc","cb|c","x(a|b|c)","x(a|c)","(a|b|c)","(a|c)"]},["*(a|{b,c})",["a","b","c","ab","ac"]],["{a,*(b|c,d)}",["a","(b|c","*(b|c","d)"]],["{a,*(b|{c,d})}",["a","b","bc","cb","c","d"]],["*(a|{b|c,c})",["a","b","c","ab","ac","bc","cb"]],["*(a|{b|c,c})",["x(a|b|c)","x(a|c)","(a|b|c)","(a|c)"],{noext:!0}],["a?b",["x/y/acb","acb/"],{matchBase:!0},["x/y/acb","acb/","acb/d/e","x/y/acb/d"]],["#*",["#a","#b"],{nocomment:!0},["#a","#b","c#d"]],"negation tests",function(){files=["d","e","!ab","!abc","a!b","\\!a"]},["!a*",["\\!a","d","e","!ab","!abc"]],["!a*",["!ab","!abc"],{nonegate:!0}],["!!a*",["a!b"]],["!\\!a*",["a!b","d","e","\\!a"]],function(){files=["foo.js","foo.bar","foo.js.js","blar.js","foo.","boo.js.boo"]},["*.!(js)",["foo.bar","foo.","boo.js.boo"]],function(){files=["a/b/.x/c","a/b/.x/c/d","a/b/.x/c/d/e","a/b/.x","a/b/.x/","a/.x/b",".x",".x/",".x/a",".x/a/b","a/.x/b/.x/c",".x/.x"]},["**/.x/**",[".x/",".x/a",".x/a/b","a/.x/b","a/b/.x/","a/b/.x/c","a/b/.x/c/d","a/b/.x/c/d/e"]]],regexps=["/^(?:(?=.)a[^/]*?)$/","/^(?:(?=.)X[^/]*?)$/","/^(?:(?=.)X[^/]*?)$/","/^(?:\\*)$/","/^(?:(?=.)\\*[^/]*?)$/","/^(?:\\*\\*)$/","/^(?:(?=.)b[^/]*?\\/)$/","/^(?:(?=.)c[^/]*?)$/","/^(?:(?:(?!(?:\\/|^)\\.).)*?)$/","/^(?:\\.\\.\\/(?!\\.)(?=.)[^/]*?\\/)$/","/^(?:s\\/(?=.)\\.\\.[^/]*?\\/)$/","/^(?:\\/\\^root:\\/\\{s\\/(?=.)\\^[^:][^/]*?:[^:][^/]*?:\\([^:]\\)[^/]*?\\.[^/]*?\\$\\/1\\/)$/","/^(?:\\/\\^root:\\/\\{s\\/(?=.)\\^[^:][^/]*?:[^:][^/]*?:\\([^:]\\)[^/]*?\\.[^/]*?\\$\\/\\/)$/","/^(?:(?!\\.)(?=.)[a-c]b[^/]*?)$/","/^(?:(?!\\.)(?=.)[a-y][^/]*?[^c])$/","/^(?:(?=.)a[^/]*?[^c])$/","/^(?:(?=.)a[X-]b)$/","/^(?:(?!\\.)(?=.)[^a-c][^/]*?)$/","/^(?:a\\*b\\/(?!\\.)(?=.)[^/]*?)$/","/^(?:(?=.)a\\*[^/]\\/(?!\\.)(?=.)[^/]*?)$/","/^(?:(?!\\.)(?=.)[^/]*?\\\\\\![^/]*?)$/","/^(?:(?!\\.)(?=.)[^/]*?\\![^/]*?)$/","/^(?:(?!\\.)(?=.)[^/]*?\\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?=.)[^/]*?\\(a\\|c\\))$/","/^(?:(?=.)a[^/]b)$/","/^(?:(?=.)#[^/]*?)$/","/^(?!^(?:(?=.)a[^/]*?)$).*$/","/^(?:(?=.)\\!a[^/]*?)$/","/^(?:(?=.)a[^/]*?)$/","/^(?!^(?:(?=.)\\!a[^/]*?)$).*$/","/^(?:(?!\\.)(?=.)[^/]*?\\.(?:(?!js)[^/]*?))$/","/^(?:(?:(?!(?:\\/|^)\\.).)*?\\/\\.x\\/(?:(?!(?:\\/|^)\\.).)*?)$/"],re=0;tap.test("basic tests",function(e){var n=Date.now();patterns.forEach(function(n){if("function"==typeof n)return n();if("string"==typeof n)return e.comment(n);var t=n[0],r=n[1].sort(alpha),a=n[2]||{},i=n[3]||files,s=n[4]||{},o=new mm.Minimatch(t,a),l=o.makeRe(),u=regexps[re++];s.re=String(l)||JSON.stringify(l),s.files=JSON.stringify(i),s.pattern=t,s.set=o.set,s.negated=o.negate;var c=mm.match(i,t,a);c.sort(alpha),e.equivalent(c,r,JSON.stringify(t)+" "+JSON.stringify(r),s),e.equal(s.re,u,s)}),e.comment("time="+(Date.now()-n)+"ms"),e.end()}),tap.test("global leak test",function(e){var n=Object.keys(global);e.equivalent(n,globalBefore,"no new globals, please"),e.end()});