├── tsconfig.json ├── .npmignore ├── .editorconfig ├── .gitignore ├── src ├── types.ts ├── merge │ └── index.ts ├── normalize │ ├── index.ts │ └── grammar.ts ├── parse │ ├── index.ts │ ├── utils.ts │ └── grammar.ts ├── compile │ └── index.ts ├── index.ts ├── utils.ts └── range.ts ├── package.json ├── tasks └── benchmark.js ├── license ├── readme.md └── test └── index.js /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tsex/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | resources 2 | src 3 | tasks 4 | test 5 | 6 | .editorconfig 7 | tsconfig.json 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.err 3 | *.log 4 | ._* 5 | .cache 6 | .fseventsd 7 | .DocumentRevisions* 8 | .DS_Store 9 | .TemporaryItems 10 | .Trashes 11 | Thumbs.db 12 | 13 | dist 14 | node_modules 15 | package-lock.json 16 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | 2 | /* MAIN */ 3 | 4 | type Node = { 5 | partial?: boolean, 6 | regex?: RegExp, 7 | children: Node[] 8 | }; 9 | 10 | type Options = { 11 | partial?: boolean 12 | }; 13 | 14 | /* EXPORT */ 15 | 16 | export type {Node, Options}; 17 | -------------------------------------------------------------------------------- /src/merge/index.ts: -------------------------------------------------------------------------------- 1 | 2 | /* MAIN */ 3 | 4 | const merge = ( res: RegExp[] ): RegExp => { 5 | 6 | const source = res.map ( re => re.source ).join ( '|' ) || '$^'; 7 | const flags = res[0]?.flags; 8 | 9 | return new RegExp ( source, flags ); 10 | 11 | }; 12 | 13 | /* EXPORT */ 14 | 15 | export default merge; 16 | -------------------------------------------------------------------------------- /src/normalize/index.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import {parse} from 'grammex'; 5 | import Grammar from './grammar'; 6 | 7 | /* MAIN */ 8 | 9 | const normalize = ( glob: string ): string => { 10 | 11 | return parse ( glob, Grammar, { memoization: false } ).join ( '' ); 12 | 13 | }; 14 | 15 | /* EXPORT */ 16 | 17 | export default normalize; 18 | -------------------------------------------------------------------------------- /src/parse/index.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import type {Node} from '../types'; 5 | import {parse} from 'grammex'; 6 | import Grammar from './grammar'; 7 | 8 | /* MAIN */ 9 | 10 | const _parse = ( glob: string ): Node => { 11 | 12 | return parse ( glob, Grammar, { memoization: false } )[0]; 13 | 14 | }; 15 | 16 | /* EXPORT */ 17 | 18 | export default _parse; 19 | -------------------------------------------------------------------------------- /src/compile/index.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import type {Node, Options} from '../types'; 5 | import graphmatch from 'graphmatch'; 6 | 7 | /* MAIN */ 8 | 9 | const compile = ( node: Node, options?: Options ): RegExp => { 10 | 11 | const re = graphmatch.compile ( node, options ); 12 | const source = `${re.source.slice ( 0, -1 )}[\\\\/]?$`; // With optional trailing slash 13 | const flags = re.flags; 14 | 15 | return new RegExp ( source, flags ); 16 | 17 | }; 18 | 19 | /* EXPORT */ 20 | 21 | export default compile; 22 | -------------------------------------------------------------------------------- /src/normalize/grammar.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import {match, or, star} from 'grammex'; 5 | import {identity} from '../utils'; 6 | 7 | /* MAIN */ 8 | 9 | const Escaped = match ( /\\./, identity ); 10 | const Passthrough = match ( /./, identity ); 11 | 12 | const StarStarStar = match ( /\*\*\*+/, '*' ); 13 | 14 | const StarStarNoLeft = match ( /([^/{[(!])\*\*/, ( _, $1 ) => `${$1}*` ); 15 | const StarStarNoRight = match ( /(^|.)\*\*(?=[^*/)\]}])/, ( _, $1 ) => `${$1}*` ); 16 | 17 | const Grammar = star ( or ([ Escaped, StarStarStar, StarStarNoLeft, StarStarNoRight, Passthrough ]) ); 18 | 19 | /* EXPORT */ 20 | 21 | export default Grammar; 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zeptomatch", 3 | "repository": "github:fabiospampinato/zeptomatch", 4 | "description": "An absurdly small glob matcher that packs a punch.", 5 | "license": "MIT", 6 | "version": "2.1.0", 7 | "type": "module", 8 | "main": "dist/index.js", 9 | "exports": "./dist/index.js", 10 | "types": "./dist/index.d.ts", 11 | "scripts": { 12 | "benchmark": "tsex benchmark", 13 | "benchmark:watch": "tsex benchmark --watch", 14 | "clean": "tsex clean", 15 | "compile": "tsex compile", 16 | "compile:watch": "tsex compile --watch", 17 | "test": "tsex test", 18 | "test:watch": "tsex test --watch", 19 | "prepublishOnly": "tsex prepare" 20 | }, 21 | "keywords": [ 22 | "tiny", 23 | "glob", 24 | "match", 25 | "matcher", 26 | "partial" 27 | ], 28 | "dependencies": { 29 | "grammex": "^3.1.11", 30 | "graphmatch": "^1.1.0" 31 | }, 32 | "devDependencies": { 33 | "benchloop": "^2.1.1", 34 | "fava": "^0.3.5", 35 | "tsex": "^4.0.2", 36 | "typescript": "^5.9.3" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tasks/benchmark.js: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import benchmark from 'benchloop'; 5 | import zeptomatch from '../dist/index.js'; 6 | 7 | /* HELPERS */ 8 | 9 | const GLOB = 'foo/**/{bar/baz,qux}/*.js'; 10 | const GLOBS = ['foo/**/bar/baz/*.js', 'foo/**/qux/*.js']; 11 | const OPTIONS_PARTIAL = { partial: true }; 12 | 13 | /* MAIN */ 14 | 15 | benchmark.config ({ 16 | iterations: 1_000_000 17 | }); 18 | 19 | benchmark.group ( 'match', () => { 20 | 21 | for ( const [name, glob] of [['single', GLOB], ['double', GLOBS]] ) { 22 | 23 | benchmark.group ( name, () => { 24 | 25 | benchmark ({ 26 | name: 'full', 27 | fn: () => { 28 | zeptomatch ( glob, 'foo/bar/baz/file.js' ); 29 | zeptomatch ( glob, 'foo/bar/baz/file.js_' ); 30 | } 31 | }); 32 | 33 | benchmark ({ 34 | name: 'partial', 35 | fn: () => { 36 | zeptomatch ( glob, 'foo/bar/baz', OPTIONS_PARTIAL ); 37 | zeptomatch ( glob, 'foo/bar/baz_', OPTIONS_PARTIAL ); 38 | } 39 | }); 40 | 41 | }); 42 | 43 | } 44 | 45 | }); 46 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2023-present Fabio Spampinato 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the "Software"), 7 | to deal in the Software without restriction, including without limitation 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import type {Options} from './types'; 5 | import compile from './compile'; 6 | import merge from './merge'; 7 | import normalize from './normalize'; 8 | import parse from './parse'; 9 | import {isString, memoizeByObject, memoizeByPrimitive} from './utils'; 10 | 11 | /* MAIN */ 12 | 13 | const zeptomatch = ( glob: string | string[], path: string, options?: Options ): boolean => { 14 | 15 | return zeptomatch.compile ( glob, options ).test ( path ); 16 | 17 | }; 18 | 19 | /* UTILITIES */ 20 | 21 | zeptomatch.compile = (() => { 22 | 23 | const compileGlob = memoizeByPrimitive (( glob: string, options?: Options ): RegExp => { 24 | return compile ( parse ( normalize ( glob ) ), options ); 25 | }); 26 | 27 | const compileGlobs = memoizeByObject (( globs: string[], options?: Options ): RegExp => { 28 | return merge ( globs.map ( glob => compileGlob ( glob, options ) ) ); 29 | }); 30 | 31 | return ( glob: string | string[], options?: Options ): RegExp => { 32 | if ( isString ( glob ) ) { 33 | return compileGlob ( glob, options ); 34 | } else { 35 | return compileGlobs ( glob, options ); 36 | } 37 | }; 38 | 39 | })(); 40 | 41 | /* EXPORT */ 42 | 43 | export default zeptomatch; 44 | export type {Options}; 45 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import type {Options} from './types'; 5 | 6 | /* MAIN */ 7 | 8 | const identity = ( value: T ): T => { 9 | 10 | return value; 11 | 12 | }; 13 | 14 | const isString = ( value: unknown ): value is string => { 15 | 16 | return typeof value === 'string'; 17 | 18 | }; 19 | 20 | const memoizeByObject = ( fn: ( globs: string[], options?: Options ) => T ) => { 21 | 22 | const cacheFull = new WeakMap(); 23 | const cachePartial = new WeakMap(); 24 | 25 | return ( globs: string[], options?: Options ): T => { 26 | 27 | const cache = options?.partial ? cachePartial : cacheFull; 28 | const cached = cache.get ( globs ); 29 | 30 | if ( cached !== undefined ) return cached; 31 | 32 | const result = fn ( globs, options ); 33 | 34 | cache.set ( globs, result ); 35 | 36 | return result; 37 | 38 | }; 39 | 40 | }; 41 | 42 | const memoizeByPrimitive = ( fn: ( glob: string, options?: Options ) => T ) => { 43 | 44 | const cacheFull: Record = {}; 45 | const cachePartial: Record = {}; 46 | 47 | return ( glob: string, options?: Options ): T => { 48 | 49 | const cache = options?.partial ? cachePartial : cacheFull; 50 | 51 | return cache[glob] ??= fn ( glob, options ); 52 | 53 | }; 54 | 55 | }; 56 | 57 | /* EXPORT */ 58 | 59 | export {identity, isString, memoizeByObject, memoizeByPrimitive}; 60 | -------------------------------------------------------------------------------- /src/parse/utils.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import type {Node} from '../types'; 5 | 6 | /* MAIN */ 7 | 8 | const regex = ( source: string ): Node => { // A single node, never matching partially 9 | const regex = new RegExp ( source, 's' ); 10 | return { partial: false, regex, children: [] }; 11 | }; 12 | 13 | const alternation = ( children: Node[] ): Node => { // A list of nodes 14 | return { children }; 15 | }; 16 | 17 | const sequence = (() => { // A tree of nodes 18 | 19 | const pushToLeaves = ( parent: Node, child: Node, handled: Set ): void => { 20 | if ( handled.has ( parent ) ) return; 21 | handled.add ( parent ); 22 | 23 | const {children} = parent; 24 | if ( !children.length ) { // Leaf node 25 | children.push ( child ); 26 | } else { // Internal node 27 | for ( let i = 0, l = children.length; i < l; i++ ) { 28 | pushToLeaves ( children[i], child, handled ); 29 | } 30 | } 31 | }; 32 | 33 | return ( nodes: Node[] ): Node => { 34 | if ( !nodes.length ) { // no-op 35 | return alternation ( [] ); 36 | } 37 | 38 | for ( let i = nodes.length - 1; i >= 1; i-- ) { 39 | const handled = new Set (); 40 | const parent = nodes[i - 1]; 41 | const child = nodes[i]; 42 | pushToLeaves ( parent, child, handled ); 43 | } 44 | return nodes[0]; 45 | }; 46 | 47 | })(); 48 | 49 | const slash = (): Node => { // A single node matching a slash, potentially matching partially 50 | const regex = new RegExp ( '[\\\\/]', 's' ); 51 | return { regex, children: [] }; 52 | }; 53 | 54 | /* EXPORT */ 55 | 56 | export {regex, alternation, sequence, slash}; 57 | -------------------------------------------------------------------------------- /src/range.ts: -------------------------------------------------------------------------------- 1 | 2 | /* CONSTANTS */ 3 | 4 | const ALPHABET = 'abcdefghijklmnopqrstuvwxyz'; 5 | 6 | /* HELPERS */ 7 | 8 | const int2alpha = ( int: number ): string => { 9 | 10 | let alpha = ''; 11 | 12 | while ( int > 0 ) { 13 | 14 | const reminder = ( int - 1 ) % 26; 15 | 16 | alpha = ALPHABET[reminder] + alpha; 17 | 18 | int = Math.floor ( ( int - 1 ) / 26 ); 19 | 20 | } 21 | 22 | return alpha; 23 | 24 | }; 25 | 26 | const alpha2int = ( str: string ): number => { 27 | 28 | let int = 0; 29 | 30 | for ( let i = 0, l = str.length; i < l; i++ ) { 31 | 32 | int = ( int * 26 ) + ALPHABET.indexOf ( str[i] ) + 1; 33 | 34 | } 35 | 36 | return int; 37 | 38 | }; 39 | 40 | /* MAIN */ 41 | 42 | // This isn't the most efficient way to do it, but it's extremely compact and we don't care about the performance of creating the ranges too much 43 | 44 | const makeRangeInt = ( start: number, end: number ): number[] => { 45 | 46 | if ( end < start ) return makeRangeInt ( end, start ); 47 | 48 | const range: number[] = []; 49 | 50 | while ( start <= end ) { 51 | 52 | range.push ( start++ ); 53 | 54 | } 55 | 56 | return range; 57 | 58 | }; 59 | 60 | const makeRangePaddedInt = ( start: number, end: number, paddingLength: number ): string[] => { 61 | 62 | return makeRangeInt ( start, end ).map ( int => String ( int ).padStart ( paddingLength, '0' ) ); 63 | 64 | }; 65 | 66 | const makeRangeAlpha = ( start: string, end: string ): string[] => { 67 | 68 | return makeRangeInt ( alpha2int ( start ), alpha2int ( end ) ).map ( int2alpha ); 69 | 70 | }; 71 | 72 | /* EXPORT */ 73 | 74 | export {makeRangeInt, makeRangePaddedInt, makeRangeAlpha}; 75 | -------------------------------------------------------------------------------- /src/parse/grammar.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import {match, and, lazy, optional, plus, or, star} from 'grammex'; 5 | import {makeRangeAlpha, makeRangePaddedInt} from '../range'; 6 | import {identity} from '../utils'; 7 | import zeptomatch from '..'; 8 | import {regex, alternation, sequence, slash} from './utils'; 9 | 10 | /* MAIN */ 11 | 12 | const Escaped = match ( /\\./, regex ); 13 | const Escape = match ( /[$.*+?^(){}[\]\|]/, char => regex ( `\\${char}` ) ); 14 | const Slash = match ( /[\\\/]/, slash ); 15 | const Passthrough = match ( /[^$.*+?^(){}[\]\|\\\/]+/, regex ); 16 | 17 | const NegationOdd = match ( /^(?:!!)*!(.*)$/, ( _, glob ) => regex ( `(?!^${zeptomatch.compile ( glob ).source}$).*?` ) ); 18 | const NegationEven = match ( /^(!!)+/ ); 19 | const Negation = or ([ NegationOdd, NegationEven ]); 20 | 21 | const StarStarBetween = match ( /\/(\*\*\/)+/, () => alternation ([ sequence ([ slash (), regex ( '.+?' ), slash () ]), slash () ]) ); 22 | const StarStarStart = match ( /^(\*\*\/)+/, () => alternation ([ regex ( '^' ), sequence ([ regex ( '.*?' ), slash () ]) ]) ); 23 | const StarStarEnd = match ( /\/(\*\*)$/, () => alternation ([ sequence ([ slash (), regex ( '.*?' ) ]), regex ( '$' ) ]) ); 24 | const StarStarNone = match ( /\*\*/, () => regex ( '.*?' ) ); 25 | const StarStar = or ([ StarStarBetween, StarStarStart, StarStarEnd, StarStarNone ]); 26 | 27 | const StarDouble = match ( /\*\/(?!\*\*\/|\*$)/, () => sequence ([ regex ( '[^\\\\/]*?' ), slash () ]) ); 28 | const StarSingle = match ( /\*/, () => regex ( '[^\\\\/]*' ) ); 29 | const Star = or ([ StarDouble, StarSingle ]); 30 | 31 | const Question = match ( '?', () => regex ( '[^\\\\/]' ) ); 32 | 33 | const ClassOpen = match ( '[', identity ); 34 | const ClassClose = match ( ']', identity ); 35 | const ClassNegation = match ( /[!^]/, '^\\\\/' ); 36 | const ClassRange = match ( /[a-z]-[a-z]|[0-9]-[0-9]/i, identity ); 37 | const ClassEscaped = match ( /\\./, identity ); 38 | const ClassEscape = match ( /[$.*+?^(){}[\|]/, char => `\\${char}` ); 39 | const ClassSlash = match ( /[\\\/]/, '\\\\/' ); 40 | const ClassPassthrough = match ( /[^$.*+?^(){}[\]\|\\\/]+/, identity ); 41 | const ClassValue = or ([ ClassEscaped, ClassEscape, ClassSlash, ClassRange, ClassPassthrough ]); 42 | const Class = and ( [ClassOpen, optional ( ClassNegation ), star ( ClassValue ), ClassClose], _ => regex ( _.join ( '' ) ) ); 43 | 44 | const RangeOpen = match ( '{', '(?:' ); 45 | const RangeClose = match ( '}', ')' ); 46 | const RangeNumeric = match ( /(\d+)\.\.(\d+)/, ( _, $1, $2 ) => makeRangePaddedInt ( +$1, +$2, Math.min ( $1.length, $2.length ) ).join ( '|' ) ); 47 | const RangeAlphaLower = match ( /([a-z]+)\.\.([a-z]+)/, ( _, $1, $2 ) => makeRangeAlpha ( $1, $2 ).join ( '|' ) ); 48 | const RangeAlphaUpper = match ( /([A-Z]+)\.\.([A-Z]+)/, ( _, $1, $2 ) => makeRangeAlpha ( $1.toLowerCase (), $2.toLowerCase () ).join ( '|' ).toUpperCase () ); 49 | const RangeValue = or ([ RangeNumeric, RangeAlphaLower, RangeAlphaUpper ]); 50 | const Range = and ( [RangeOpen, RangeValue, RangeClose], _ => regex ( _.join ( '' ) ) ); 51 | 52 | const BracesOpen = match ( '{' ); 53 | const BracesClose = match ( '}' ); 54 | const BracesComma = match ( ',' ); 55 | const BracesEscaped = match ( /\\./, regex ); 56 | const BracesEscape = match ( /[$.*+?^(){[\]\|]/, char => regex ( `\\${char}` ) ); 57 | const BracesSlash = match ( /[\\\/]/, slash ); 58 | const BracesPassthrough = match ( /[^$.*+?^(){}[\]\|\\\/,]+/, regex ); 59 | const BracesNested = lazy ( () => Braces ); 60 | const BracesEmptyValue = match ( '', () => regex ( '(?:)' ) ); 61 | const BracesFullValue = plus ( or ([ StarStar, Star, Question, Class, Range, BracesNested, BracesEscaped, BracesEscape, BracesSlash, BracesPassthrough ] ), sequence ); 62 | const BracesValue = or ([ BracesFullValue, BracesEmptyValue ]); 63 | const Braces = and ( [BracesOpen, optional ( and ([ BracesValue, star ( and ([ BracesComma, BracesValue ]) ) ]) ), BracesClose], alternation ); 64 | 65 | const Grammar = star ( or ([ Negation, StarStar, Star, Question, Class, Range, Braces, Escaped, Escape, Slash, Passthrough ]), sequence ); 66 | 67 | /* EXPORT */ 68 | 69 | export default Grammar; 70 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Zeptomatch 2 | 3 | An absurdly small glob matcher that packs a punch. 4 | 5 | ## Overview 6 | 7 | The following syntax is supported: 8 | 9 | | Syntax | Description | 10 | | ----------- | --------------------------------------------------------------------------------------------------------------------------------------- | 11 | | `*` | Matches any character, except for the path separator, zero or more times. | 12 | | `**` | Matches any character zero or more times. If it doesn't span the entire length of a path segment it's interpreted as a `*` instead. | 13 | | `?` | Matches any character, except for the path separator, one time. | 14 | | `\` | Matches the character after it in the glob literally. This is the escape operator. | 15 | | `[abc]` | Matches any of the characters in the class one time. | 16 | | `[a-z]` | Matches any of the characters in the range in the class one time. | 17 | | `[^abc]` | Matches any character, except for the characters in the class, and the path separator, one time. Aliased as `[!abc]` also. | 18 | | `[^a-z]` | Matches any character, except for the characters in the range in the class, and the path separator, one time. Aliased as `[!a-z]` also. | 19 | | `{foo,bar}` | Matches any of the alternations, which are separated by a comma, inside the braces. | 20 | | `{01..99}` | Matches any of the numbers in the expanded range. Padding is supported and opt-in. | 21 | | `{a..zz}` | Matches any of the strings in the expanded range. Upper-cased ranges are supported and opt-in. | 22 | | `!glob` | Matches anything except the provided glob. Negations can only be used at the start of the glob. | 23 | | `!!glob` | Matches the provided glob. Negations can only be used at the start of the glob. | 24 | 25 | Additional features and details: 26 | 27 | - Zeptomatch works pretty similarly to [`picomatch`](https://github.com/micromatch/picomatch), since 1000+ of its tests are being used by this library. 28 | - Zeptomatch is opinionated, there are barely any options, which helps with keeping it tiny and manageable. 29 | - Zeptomatch is automatically memoized, the only ways to use it are always the most optimized ones available. 30 | - Zeptomatch automatically normalizes path separators, both `/` and `\` mean the same thing. 31 | - Zeptomatch supports compiling a glob to a standalone regular expression. 32 | - Zeptomatch supports compiling multiple globs to a standalone regular expression too. 33 | - Zeptomatch doesn't do anything special for file names starting with a dot. 34 | - Zeptomatch supports nesting braces indefinitely. 35 | - Zeptomatch supports matching globs partially too, with path segment-level awareness! 36 | 37 | Limitations: 38 | 39 | - POSIX classes (e.g. `[:alnum:]`) are not supported. Implementing them is out of scope for a "zepto"-level library. 40 | - Extglobs (e.g. `?(foo)`) are not supported. They are too complicated and quirky too support here. 41 | 42 | ## Install 43 | 44 | ```sh 45 | npm install zeptomatch 46 | ``` 47 | 48 | ## Usage 49 | 50 | ```ts 51 | import zeptomatch from 'zeptomatch'; 52 | 53 | // Let's check if a glob matches a path, fully 54 | 55 | zeptomatch ( '*.js', 'abcd' ); // => false 56 | zeptomatch ( '*.js', 'a.js' ); // => true 57 | zeptomatch ( '*.js', 'a.md' ); // => false 58 | zeptomatch ( '*.js', 'a/b.js' ); // => false 59 | 60 | // Let's check if a glob matches a path, partially 61 | // Matching partially is very useful for performance when traversing the filesystem 62 | // It's important to not match the glob partially anymore once you have the full path available though! 63 | 64 | zeptomatch ( 'foo/bar/*.js', 'foo', { partial: true } ); // => true 65 | zeptomatch ( 'foo/bar/*.js', 'foo/bar', { partial: true } ); // => true 66 | zeptomatch ( 'foo/bar/*.js', 'foo/bar/_', { partial: true } ); // => false, as no additional path segment could ever make this match 67 | zeptomatch ( 'foo/bar/*.js', 'foo/bar/file.js' ); // => true, remember to not match the full path partially 68 | 69 | // Let's compile a glob to a regular expression that matches fully 70 | 71 | const fullRe = zeptomatch.compile ( 'src/*.js' ); // => /^(?:src[\\/][^\\/]*\.js)[\\/]?$/s 72 | 73 | // Let's compile a glob to a regular expression that matches partially 74 | 75 | const partialRe = zeptomatch.compile ( 'src/*.js', { partial: true } ); // => /^(?:src(?:$|[\\/](?:$|[^\\/]*\.js)))[\\/]?$/s 76 | ``` 77 | 78 | ## Utilities 79 | 80 | The following additional utilities are available, as standalone packages: 81 | 82 | - [`zeptomatch-escape`](https://github.com/fabiospampinato/zeptomatch-escape): A little utility for escaping globs before passing them to zeptomatch. 83 | - [`zeptomatch-explode`](https://github.com/fabiospampinato/zeptomatch-explode): A little utility for exploding a zeptomatch-flavored glob into its dynamic and static parts. 84 | - [`zeptomatch-is-static`](https://github.com/fabiospampinato/zeptomatch-is-static): A little utility for checking if a glob is fully static. 85 | - [`zeptomatch-unescape`](https://github.com/fabiospampinato/zeptomatch-unescape): A little utility for removing escape sequences from a glob. 86 | 87 | ## License 88 | 89 | MIT © Fabio Spampinato 90 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import {describe} from 'fava'; 5 | import zeptomatch from '../dist/index.js'; 6 | 7 | /* HELPERS */ 8 | 9 | const isMatch = zeptomatch; 10 | const compile = zeptomatch.compile; 11 | 12 | /* MAIN */ 13 | 14 | describe ( 'Zeptomatch', it => { 15 | 16 | // Native tests 17 | 18 | it ( 'native', t => { 19 | 20 | t.true ( isMatch ( [], '' ) ); 21 | t.true ( !isMatch ( [], 'a' ) ); 22 | 23 | t.true ( isMatch ( ['*.md', '*.js'], 'foo.md' ) ); 24 | t.true ( isMatch ( ['*.md', '*.js'], 'foo.js' ) ); 25 | t.true ( !isMatch ( ['*.md', '*.js'], 'foo.txt' ) ); 26 | 27 | t.true ( !isMatch ( '*/**foo', 'foo/bar/foo' ) ); 28 | t.true ( isMatch ( '*/**foo', 'foo/barfoo' ) ); 29 | 30 | t.true ( !isMatch ( '*/**foo', 'foo\\bar\\foo' ) ); 31 | t.true ( isMatch ( '*/**foo', 'foo\\barfoo' ) ); 32 | 33 | t.true ( !isMatch ( '*.js', 'abcd' ) ); 34 | t.true ( isMatch ( '*.js', 'a.js' ) ); 35 | t.true ( !isMatch ( '*.js', 'a.md' ) ); 36 | t.true ( !isMatch ( '*.js', 'a/b.js' ) ); 37 | 38 | t.true ( isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'aaa' ) ); 39 | t.true ( isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'aab' ) ); 40 | t.true ( isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'aba' ) ); 41 | t.true ( isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'abb' ) ); 42 | t.true ( isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'baa' ) ); 43 | t.true ( isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'bab' ) ); 44 | t.true ( isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'bba' ) ); 45 | t.true ( isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'bbb' ) ); 46 | t.true ( !isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'a' ) ); 47 | t.true ( !isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'b' ) ); 48 | t.true ( !isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'aa' ) ); 49 | t.true ( !isMatch ( '{a{a{a,b},b{a,b}},b{a{a,b},b{a,b}}}', 'bb' ) ); 50 | 51 | }); 52 | 53 | it ( 'native_grammar_full', t => { 54 | 55 | // Escaped 56 | t.true ( isMatch ( '\\n', '\n' ) ); 57 | t.true ( isMatch ( '\\(', '(' ) ); 58 | // Escape 59 | t.true ( isMatch ( '(', '(' ) ); 60 | // Slash 61 | t.true ( isMatch ( '/', '/' ) ); 62 | t.true ( isMatch ( '/', '\\' ) ); 63 | t.true ( isMatch ( '\\', '/' ) ); 64 | t.true ( isMatch ( '\\', '\\' ) ); 65 | // Passthrough 66 | t.true ( isMatch ( 'abc', 'abc' ) ); 67 | 68 | // Negation 69 | t.true ( isMatch ( '!foo', 'bar' ) ); 70 | t.false ( isMatch ( '!foo', 'foo' ) ); 71 | t.true ( isMatch ( '!!foo', 'foo' ) ); 72 | t.false ( isMatch ( '!!!foo', 'foo' ) ); 73 | 74 | // StarStar 75 | t.true ( isMatch ( '**', 'foo/bar' ) ); 76 | 77 | // Star 78 | t.true ( isMatch ( '*', 'abc' ) ); 79 | t.true ( isMatch ( '*.js', 'abc.js' ) ); 80 | 81 | // Question 82 | t.true ( isMatch ( '?', 'a' ) ); 83 | t.false ( isMatch ( '?', '' ) ); 84 | t.false ( isMatch ( '?', '/' ) ); 85 | t.false ( isMatch ( '?', '\\' ) ); 86 | 87 | // Class 88 | t.true ( isMatch ( '[a-z]', 'a' ) ); 89 | t.true ( isMatch ( '[A-Z]', 'A' ) ); 90 | t.true ( isMatch ( '[a-zA-Z]', 'a' ) ); 91 | t.true ( isMatch ( '[a-zA-Z]', 'A' ) ); 92 | t.true ( isMatch ( '[0-9]', '0' ) ); 93 | t.true ( isMatch ( '[a-z][0-9]', 'a0' ) ); 94 | t.true ( isMatch ( '[^a-z][^0-9]', '0a' ) ); 95 | t.false ( isMatch ( '[a-z]', 'A' ) ); 96 | t.false ( isMatch ( '[A-Z]', 'a' ) ); 97 | 98 | // Range 99 | t.true ( isMatch ( '{1..9}', '1' ) ); 100 | t.true ( isMatch ( '{a..z}', 'a' ) ); 101 | t.true ( isMatch ( '{A..Z}', 'A' ) ); 102 | t.true ( isMatch ( '{A..Z}{1..9}', 'A1' ) ); 103 | t.true ( isMatch ( '{1..9}{A..Z}', '1A' ) ); 104 | t.false ( isMatch ( '{a..z}', 'A' ) ); 105 | t.false ( isMatch ( '{A..Z}', 'a' ) ); 106 | 107 | // Braces 108 | t.true ( isMatch ( '{foo,bar}', 'foo' ) ); 109 | t.true ( isMatch ( '{foo,bar}', 'bar' ) ); 110 | t.true ( isMatch ( '{}', '' ) ); 111 | t.true ( isMatch ( '{,}', '' ) ); 112 | t.true ( isMatch ( '{,foo}', '' ) ); 113 | t.true ( isMatch ( '{,foo}', 'foo' ) ); 114 | t.false ( isMatch ( '{foo,bar}', '' ) ); 115 | t.false ( isMatch ( '{foo,bar}', 'foobar' ) ); 116 | t.true ( isMatch ( '{foo/bar,baz/qux}', 'foo/bar' ) ); 117 | t.true ( isMatch ( '{foo/bar,baz/qux}', 'baz/qux' ) ); 118 | t.false ( isMatch ( '{foo/bar,baz/qux}', 'foo/qux' ) ); 119 | t.false ( isMatch ( '{foo/bar,baz/qux}', 'baz/bar' ) ); 120 | 121 | }); 122 | 123 | it ( 'native_grammar_partial', t => { 124 | 125 | // Escaped 126 | t.false ( isMatch ( '\\n\\n', '\n', { partial: true } ) ); 127 | t.false ( isMatch ( '\\(\\(', '(', { partial: true } ) ); 128 | // Escape 129 | t.false ( isMatch ( '((', '(', { partial: true } ) ); 130 | // Slash 131 | t.true ( isMatch ( '//', '/', { partial: true } ) ); 132 | t.true ( isMatch ( '//', '\\', { partial: true } ) ); 133 | // Passthrough 134 | t.false ( isMatch ( 'abc', '', { partial: true } ) ); 135 | t.false ( isMatch ( 'abc', 'a', { partial: true } ) ); 136 | t.false ( isMatch ( 'abc', 'ab', { partial: true } ) ); 137 | t.true ( isMatch ( 'abc', 'abc', { partial: true } ) ); 138 | 139 | // Negation 140 | t.true ( isMatch ( '!foo/bar', 'bar', { partial: true } ) ); 141 | t.false ( isMatch ( '!foo', 'foo', { partial: true } ) ); 142 | t.true ( isMatch ( '!!foo', 'foo', { partial: true } ) ); 143 | t.false ( isMatch ( '!!!foo', 'foo', { partial: true } ) ); 144 | 145 | // StarStar 146 | t.true ( isMatch ( '**', '', { partial: true } ) ); 147 | t.true ( isMatch ( '**', 'foo', { partial: true } ) ); 148 | t.true ( isMatch ( '**', 'foo/', { partial: true } ) ); 149 | t.true ( isMatch ( '**', 'foo/bar', { partial: true } ) ); 150 | t.true ( isMatch ( '**', 'foo/bar/', { partial: true } ) ); 151 | 152 | // Star 153 | t.true ( isMatch ( '*', '', { partial: true } ) ); 154 | t.true ( isMatch ( '*', 'abc', { partial: true } ) ); 155 | t.true ( isMatch ( '*.js', 'abc.js', { partial: true } ) ); 156 | t.false ( isMatch ( '*.js', 'abc', { partial: true } ) ); 157 | 158 | // Question 159 | t.false ( isMatch ( 'a?b', 'a', { partial: true } ) ); 160 | t.false ( isMatch ( 'a?b', 'ab', { partial: true } ) ); 161 | t.true ( isMatch ( 'a?b', 'abb', { partial: true } ) ); 162 | t.false ( isMatch ( 'a?b', 'abc', { partial: true } ) ); 163 | 164 | // Class 165 | t.false ( isMatch ( '[a-z][a-z]', 'a', { partial: true } ) ); 166 | t.false ( isMatch ( '[A-Z][A-Z]', 'A', { partial: true } ) ); 167 | t.false ( isMatch ( '[a-zA-Z][a-zA-Z]', 'a', { partial: true } ) ); 168 | t.false ( isMatch ( '[a-zA-Z][a-zA-Z]', 'A', { partial: true } ) ); 169 | t.false ( isMatch ( '[0-9][0-9]', '0', { partial: true } ) ); 170 | t.false ( isMatch ( '[a-z][0-9][a-z][0-9]', 'a0', { partial: true } ) ); 171 | t.false ( isMatch ( '[^a-z][^0-9][^a-z][^0-9]', '0a', { partial: true } ) ); 172 | 173 | // Range 174 | t.false ( isMatch ( '{1..9}{1..9}', '1', { partial: true } ) ); 175 | t.false ( isMatch ( '{a..z}{a..z}', 'a', { partial: true } ) ); 176 | t.false ( isMatch ( '{A..Z}{A..Z}', 'A', { partial: true } ) ); 177 | t.false ( isMatch ( '{A..Z}{1..9}{A..Z}{1..9}', 'A1', { partial: true } ) ); 178 | t.false ( isMatch ( '{1..9}{A..Z}{1..9}{A..Z}', '1A', { partial: true } ) ); 179 | 180 | // Braces 181 | t.false ( isMatch ( '{foo,bar}baz', 'foo', { partial: true } ) ); 182 | t.false ( isMatch ( '{foo,bar}baz', 'bar', { partial: true } ) ); 183 | t.false ( isMatch ( '{foo,bar}baz', 'f', { partial: true } ) ); 184 | t.false ( isMatch ( '{foo,bar}baz', 'b', { partial: true } ) ); 185 | 186 | t.true ( isMatch ( '{foo/bar,baz/qux}', 'foo', { partial: true } ) ); 187 | t.true ( isMatch ( '{foo/bar,baz/qux}', 'foo/', { partial: true } ) ); 188 | t.true ( isMatch ( '{foo/bar,baz/qux}', 'baz', { partial: true } ) ); 189 | t.true ( isMatch ( '{foo/bar,baz/qux}', 'baz/', { partial: true } ) ); 190 | t.false ( isMatch ( '{foo/bar,baz/qux}', 'foo/qux', { partial: true } ) ); 191 | t.false ( isMatch ( '{foo/bar,baz/qux}', 'baz/bar', { partial: true } ) ); 192 | 193 | }); 194 | 195 | it ( 'native_memoization', t => { 196 | 197 | const glob = 'foo'; 198 | const re1 = compile ( glob ); 199 | const re2 = compile ( glob ); 200 | const re3 = compile ( glob, { partial: true } ); 201 | const re4 = compile ( glob, { partial: true } ); 202 | t.is ( re1, re2 ); 203 | t.is ( re3, re4 ); 204 | t.not ( re1, re3 ); 205 | 206 | const globs = ['foo', 'bar']; 207 | const re5 = compile ( globs ); 208 | const re6 = compile ( globs ); 209 | const re7 = compile ( globs, { partial: true } ); 210 | const re8 = compile ( globs, { partial: true } ); 211 | t.is ( re5, re6 ); 212 | t.is ( re7, re8 ); 213 | t.not ( re5, re8 ); 214 | 215 | }); 216 | 217 | it ( 'native_partial_0', t => { 218 | 219 | const glob = '/*/b/x/y/z'; 220 | 221 | t.true ( isMatch ( glob, '/a/b', { partial: true } ) ); 222 | t.false ( isMatch ( glob, '/a/b' ) ); 223 | t.false ( isMatch ( glob, '/a/b/c', { partial: true } ) ); 224 | 225 | }); 226 | 227 | it ( 'native_partial_1', t => { 228 | 229 | const glob = 'foo/**/{bar/baz,qux}/*.js'; 230 | 231 | // Partial 232 | 233 | t.false ( isMatch ( glob, '', { partial: true } ) ); 234 | t.true ( isMatch ( glob, 'foo', { partial: true } ) ); 235 | t.true ( isMatch ( glob, 'foo/', { partial: true } ) ); 236 | 237 | t.true ( isMatch ( glob, 'foo/bar', { partial: true } ) ); 238 | t.true ( isMatch ( glob, 'foo/bar/', { partial: true } ) ); 239 | t.true ( isMatch ( glob, 'foo/qux', { partial: true } ) ); 240 | t.true ( isMatch ( glob, 'foo/qux/', { partial: true } ) ); 241 | 242 | t.true ( isMatch ( glob, 'foo/bar_', { partial: true } ) ); 243 | t.true ( isMatch ( glob, 'foo/bar_', { partial: true } ) ); 244 | t.true ( isMatch ( glob, 'foo/bar/_', { partial: true } ) ); 245 | t.true ( isMatch ( glob, 'foo/qux_', { partial: true } ) ); 246 | t.true ( isMatch ( glob, 'foo/qux/_', { partial: true } ) ); 247 | 248 | // Full 249 | 250 | t.false ( isMatch ( glob, '' ) ); 251 | t.false ( isMatch ( glob, 'foo' ) ); 252 | t.false ( isMatch ( glob, 'foo/' ) ); 253 | 254 | t.false ( isMatch ( glob, 'foo/bar' ) ); 255 | t.false ( isMatch ( glob, 'foo/bar/' ) ); 256 | t.false ( isMatch ( glob, 'foo/qux' ) ); 257 | t.false ( isMatch ( glob, 'foo/qux/' ) ); 258 | 259 | t.false ( isMatch ( glob, 'foo/bar_' ) ); 260 | t.false ( isMatch ( glob, 'foo/bar/_' ) ); 261 | t.false ( isMatch ( glob, 'foo/qux_' ) ); 262 | t.false ( isMatch ( glob, 'foo/qux/_' ) ); 263 | 264 | }); 265 | 266 | it ( 'native_partial_2', t => { 267 | 268 | const glob = 'foo/*/{bar/baz,qux}/*.js'; 269 | 270 | // Partial 271 | 272 | t.false ( isMatch ( glob, '', { partial: true } ) ); 273 | t.true ( isMatch ( glob, 'foo', { partial: true } ) ); 274 | t.true ( isMatch ( glob, 'foo/', { partial: true } ) ); 275 | 276 | t.true ( isMatch ( glob, 'foo/bar', { partial: true } ) ); 277 | t.true ( isMatch ( glob, 'foo/bar/', { partial: true } ) ); 278 | t.true ( isMatch ( glob, 'foo/qux', { partial: true } ) ); 279 | t.true ( isMatch ( glob, 'foo/qux/', { partial: true } ) ); 280 | 281 | t.true ( isMatch ( glob, 'foo/bar_', { partial: true } ) ); 282 | t.true ( isMatch ( glob, 'foo/bar_', { partial: true } ) ); 283 | t.false ( isMatch ( glob, 'foo/bar/_', { partial: true } ) ); 284 | t.true ( isMatch ( glob, 'foo/qux_', { partial: true } ) ); 285 | t.false ( isMatch ( glob, 'foo/qux/_', { partial: true } ) ); 286 | 287 | // Full 288 | 289 | t.false ( isMatch ( glob, '' ) ); 290 | t.false ( isMatch ( glob, 'foo' ) ); 291 | t.false ( isMatch ( glob, 'foo/' ) ); 292 | 293 | t.false ( isMatch ( glob, 'foo/bar' ) ); 294 | t.false ( isMatch ( glob, 'foo/bar/' ) ); 295 | t.false ( isMatch ( glob, 'foo/qux' ) ); 296 | t.false ( isMatch ( glob, 'foo/qux/' ) ); 297 | 298 | t.false ( isMatch ( glob, 'foo/bar_' ) ); 299 | t.false ( isMatch ( glob, 'foo/bar/_' ) ); 300 | t.false ( isMatch ( glob, 'foo/qux_' ) ); 301 | t.false ( isMatch ( glob, 'foo/qux/_' ) ); 302 | 303 | }); 304 | 305 | it ( 'native_partial_3', t => { 306 | 307 | const glob = 'foo/{bar/baz,qux}/*.js'; 308 | 309 | // Partial 310 | 311 | t.false ( isMatch ( glob, '', { partial: true } ) ); 312 | t.true ( isMatch ( glob, 'foo', { partial: true } ) ); 313 | t.true ( isMatch ( glob, 'foo/', { partial: true } ) ); 314 | 315 | t.true ( isMatch ( glob, 'foo/bar', { partial: true } ) ); 316 | t.true ( isMatch ( glob, 'foo/bar/', { partial: true } ) ); 317 | t.true ( isMatch ( glob, 'foo/qux', { partial: true } ) ); 318 | t.true ( isMatch ( glob, 'foo/qux/', { partial: true } ) ); 319 | 320 | t.false ( isMatch ( glob, 'foo/bar_', { partial: true } ) ); 321 | t.false ( isMatch ( glob, 'foo/bar_', { partial: true } ) ); 322 | t.false ( isMatch ( glob, 'foo/bar/_', { partial: true } ) ); 323 | t.false ( isMatch ( glob, 'foo/bar/baz/_', { partial: true } ) ); 324 | t.false ( isMatch ( glob, 'foo/qux_', { partial: true } ) ); 325 | t.false ( isMatch ( glob, 'foo/qux/_', { partial: true } ) ); 326 | 327 | // Full 328 | 329 | t.false ( isMatch ( glob, '' ) ); 330 | t.false ( isMatch ( glob, 'foo' ) ); 331 | t.false ( isMatch ( glob, 'foo/' ) ); 332 | 333 | t.false ( isMatch ( glob, 'foo/bar' ) ); 334 | t.false ( isMatch ( glob, 'foo/bar/' ) ); 335 | t.false ( isMatch ( glob, 'foo/qux' ) ); 336 | t.false ( isMatch ( glob, 'foo/qux/' ) ); 337 | 338 | t.false ( isMatch ( glob, 'foo/bar_' ) ); 339 | t.false ( isMatch ( glob, 'foo/bar/_' ) ); 340 | t.false ( isMatch ( glob, 'foo/qux_' ) ); 341 | t.false ( isMatch ( glob, 'foo/qux/_' ) ); 342 | 343 | }); 344 | 345 | it ( 'native_range', t => { 346 | 347 | // Numeric 348 | 349 | t.true ( isMatch ( '{1..20}', '1' ) ); 350 | t.true ( isMatch ( '{1..20}', '10' ) ); 351 | t.true ( isMatch ( '{1..20}', '20' ) ); 352 | 353 | t.true ( isMatch ( '{20..1}', '1' ) ); 354 | t.true ( isMatch ( '{20..1}', '10' ) ); 355 | t.true ( isMatch ( '{20..1}', '20' ) ); 356 | 357 | t.true ( !isMatch ( '{1..20}', '0' ) ); 358 | t.true ( !isMatch ( '{1..20}', '22' ) ); 359 | 360 | t.true ( !isMatch ( '{20..1}', '0' ) ); 361 | t.true ( !isMatch ( '{20..1}', '22' ) ); 362 | 363 | // Numeric padded 364 | 365 | t.true ( isMatch ( '{01..20}', '01' ) ); 366 | t.true ( isMatch ( '{01..20}', '10' ) ); 367 | t.true ( isMatch ( '{01..20}', '20' ) ); 368 | 369 | t.true ( isMatch ( '{20..01}', '01' ) ); 370 | t.true ( isMatch ( '{20..01}', '10' ) ); 371 | t.true ( isMatch ( '{20..01}', '20' ) ); 372 | 373 | t.true ( !isMatch ( '{01..20}', '00' ) ); 374 | t.true ( !isMatch ( '{01..20}', '1' ) ); 375 | t.true ( !isMatch ( '{01..20}', '22' ) ); 376 | 377 | t.true ( !isMatch ( '{20..01}', '00' ) ); 378 | t.true ( !isMatch ( '{20..01}', '1' ) ); 379 | t.true ( !isMatch ( '{20..01}', '22' ) ); 380 | 381 | // Alphabetic 382 | 383 | t.true ( isMatch ( '{a..zz}', 'a' ) ); 384 | t.true ( isMatch ( '{a..zz}', 'bb' ) ); 385 | t.true ( isMatch ( '{a..zz}', 'za' ) ); 386 | 387 | t.true ( isMatch ( '{zz..a}', 'a' ) ); 388 | t.true ( isMatch ( '{zz..a}', 'bb' ) ); 389 | t.true ( isMatch ( '{zz..a}', 'za' ) ); 390 | 391 | t.true ( !isMatch ( '{a..zz}', 'aaa' ) ); 392 | t.true ( !isMatch ( '{a..zz}', 'A' ) ); 393 | 394 | t.true ( !isMatch ( '{zz..a}', 'aaa' ) ); 395 | t.true ( !isMatch ( '{zz..a}', 'A' ) ); 396 | 397 | // Alphabetic uppercase 398 | 399 | t.true ( isMatch ( '{A..ZZ}', 'A' ) ); 400 | t.true ( isMatch ( '{A..ZZ}', 'BB' ) ); 401 | t.true ( isMatch ( '{A..ZZ}', 'ZA' ) ); 402 | 403 | t.true ( isMatch ( '{ZZ..A}', 'A' ) ); 404 | t.true ( isMatch ( '{ZZ..A}', 'BB' ) ); 405 | t.true ( isMatch ( '{ZZ..A}', 'ZA' ) ); 406 | 407 | t.true ( !isMatch ( '{A..ZZ}', 'AAA' ) ); 408 | t.true ( !isMatch ( '{A..ZZ}', 'a' ) ); 409 | 410 | t.true ( !isMatch ( '{ZZ..A}', 'AAA' ) ); 411 | t.true ( !isMatch ( '{ZZ..A}', 'a' ) ); 412 | 413 | }); 414 | 415 | it ( 'native_slashes_normalization', t => { 416 | 417 | t.true ( isMatch ( 'foo/*.json', 'foo\\bar.json' ) ); 418 | t.true ( isMatch ( 'foo/*.json', 'foo/bar.json' ) ); 419 | 420 | }); 421 | 422 | it ( 'native_trailing slash', t => { 423 | 424 | t.true ( isMatch ( 'foo', 'foo' ) ); 425 | t.true ( isMatch ( 'foo', 'foo/' ) ); 426 | 427 | t.false ( isMatch ( 'foo/', 'foo' ) ); 428 | t.true ( isMatch ( 'foo/', 'foo/' ) ); 429 | t.true ( isMatch ( 'foo/', 'foo//' ) ); 430 | 431 | }); 432 | 433 | // Tests adapted from "picomatch": https://github.com/micromatch/picomatch 434 | // License: https://github.com/micromatch/picomatch/blob/master/LICENSE 435 | 436 | it ( 'multiple_patterns', t => { 437 | 438 | t.true ( isMatch ( ['.', 'foo'], '.' ) ); 439 | t.true ( isMatch ( ['a', 'foo'], 'a' ) ); 440 | t.true ( isMatch ( ['*', 'foo', 'bar'], 'ab' ) ); 441 | t.true ( isMatch ( ['*b', 'foo', 'bar'], 'ab' ) ); 442 | t.true ( !isMatch ( ['./*', 'foo', 'bar'], 'ab' ) ); 443 | t.true ( isMatch ( ['a*', 'foo', 'bar'], 'ab' ) ); 444 | t.true ( isMatch ( ['ab', 'foo'], 'ab' ) ); 445 | 446 | t.true ( !isMatch ( ['/a', 'foo'], '/ab' ) ); 447 | t.true ( !isMatch ( ['?/?', 'foo', 'bar'], '/ab' ) ); 448 | t.true ( !isMatch ( ['a/*', 'foo', 'bar'], '/ab' ) ); 449 | t.true ( !isMatch ( ['a/b', 'foo'], 'a/b/c' ) ); 450 | t.true ( !isMatch ( ['*/*', 'foo', 'bar'], 'ab' ) ); 451 | t.true ( !isMatch ( ['/a', 'foo', 'bar'], 'ab' ) ); 452 | t.true ( !isMatch ( ['a', 'foo'], 'ab' ) ); 453 | t.true ( !isMatch ( ['b', 'foo'], 'ab' ) ); 454 | t.true ( !isMatch ( ['c', 'foo', 'bar'], 'ab' ) ); 455 | t.true ( !isMatch ( ['ab', 'foo'], 'abcd' ) ); 456 | t.true ( !isMatch ( ['bc', 'foo'], 'abcd' ) ); 457 | t.true ( !isMatch ( ['c', 'foo'], 'abcd' ) ); 458 | t.true ( !isMatch ( ['cd', 'foo'], 'abcd' ) ); 459 | t.true ( !isMatch ( ['d', 'foo'], 'abcd' ) ); 460 | t.true ( !isMatch ( ['f', 'foo', 'bar'], 'abcd' ) ); 461 | t.true ( !isMatch ( ['/*', 'foo', 'bar'], 'ef' ) ); 462 | 463 | }); 464 | 465 | it ( 'file_extensions', t => { 466 | 467 | t.true ( isMatch ( '*.md', '.c.md' ) ); 468 | t.true ( !isMatch ( '.c.', '.c.md' ) ); 469 | t.true ( !isMatch ( '.md', '.c.md' ) ); 470 | t.true ( isMatch ( '*.md', '.md' ) ); 471 | t.true ( !isMatch ( '.m', '.md' ) ); 472 | t.true ( !isMatch ( '*.md', 'a/b/c.md' ) ); 473 | t.true ( !isMatch ( '.md', 'a/b/c.md' ) ); 474 | t.true ( !isMatch ( 'a/*.md', 'a/b/c.md' ) ); 475 | t.true ( !isMatch ( '*.md', 'a/b/c/c.md' ) ); 476 | t.true ( !isMatch ( 'c.js', 'a/b/c/c.md' ) ); 477 | t.true ( isMatch ( '.*.md', '.c.md' ) ); 478 | t.true ( isMatch ( '.md', '.md' ) ); 479 | t.true ( isMatch ( 'a/**/*.*', 'a/b/c.js' ) ); 480 | t.true ( isMatch ( '**/*.md', 'a/b/c.md' ) ); 481 | t.true ( isMatch ( 'a/*/*.md', 'a/b/c.md' ) ); 482 | t.true ( isMatch ( '*.md', 'c.md' ) ); 483 | 484 | }); 485 | 486 | it ( 'dot_files', t => { 487 | 488 | t.true ( !isMatch ( '.*.md', 'a/b/c/.xyz.md' ) ); 489 | t.true ( isMatch ( '*.md', '.c.md' ) ); 490 | t.true ( isMatch ( '.*', '.c.md' ) ); 491 | t.true ( isMatch ( '**/*.md', 'a/b/c/.xyz.md' ) ); 492 | t.true ( isMatch ( '**/.*.md', 'a/b/c/.xyz.md' ) ); 493 | t.true ( isMatch ( 'a/b/c/*.md', 'a/b/c/.xyz.md' ) ); 494 | t.true ( isMatch ( 'a/b/c/.*.md', 'a/b/c/.xyz.md' ) ); 495 | 496 | }); 497 | 498 | it ( 'matching', t => { 499 | 500 | t.true ( isMatch ( 'a+b/src/*.js', 'a+b/src/glimini.js' ) ); 501 | t.true ( isMatch ( '+b/src/*.js', '+b/src/glimini.js' ) ); 502 | t.true ( isMatch ( 'coffee+/src/*.js', 'coffee+/src/glimini.js' ) ); 503 | t.true ( isMatch ( 'coffee+/src/*', 'coffee+/src/glimini.js' ) ); 504 | 505 | t.true ( isMatch ( '.', '.' ) ); 506 | t.true ( isMatch ( '/a', '/a' ) ); 507 | t.true ( !isMatch ( '/a', '/ab' ) ); 508 | t.true ( isMatch ( 'a', 'a' ) ); 509 | t.true ( !isMatch ( '/a', 'ab' ) ); 510 | t.true ( !isMatch ( 'a', 'ab' ) ); 511 | t.true ( isMatch ( 'ab', 'ab' ) ); 512 | t.true ( !isMatch ( 'cd', 'abcd' ) ); 513 | t.true ( !isMatch ( 'bc', 'abcd' ) ); 514 | t.true ( !isMatch ( 'ab', 'abcd' ) ); 515 | 516 | t.true ( isMatch ( 'a.b', 'a.b' ) ); 517 | t.true ( isMatch ( '*.b', 'a.b' ) ); 518 | t.true ( isMatch ( 'a.*', 'a.b' ) ); 519 | t.true ( isMatch ( '*.*', 'a.b' ) ); 520 | t.true ( isMatch ( 'a*.c*', 'a-b.c-d' ) ); 521 | t.true ( isMatch ( '*b.*d', 'a-b.c-d' ) ); 522 | t.true ( isMatch ( '*.*', 'a-b.c-d' ) ); 523 | t.true ( isMatch ( '*.*-*', 'a-b.c-d' ) ); 524 | t.true ( isMatch ( '*-*.*-*', 'a-b.c-d' ) ); 525 | t.true ( isMatch ( '*.c-*', 'a-b.c-d' ) ); 526 | t.true ( isMatch ( '*.*-d', 'a-b.c-d' ) ); 527 | t.true ( isMatch ( 'a-*.*-d', 'a-b.c-d' ) ); 528 | t.true ( isMatch ( '*-b.c-*', 'a-b.c-d' ) ); 529 | t.true ( isMatch ( '*-b*c-*', 'a-b.c-d' ) ); 530 | t.true ( !isMatch ( '*-bc-*', 'a-b.c-d' ) ); 531 | 532 | t.true ( !isMatch ( './*/', '/ab' ) ); 533 | t.true ( !isMatch ( '*', '/ef' ) ); 534 | t.true ( !isMatch ( './*/', 'ab' ) ); 535 | t.true ( !isMatch ( '/*', 'ef' ) ); 536 | t.true ( isMatch ( '/*', '/ab' ) ); 537 | t.true ( isMatch ( '/*', '/cd' ) ); 538 | t.true ( isMatch ( '*', 'ab' ) ); 539 | t.true ( !isMatch ( './*', 'ab' ) ); 540 | t.true ( isMatch ( 'ab', 'ab' ) ); 541 | t.true ( !isMatch ( './*/', 'ab/' ) ); 542 | 543 | t.true ( !isMatch ( '*.js', 'a/b/c/z.js' ) ); 544 | t.true ( !isMatch ( '*.js', 'a/b/z.js' ) ); 545 | t.true ( !isMatch ( '*.js', 'a/z.js' ) ); 546 | t.true ( isMatch ( '*.js', 'z.js' ) ); 547 | 548 | t.true ( isMatch ( 'z*.js', 'z.js' ) ); 549 | t.true ( isMatch ( 'a/z*.js', 'a/z.js' ) ); 550 | t.true ( isMatch ( '*/z*.js', 'a/z.js' ) ); 551 | 552 | t.true ( isMatch ( '**/*.js', 'a/b/c/z.js' ) ); 553 | t.true ( isMatch ( '**/*.js', 'a/b/z.js' ) ); 554 | t.true ( isMatch ( '**/*.js', 'a/z.js' ) ); 555 | t.true ( isMatch ( 'a/b/**/*.js', 'a/b/c/d/e/z.js' ) ); 556 | t.true ( isMatch ( 'a/b/**/*.js', 'a/b/c/d/z.js' ) ); 557 | t.true ( isMatch ( 'a/b/c/**/*.js', 'a/b/c/z.js' ) ); 558 | t.true ( isMatch ( 'a/b/c**/*.js', 'a/b/c/z.js' ) ); 559 | t.true ( isMatch ( 'a/b/**/*.js', 'a/b/c/z.js' ) ); 560 | t.true ( isMatch ( 'a/b/**/*.js', 'a/b/z.js' ) ); 561 | 562 | t.true ( !isMatch ( 'a/b/**/*.js', 'a/z.js' ) ); 563 | t.true ( !isMatch ( 'a/b/**/*.js', 'z.js' ) ); 564 | 565 | t.true ( isMatch ( 'z*', 'z.js' ) ); 566 | t.true ( isMatch ( '**/z*', 'z.js' ) ); 567 | t.true ( isMatch ( '**/z*.js', 'z.js' ) ); 568 | t.true ( isMatch ( '**/*.js', 'z.js' ) ); 569 | t.true ( isMatch ( '**/foo', 'foo' ) ); 570 | 571 | t.true ( !isMatch ( 'z*.js', 'zzjs' ) ); 572 | t.true ( !isMatch ( '*z.js', 'zzjs' ) ); 573 | 574 | t.true ( !isMatch ( 'a/b/**/f', 'a/b/c/d/' ) ); 575 | t.true ( isMatch ( 'a/**', 'a' ) ); 576 | t.true ( isMatch ( '**', 'a' ) ); 577 | t.true ( isMatch ( '**', 'a/' ) ); 578 | t.true ( isMatch ( 'a/b-*/**/z.js', 'a/b-c/d/e/z.js' ) ); 579 | t.true ( isMatch ( 'a/b-*/**/z.js', 'a/b-c/z.js' ) ); 580 | t.true ( isMatch ( '**', 'a/b/c/d' ) ); 581 | t.true ( isMatch ( '**', 'a/b/c/d/' ) ); 582 | t.true ( isMatch ( '**/**', 'a/b/c/d/' ) ); 583 | t.true ( isMatch ( '**/b/**', 'a/b/c/d/' ) ); 584 | t.true ( isMatch ( 'a/b/**', 'a/b/c/d/' ) ); 585 | t.true ( isMatch ( 'a/b/**/', 'a/b/c/d/' ) ); 586 | t.true ( isMatch ( 'a/b/**/c/**/', 'a/b/c/d/' ) ); 587 | t.true ( isMatch ( 'a/b/**/c/**/d/', 'a/b/c/d/' ) ); 588 | t.true ( isMatch ( 'a/b/**/**/*.*', 'a/b/c/d/e.f' ) ); 589 | t.true ( isMatch ( 'a/b/**/*.*', 'a/b/c/d/e.f' ) ); 590 | t.true ( isMatch ( 'a/b/**/c/**/d/*.*', 'a/b/c/d/e.f' ) ); 591 | t.true ( isMatch ( 'a/b/**/d/**/*.*', 'a/b/c/d/e.f' ) ); 592 | t.true ( isMatch ( 'a/b/**/d/**/*.*', 'a/b/c/d/g/e.f' ) ); 593 | t.true ( isMatch ( 'a/b/**/d/**/*.*', 'a/b/c/d/g/g/e.f' ) ); 594 | 595 | t.true ( !isMatch ( '*/foo', 'bar/baz/foo' ) ); 596 | t.true ( !isMatch ( '**/bar/*', 'deep/foo/bar' ) ); 597 | t.true ( !isMatch ( '*/bar/**', 'deep/foo/bar/baz/x' ) ); 598 | t.true ( !isMatch ( 'foo?bar', 'foo/bar' ) ); 599 | t.true ( !isMatch ( '**/bar*', 'foo/bar/baz' ) ); 600 | t.true ( !isMatch ( '**/bar**', 'foo/bar/baz' ) ); 601 | t.true ( !isMatch ( 'foo**bar', 'foo/baz/bar' ) ); 602 | t.true ( !isMatch ( 'foo*bar', 'foo/baz/bar' ) ); 603 | t.true ( !isMatch ( '**/bar/*/', 'deep/foo/bar/baz' ) ); 604 | t.true ( isMatch ( '**/bar/*', 'deep/foo/bar/baz/' ) ); 605 | t.true ( isMatch ( '**/bar/*', 'deep/foo/bar/baz' ) ); 606 | t.true ( isMatch ( 'foo/**', 'foo' ) ); 607 | t.true ( isMatch ( '**/bar/*{,/}', 'deep/foo/bar/baz/' ) ); 608 | t.true ( isMatch ( 'a/**/j/**/z/*.md', 'a/b/j/c/z/x.md' ) ); 609 | t.true ( isMatch ( 'a/**/j/**/z/*.md', 'a/j/z/x.md' ) ); 610 | t.true ( isMatch ( '**/foo', 'bar/baz/foo' ) ); 611 | t.true ( isMatch ( '**/bar/**', 'deep/foo/bar/' ) ); 612 | t.true ( isMatch ( '**/bar/*', 'deep/foo/bar/baz' ) ); 613 | t.true ( isMatch ( '**/bar/*/', 'deep/foo/bar/baz/' ) ); 614 | t.true ( isMatch ( '**/bar/**', 'deep/foo/bar/baz/' ) ); 615 | t.true ( isMatch ( '**/bar/*/*', 'deep/foo/bar/baz/x' ) ); 616 | t.true ( isMatch ( 'foo/**/**/bar', 'foo/b/a/z/bar' ) ); 617 | t.true ( isMatch ( 'foo/**/bar', 'foo/b/a/z/bar' ) ); 618 | t.true ( isMatch ( 'foo/**/**/bar', 'foo/bar' ) ); 619 | t.true ( isMatch ( 'foo/**/bar', 'foo/bar' ) ); 620 | t.true ( isMatch ( 'foo[/]bar', 'foo/bar' ) ); 621 | t.true ( isMatch ( '*/bar/**', 'foo/bar/baz/x' ) ); 622 | t.true ( isMatch ( 'foo/**/**/bar', 'foo/baz/bar' ) ); 623 | t.true ( isMatch ( 'foo/**/bar', 'foo/baz/bar' ) ); 624 | t.true ( isMatch ( 'foo**bar', 'foobazbar' ) ); 625 | t.true ( isMatch ( '**/foo', 'XXX/foo' ) ); 626 | 627 | t.true ( isMatch ( 'foo//baz.md', 'foo//baz.md' ) ); 628 | t.true ( isMatch ( 'foo//*baz.md', 'foo//baz.md' ) ); 629 | t.true ( isMatch ( 'foo{/,//}baz.md', 'foo//baz.md' ) ); 630 | t.true ( isMatch ( 'foo{/,//}baz.md', 'foo/baz.md' ) ); 631 | t.true ( !isMatch ( 'foo/+baz.md', 'foo//baz.md' ) ); 632 | t.true ( !isMatch ( 'foo//+baz.md', 'foo//baz.md' ) ); 633 | t.true ( !isMatch ( 'foo/baz.md', 'foo//baz.md' ) ); 634 | t.true ( !isMatch ( 'foo//baz.md', 'foo/baz.md' ) ); 635 | 636 | t.true ( !isMatch ( 'aaa?bbb', 'aaa/bbb' ) ); 637 | 638 | t.true ( isMatch ( '*.md', '.c.md' ) ); 639 | t.true ( !isMatch ( '*.md', 'a/.c.md' ) ); 640 | t.true ( isMatch ( 'a/.c.md', 'a/.c.md' ) ); 641 | t.true ( !isMatch ( '*.md', '.a' ) ); 642 | t.true ( !isMatch ( '*.md', '.verb.txt' ) ); 643 | t.true ( isMatch ( 'a/b/c/.*.md', 'a/b/c/.xyz.md' ) ); 644 | t.true ( isMatch ( '.md', '.md' ) ); 645 | t.true ( !isMatch ( '.md', '.txt' ) ); 646 | t.true ( isMatch ( '.md', '.md' ) ); 647 | t.true ( isMatch ( '.a', '.a' ) ); 648 | t.true ( isMatch ( '.b*', '.b' ) ); 649 | t.true ( isMatch ( '.a*', '.ab' ) ); 650 | t.true ( isMatch ( '.*', '.ab' ) ); 651 | t.true ( isMatch ( '*.*', '.ab' ) ); 652 | t.true ( !isMatch ( 'a/b/c/*.md', '.md' ) ); 653 | t.true ( !isMatch ( 'a/b/c/*.md', '.a.md' ) ); 654 | t.true ( isMatch ( 'a/b/c/*.md', 'a/b/c/d.a.md' ) ); 655 | t.true ( !isMatch ( 'a/b/c/*.md', 'a/b/d/.md' ) ); 656 | 657 | t.true ( isMatch ( '*.md', '.c.md' ) ); 658 | t.true ( isMatch ( '.*', '.c.md' ) ); 659 | t.true ( isMatch ( 'a/b/c/*.md', 'a/b/c/.xyz.md' ) ); 660 | t.true ( isMatch ( 'a/b/c/.*.md', 'a/b/c/.xyz.md' ) ); 661 | 662 | }); 663 | 664 | it ( 'brackets', t => { 665 | 666 | t.true ( isMatch ( 'foo[/]bar', 'foo/bar' ) ); 667 | t.true ( isMatch ( 'foo[/]bar[/]', 'foo/bar/' ) ); 668 | t.true ( isMatch ( 'foo[/]bar[/]baz', 'foo/bar/baz' ) ); 669 | 670 | }); 671 | 672 | it ( 'ranges', t => { 673 | 674 | t.true ( isMatch ( 'a/{a..c}', 'a/c' ) ); 675 | t.true ( !isMatch ( 'a/{a..c}', 'a/z' ) ); 676 | t.true ( isMatch ( 'a/{1..100}', 'a/99' ) ); 677 | t.true ( !isMatch ( 'a/{1..100}', 'a/101' ) ); 678 | t.true ( isMatch ( 'a/{01..10}', 'a/02' ) ); 679 | t.true ( !isMatch ( 'a/{01..10}', 'a/2' ) ); 680 | 681 | }); 682 | 683 | it ( 'exploits', t => { 684 | 685 | t.true ( !isMatch ( `${'\\'.repeat ( 65500 )}A`, '\\A' ) ); // This matches in picomatch, but why though? 686 | t.true ( isMatch ( `!${'\\'.repeat ( 65500 )}A`, 'A' ) ); 687 | t.true ( isMatch ( `!(${'\\'.repeat ( 65500 )}A)`, 'A' ) ); 688 | t.true ( !isMatch ( `[!(${'\\'.repeat ( 65500 )}A`, 'A' ) ); 689 | 690 | }); 691 | 692 | it ( 'wildmat', t => { 693 | 694 | t.true ( !isMatch ( '*f', 'foo' ) ); 695 | t.true ( !isMatch ( '??', 'foo' ) ); 696 | t.true ( !isMatch ( 'bar', 'foo' ) ); 697 | t.true ( !isMatch ( 'foo\\*bar', 'foobar' ) ); 698 | t.true ( isMatch ( '\\??\\?b', '?a?b' ) ); 699 | t.true ( isMatch ( '*ab', 'aaaaaaabababab' ) ); 700 | t.true ( isMatch ( '*', 'foo' ) ); 701 | t.true ( isMatch ( '*foo*', 'foo' ) ); 702 | t.true ( isMatch ( '???', 'foo' ) ); 703 | t.true ( isMatch ( 'f*', 'foo' ) ); 704 | t.true ( isMatch ( 'foo', 'foo' ) ); 705 | t.true ( isMatch ( '*ob*a*r*', 'foobar' ) ); 706 | 707 | t.true ( !isMatch ( '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' ) ); 708 | t.true ( !isMatch ( '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' ) ); 709 | t.true ( !isMatch ( '*X*i', 'ab/cXd/efXg/hi' ) ); 710 | t.true ( !isMatch ( '*Xg*i', 'ab/cXd/efXg/hi' ) ); 711 | t.true ( !isMatch ( '**/*a*b*g*n*t', 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' ) ); 712 | t.true ( !isMatch ( '*/*/*', 'foo' ) ); 713 | t.true ( !isMatch ( 'fo', 'foo' ) ); 714 | t.true ( !isMatch ( '*/*/*', 'foo/bar' ) ); 715 | t.true ( !isMatch ( 'foo?bar', 'foo/bar' ) ); 716 | t.true ( !isMatch ( '*/*/*', 'foo/bb/aa/rr' ) ); 717 | t.true ( !isMatch ( 'foo*', 'foo/bba/arr' ) ); 718 | t.true ( !isMatch ( 'foo**', 'foo/bba/arr' ) ); 719 | t.true ( !isMatch ( 'foo/*', 'foo/bba/arr' ) ); 720 | t.true ( !isMatch ( 'foo/**arr', 'foo/bba/arr' ) ); 721 | t.true ( !isMatch ( 'foo/**z', 'foo/bba/arr' ) ); 722 | t.true ( !isMatch ( 'foo/*arr', 'foo/bba/arr' ) ); 723 | t.true ( !isMatch ( 'foo/*z', 'foo/bba/arr' ) ); 724 | t.true ( !isMatch ( 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' ) ); 725 | t.true ( isMatch ( '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' ) ); 726 | t.true ( isMatch ( '**/*X*/**/*i', 'ab/cXd/efXg/hi' ) ); 727 | t.true ( isMatch ( '*/*X*/*/*i', 'ab/cXd/efXg/hi' ) ); 728 | t.true ( isMatch ( '**/*a*b*g*n*t', 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' ) ); 729 | t.true ( isMatch ( '*X*i', 'abcXdefXghi' ) ); 730 | t.true ( isMatch ( 'foo', 'foo' ) ); 731 | t.true ( isMatch ( 'foo/*', 'foo/bar' ) ); 732 | t.true ( isMatch ( 'foo/bar', 'foo/bar' ) ); 733 | t.true ( isMatch ( 'foo[/]bar', 'foo/bar' ) ); 734 | t.true ( isMatch ( '**/**/**', 'foo/bb/aa/rr' ) ); 735 | t.true ( isMatch ( '*/*/*', 'foo/bba/arr' ) ); 736 | t.true ( isMatch ( 'foo/**', 'foo/bba/arr' ) ); 737 | 738 | }); 739 | 740 | it.skip ( 'posix_classes', t => { 741 | 742 | t.true ( isMatch ( '[[:xdigit:]]', 'e' ) ); 743 | 744 | t.true ( isMatch ( '[[:alpha:]123]', 'a' ) ); 745 | t.true ( isMatch ( '[[:alpha:]123]', '1' ) ); 746 | t.true ( !isMatch ( '[[:alpha:]123]', '5' ) ); 747 | t.true ( isMatch ( '[[:alpha:]123]', 'A' ) ); 748 | 749 | t.true ( isMatch ( '[[:alpha:]]', 'A' ) ); 750 | t.true ( !isMatch ( '[[:alpha:]]', '9' ) ); 751 | t.true ( isMatch ( '[[:alpha:]]', 'b' ) ); 752 | 753 | t.true ( !isMatch ( '[![:alpha:]]', 'A' ) ); 754 | t.true ( isMatch ( '[![:alpha:]]', '9' ) ); 755 | t.true ( !isMatch ( '[![:alpha:]]', 'b' ) ); 756 | 757 | t.true ( !isMatch ( '[^[:alpha:]]', 'A' ) ); 758 | t.true ( isMatch ( '[^[:alpha:]]', '9' ) ); 759 | t.true ( !isMatch ( '[^[:alpha:]]', 'b' ) ); 760 | 761 | t.true ( !isMatch ( '[[:digit:]]', 'A' ) ); 762 | t.true ( isMatch ( '[[:digit:]]', '9' ) ); 763 | t.true ( !isMatch ( '[[:digit:]]', 'b' ) ); 764 | 765 | t.true ( isMatch ( '[^[:digit:]]', 'A' ) ); 766 | t.true ( !isMatch ( '[^[:digit:]]', '9' ) ); 767 | t.true ( isMatch ( '[^[:digit:]]', 'b' ) ); 768 | 769 | t.true ( isMatch ( '[![:digit:]]', 'A' ) ); 770 | t.true ( !isMatch ( '[![:digit:]]', '9' ) ); 771 | t.true ( isMatch ( '[![:digit:]]', 'b' ) ); 772 | 773 | t.true ( isMatch ( '[[:lower:]]', 'a' ) ); 774 | t.true ( !isMatch ( '[[:lower:]]', 'A' ) ); 775 | t.true ( !isMatch ( '[[:lower:]]', '9' ) ); 776 | 777 | t.true ( isMatch ( '[:alpha:]', 'a' ) ); 778 | t.true ( isMatch ( '[:alpha:]', 'l' ) ); 779 | t.true ( isMatch ( '[:alpha:]', 'p' ) ); 780 | t.true ( isMatch ( '[:alpha:]', 'h' ) ); 781 | t.true ( isMatch ( '[:alpha:]', ':' ) ); 782 | t.true ( !isMatch ( '[:alpha:]', 'b' ) ); 783 | 784 | t.true ( isMatch ( '[[:lower:][:digit:]]', '9' ) ); 785 | t.true ( isMatch ( '[[:lower:][:digit:]]', 'a' ) ); 786 | t.true ( !isMatch ( '[[:lower:][:digit:]]', 'A' ) ); 787 | t.true ( !isMatch ( '[[:lower:][:digit:]]', 'aa' ) ); 788 | t.true ( !isMatch ( '[[:lower:][:digit:]]', '99' ) ); 789 | t.true ( !isMatch ( '[[:lower:][:digit:]]', 'a9' ) ); 790 | t.true ( !isMatch ( '[[:lower:][:digit:]]', '9a' ) ); 791 | t.true ( !isMatch ( '[[:lower:][:digit:]]', 'aA' ) ); 792 | t.true ( !isMatch ( '[[:lower:][:digit:]]', '9A' ) ); 793 | t.true ( isMatch ( '[[:lower:][:digit:]]+', 'aa' ) ); 794 | t.true ( isMatch ( '[[:lower:][:digit:]]+', '99' ) ); 795 | t.true ( isMatch ( '[[:lower:][:digit:]]+', 'a9' ) ); 796 | t.true ( isMatch ( '[[:lower:][:digit:]]+', '9a' ) ); 797 | t.true ( !isMatch ( '[[:lower:][:digit:]]+', 'aA' ) ); 798 | t.true ( !isMatch ( '[[:lower:][:digit:]]+', '9A' ) ); 799 | t.true ( isMatch ( '[[:lower:][:digit:]]*', 'a' ) ); 800 | t.true ( !isMatch ( '[[:lower:][:digit:]]*', 'A' ) ); 801 | t.true ( !isMatch ( '[[:lower:][:digit:]]*', 'AA' ) ); 802 | t.true ( isMatch ( '[[:lower:][:digit:]]*', 'aa' ) ); 803 | t.true ( isMatch ( '[[:lower:][:digit:]]*', 'aaa' ) ); 804 | t.true ( isMatch ( '[[:lower:][:digit:]]*', '999' ) ); 805 | 806 | t.true ( !isMatch ( 'a[[:word:]]+c', 'a c' ) ); 807 | t.true ( !isMatch ( 'a[[:word:]]+c', 'a.c' ) ); 808 | t.true ( !isMatch ( 'a[[:word:]]+c', 'a.xy.zc' ) ); 809 | t.true ( !isMatch ( 'a[[:word:]]+c', 'a.zc' ) ); 810 | t.true ( !isMatch ( 'a[[:word:]]+c', 'abq' ) ); 811 | t.true ( !isMatch ( 'a[[:word:]]+c', 'axy zc' ) ); 812 | t.true ( !isMatch ( 'a[[:word:]]+c', 'axy' ) ); 813 | t.true ( !isMatch ( 'a[[:word:]]+c', 'axy.zc' ) ); 814 | t.true ( isMatch ( 'a[[:word:]]+c', 'a123c' ) ); 815 | t.true ( isMatch ( 'a[[:word:]]+c', 'a1c' ) ); 816 | t.true ( isMatch ( 'a[[:word:]]+c', 'abbbbc' ) ); 817 | t.true ( isMatch ( 'a[[:word:]]+c', 'abbbc' ) ); 818 | t.true ( isMatch ( 'a[[:word:]]+c', 'abbc' ) ); 819 | t.true ( isMatch ( 'a[[:word:]]+c', 'abc' ) ); 820 | 821 | t.true ( !isMatch ( 'a[[:word:]]+', 'a c' ) ); 822 | t.true ( !isMatch ( 'a[[:word:]]+', 'a.c' ) ); 823 | t.true ( !isMatch ( 'a[[:word:]]+', 'a.xy.zc' ) ); 824 | t.true ( !isMatch ( 'a[[:word:]]+', 'a.zc' ) ); 825 | t.true ( !isMatch ( 'a[[:word:]]+', 'axy zc' ) ); 826 | t.true ( !isMatch ( 'a[[:word:]]+', 'axy.zc' ) ); 827 | t.true ( isMatch ( 'a[[:word:]]+', 'a123c' ) ); 828 | t.true ( isMatch ( 'a[[:word:]]+', 'a1c' ) ); 829 | t.true ( isMatch ( 'a[[:word:]]+', 'abbbbc' ) ); 830 | t.true ( isMatch ( 'a[[:word:]]+', 'abbbc' ) ); 831 | t.true ( isMatch ( 'a[[:word:]]+', 'abbc' ) ); 832 | t.true ( isMatch ( 'a[[:word:]]+', 'abc' ) ); 833 | t.true ( isMatch ( 'a[[:word:]]+', 'abq' ) ); 834 | t.true ( isMatch ( 'a[[:word:]]+', 'axy' ) ); 835 | t.true ( isMatch ( 'a[[:word:]]+', 'axyzc' ) ); 836 | t.true ( isMatch ( 'a[[:word:]]+', 'axyzc' ) ); 837 | 838 | t.true ( isMatch ( '[[:lower:]]', 'a' ) ); 839 | t.true ( isMatch ( '[[:upper:]]', 'A' ) ); 840 | t.true ( isMatch ( '[[:digit:][:upper:][:space:]]', 'A' ) ); 841 | t.true ( isMatch ( '[[:digit:][:upper:][:space:]]', '1' ) ); 842 | t.true ( isMatch ( '[[:digit:][:upper:][:space:]]', ' ' ) ); 843 | t.true ( isMatch ( '[[:xdigit:]]', '5' ) ); 844 | t.true ( isMatch ( '[[:xdigit:]]', 'f' ) ); 845 | t.true ( isMatch ( '[[:xdigit:]]', 'D' ) ); 846 | t.true ( isMatch ( '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]', '_' ) ); 847 | t.true ( isMatch ( '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]', '_' ) ); 848 | t.true ( isMatch ( '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]', '.' ) ); 849 | t.true ( isMatch ( '[a-c[:digit:]x-z]', '5' ) ); 850 | t.true ( isMatch ( '[a-c[:digit:]x-z]', 'b' ) ); 851 | t.true ( isMatch ( '[a-c[:digit:]x-z]', 'y' ) ); 852 | 853 | t.true ( !isMatch ( '[[:lower:]]', 'A' ) ); 854 | t.true ( isMatch ( '[![:lower:]]', 'A' ) ); 855 | t.true ( !isMatch ( '[[:upper:]]', 'a' ) ); 856 | t.true ( !isMatch ( '[[:digit:][:upper:][:space:]]', 'a' ) ); 857 | t.true ( !isMatch ( '[[:digit:][:upper:][:space:]]', '.' ) ); 858 | t.true ( !isMatch ( '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]', '.' ) ); 859 | t.true ( !isMatch ( '[a-c[:digit:]x-z]', 'q' ) ); 860 | 861 | t.true ( isMatch ( 'a [b]', 'a [b]' ) ); 862 | t.true ( isMatch ( 'a [b]', 'a b' ) ); 863 | 864 | t.true ( isMatch ( 'a [b] c', 'a [b] c' ) ); 865 | t.true ( isMatch ( 'a [b] c', 'a b c' ) ); 866 | 867 | t.true ( isMatch ( 'a \\[b\\]', 'a [b]' ) ); 868 | t.true ( !isMatch ( 'a \\[b\\]', 'a b' ) ); 869 | 870 | t.true ( isMatch ( 'a ([b])', 'a [b]' ) ); 871 | t.true ( isMatch ( 'a ([b])', 'a b' ) ); 872 | 873 | t.true ( isMatch ( 'a (\\[b\\]|[b])', 'a b' ) ); 874 | t.true ( isMatch ( 'a (\\[b\\]|[b])', 'a [b]' ) ); 875 | 876 | t.true ( isMatch ( '[[:xdigit:]]', 'e' ) ); 877 | t.true ( isMatch ( '[[:xdigit:]]', '1' ) ); 878 | t.true ( isMatch ( '[[:alpha:]123]', 'a' ) ); 879 | t.true ( isMatch ( '[[:alpha:]123]', '1' ) ); 880 | 881 | t.true ( isMatch ( '[![:alpha:]]', '9' ) ); 882 | t.true ( isMatch ( '[^[:alpha:]]', '9' ) ); 883 | 884 | t.true ( isMatch ( '[[:word:]]', 'A' ) ); 885 | t.true ( isMatch ( '[[:word:]]', 'B' ) ); 886 | t.true ( isMatch ( '[[:word:]]', 'a' ) ); 887 | t.true ( isMatch ( '[[:word:]]', 'b' ) ); 888 | 889 | t.true ( isMatch ( '[[:word:]]', '1' ) ); 890 | t.true ( isMatch ( '[[:word:]]', '2' ) ); 891 | 892 | t.true ( isMatch ( '[[:digit:]]', '1' ) ); 893 | t.true ( isMatch ( '[[:digit:]]', '2' ) ); 894 | 895 | t.true ( !isMatch ( '[[:digit:]]', 'a' ) ); 896 | t.true ( !isMatch ( '[[:digit:]]', 'A' ) ); 897 | 898 | t.true ( isMatch ( '[[:upper:]]', 'A' ) ); 899 | t.true ( isMatch ( '[[:upper:]]', 'B' ) ); 900 | 901 | t.true ( !isMatch ( '[[:upper:]]', 'a' ) ); 902 | t.true ( !isMatch ( '[[:upper:]]', 'b' ) ); 903 | 904 | t.true ( !isMatch ( '[[:upper:]]', '1' ) ); 905 | t.true ( !isMatch ( '[[:upper:]]', '2' ) ); 906 | 907 | t.true ( isMatch ( '[[:lower:]]', 'a' ) ); 908 | t.true ( isMatch ( '[[:lower:]]', 'b' ) ); 909 | 910 | t.true ( !isMatch ( '[[:lower:]]', 'A' ) ); 911 | t.true ( !isMatch ( '[[:lower:]]', 'B' ) ); 912 | 913 | t.true ( isMatch ( '[[:lower:]][[:upper:]]', 'aA' ) ); 914 | t.true ( !isMatch ( '[[:lower:]][[:upper:]]', 'AA' ) ); 915 | t.true ( !isMatch ( '[[:lower:]][[:upper:]]', 'Aa' ) ); 916 | 917 | t.true ( isMatch ( '[[:xdigit:]]*', 'ababab' ) ); 918 | t.true ( isMatch ( '[[:xdigit:]]*', '020202' ) ); 919 | t.true ( isMatch ( '[[:xdigit:]]*', '900' ) ); 920 | 921 | t.true ( isMatch ( '[[:punct:]]', '!' ) ); 922 | t.true ( isMatch ( '[[:punct:]]', '?' ) ); 923 | t.true ( isMatch ( '[[:punct:]]', '#' ) ); 924 | t.true ( isMatch ( '[[:punct:]]', '&' ) ); 925 | t.true ( isMatch ( '[[:punct:]]', '@' ) ); 926 | t.true ( isMatch ( '[[:punct:]]', '+' ) ); 927 | t.true ( isMatch ( '[[:punct:]]', '*' ) ); 928 | t.true ( isMatch ( '[[:punct:]]', ':' ) ); 929 | t.true ( isMatch ( '[[:punct:]]', '=' ) ); 930 | t.true ( isMatch ( '[[:punct:]]', '|' ) ); 931 | t.true ( isMatch ( '[[:punct:]]*', '|++' ) ); 932 | 933 | t.true ( !isMatch ( '[[:punct:]]', '?*+' ) ); 934 | 935 | t.true ( isMatch ( '[[:punct:]]*', '?*+' ) ); 936 | t.true ( isMatch ( 'foo[[:punct:]]*', 'foo' ) ); 937 | t.true ( isMatch ( 'foo[[:punct:]]*', 'foo?*+' ) ); 938 | 939 | t.true ( isMatch ( '[:al:]', 'a' ) ); 940 | t.true ( isMatch ( '[[:al:]', 'a' ) ); 941 | t.true ( isMatch ( '[abc[:punct:][0-9]', '!' ) ); 942 | 943 | t.true ( isMatch ( '[_[:alpha:]]*', 'PATH' ) ); 944 | 945 | t.true ( isMatch ( '[_[:alpha:]][_[:alnum:]]*', 'PATH' ) ); 946 | 947 | t.true ( isMatch ( '[[:alpha:]][[:digit:]][[:upper:]]', 'a1B' ) ); 948 | t.true ( !isMatch ( '[[:alpha:]][[:digit:]][[:upper:]]', 'a1b' ) ); 949 | t.true ( isMatch ( '[[:digit:][:punct:][:space:]]', '.' ) ); 950 | t.true ( !isMatch ( '[[:digit:][:punct:][:space:]]', 'a' ) ); 951 | t.true ( isMatch ( '[[:digit:][:punct:][:space:]]', '!' ) ); 952 | t.true ( !isMatch ( '[[:digit:]][[:punct:]][[:space:]]', '!' ) ); 953 | t.true ( isMatch ( '[[:digit:]][[:punct:]][[:space:]]', '1! ' ) ); 954 | t.true ( !isMatch ( '[[:digit:]][[:punct:]][[:space:]]', '1! ' ) ); 955 | 956 | t.true ( isMatch ( '[[:digit:]]', '9' ) ); 957 | t.true ( !isMatch ( '[[:digit:]]', 'X' ) ); 958 | t.true ( isMatch ( '[[:lower:]][[:upper:]]', 'aB' ) ); 959 | t.true ( isMatch ( '[[:alpha:][:digit:]]', 'a' ) ); 960 | t.true ( isMatch ( '[[:alpha:][:digit:]]', '3' ) ); 961 | t.true ( !isMatch ( '[[:alpha:][:digit:]]', 'aa' ) ); 962 | t.true ( !isMatch ( '[[:alpha:][:digit:]]', 'a3' ) ); 963 | t.true ( !isMatch ( '[[:alpha:]\\]', 'a' ) ); 964 | t.true ( !isMatch ( '[[:alpha:]\\]', 'b' ) ); 965 | 966 | t.true ( isMatch ( '[[:blank:]]', '\t' ) ); 967 | t.true ( isMatch ( '[[:space:]]', '\t' ) ); 968 | t.true ( isMatch ( '[[:space:]]', ' ' ) ); 969 | 970 | t.true ( !isMatch ( '[[:ascii:]]', '\\377' ) ); 971 | t.true ( !isMatch ( '[1[:alpha:]123]', '9' ) ); 972 | 973 | t.true ( !isMatch ( '[[:punct:]]', ' ' ) ); 974 | 975 | t.true ( isMatch ( '[[:graph:]]', 'A' ) ); 976 | t.true ( !isMatch ( '[[:graph:]]', '\\b' ) ); 977 | t.true ( !isMatch ( '[[:graph:]]', '\\n' ) ); 978 | t.true ( !isMatch ( '[[:graph:]]', '\\s' ) ); 979 | 980 | }); 981 | 982 | it.skip ( 'extglobs', t => { 983 | 984 | t.true ( isMatch ( 'c!(.)z', 'cbz' ) ); 985 | t.true ( !isMatch ( 'c!(*)z', 'cbz' ) ); 986 | t.true ( isMatch ( 'c!(b*)z', 'cccz' ) ); 987 | t.true ( isMatch ( 'c!(+)z', 'cbz' ) ); 988 | t.true ( !isMatch ( 'c!(?)z', 'cbz' ) ); // This matches in picomatch, but why though? 989 | t.true ( isMatch ( 'c!(@)z', 'cbz' ) ); 990 | 991 | t.true ( !isMatch ( 'c!(?:foo)?z', 'c/z' ) ); 992 | t.true ( isMatch ( 'c!(?:foo)?z', 'c!fooz' ) ); 993 | t.true ( isMatch ( 'c!(?:foo)?z', 'c!z' ) ); 994 | 995 | // t.true ( !isMatch ( '!(abc)', 'abc' ) ); 996 | // t.true ( !isMatch ( '!(a)', 'a' ) ); 997 | // t.true ( isMatch ( '!(a)', 'aa' ) ); 998 | // t.true ( isMatch ( '!(a)', 'b' ) ); 999 | 1000 | t.true ( isMatch ( 'a!(b)c', 'aac' ) ); 1001 | t.true ( !isMatch ( 'a!(b)c', 'abc' ) ); 1002 | t.true ( isMatch ( 'a!(b)c', 'acc' ) ); 1003 | t.true ( isMatch ( 'a!(z)', 'abz' ) ); 1004 | t.true ( !isMatch ( 'a!(z)', 'az' ) ); 1005 | 1006 | t.true ( !isMatch ( 'a!(.)', 'a.' ) ); 1007 | t.true ( !isMatch ( '!(.)a', '.a' ) ); 1008 | t.true ( !isMatch ( 'a!(.)c', 'a.c' ) ); 1009 | t.true ( isMatch ( 'a!(.)c', 'abc' ) ); 1010 | 1011 | t.true ( !isMatch ( '/!(*.d).ts', '/file.d.ts' ) ); 1012 | t.true ( isMatch ( '/!(*.d).ts', '/file.ts' ) ); 1013 | t.true ( isMatch ( '/!(*.d).ts', '/file.something.ts' ) ); 1014 | // t.true ( isMatch ( '/!(*.d).ts', '/file.d.something.ts' ) ); 1015 | // t.true ( isMatch ( '/!(*.d).ts', '/file.dhello.ts' ) ); 1016 | 1017 | // t.true ( !isMatch ( '**/!(*.d).ts', '/file.d.ts' ) ); 1018 | // t.true ( isMatch ( '**/!(*.d).ts', '/file.ts' ) ); 1019 | // t.true ( isMatch ( '**/!(*.d).ts', '/file.something.ts' ) ); 1020 | // t.true ( isMatch ( '**/!(*.d).ts', '/file.d.something.ts' ) ); 1021 | // t.true ( isMatch ( '**/!(*.d).ts', '/file.dhello.ts' ) ); 1022 | 1023 | // t.true ( !isMatch ( '/!(*.d).{ts,tsx}', '/file.d.ts' ) ); 1024 | // t.true ( isMatch ( '/!(*.d).{ts,tsx}', '/file.ts' ) ); 1025 | // t.true ( isMatch ( '/!(*.d).{ts,tsx}', '/file.something.ts' ) ); 1026 | // t.true ( isMatch ( '/!(*.d).{ts,tsx}', '/file.d.something.ts' ) ); 1027 | // t.true ( isMatch ( '/!(*.d).{ts,tsx}', '/file.dhello.ts' ) ); 1028 | 1029 | // t.true ( !isMatch ( '/!(*.d).@(ts)', '/file.d.ts' ) ); 1030 | // t.true ( isMatch ( '/!(*.d).@(ts)', '/file.ts' ) ); 1031 | // t.true ( isMatch ( '/!(*.d).@(ts)', '/file.something.ts' ) ); 1032 | // t.true ( isMatch ( '/!(*.d).@(ts)', '/file.d.something.ts' ) ); 1033 | // t.true ( isMatch ( '/!(*.d).@(ts)', '/file.dhello.ts' ) ); 1034 | 1035 | t.true ( !isMatch ( 'foo/!(abc)', 'foo/abc' ) ); 1036 | t.true ( isMatch ( 'foo/!(abc)', 'foo/bar' ) ); 1037 | 1038 | t.true ( !isMatch ( 'a/!(z)', 'a/z' ) ); 1039 | t.true ( isMatch ( 'a/!(z)', 'a/b' ) ); 1040 | 1041 | t.true ( !isMatch ( 'c/!(z)/v', 'c/z/v' ) ); 1042 | t.true ( isMatch ( 'c/!(z)/v', 'c/a/v' ) ); 1043 | 1044 | t.true ( isMatch ( '!(b/a)', 'a/a' ) ); 1045 | t.true ( !isMatch ( '!(b/a)', 'b/a' ) ); 1046 | 1047 | // t.true ( !isMatch ( '!(!(foo))*', 'foo/bar' ) ); 1048 | t.true ( isMatch ( '!(b/a)', 'a/a' ) ); 1049 | t.true ( !isMatch ( '!(b/a)', 'b/a' ) ); 1050 | 1051 | // t.true ( isMatch ( '(!(b/a))', 'a/a' ) ); 1052 | // t.true ( isMatch ( '!((b/a))', 'a/a' ) ); 1053 | // t.true ( !isMatch ( '!((b/a))', 'b/a' ) ); 1054 | 1055 | t.true ( !isMatch ( '(!(?:b/a))', 'a/a' ) ); 1056 | t.true ( !isMatch ( '!((?:b/a))', 'b/a' ) ); 1057 | 1058 | // t.true ( isMatch ( '!(b/(a))', 'a/a' ) ); 1059 | // t.true ( !isMatch ( '!(b/(a))', 'b/a' ) ); 1060 | 1061 | t.true ( isMatch ( '!(b/a)', 'a/a' ) ); 1062 | t.true ( !isMatch ( '!(b/a)', 'b/a' ) ); 1063 | 1064 | // t.true ( !isMatch ( 'c!(z)', 'c/z' ) ); 1065 | // t.true ( !isMatch ( 'c!(z)z', 'c/z' ) ); 1066 | // t.true ( !isMatch ( 'c!(.)z', 'c/z' ) ); 1067 | // t.true ( !isMatch ( 'c!(*)z', 'c/z' ) ); 1068 | // t.true ( !isMatch ( 'c!(+)z', 'c/z' ) ); 1069 | // t.true ( !isMatch ( 'c!(?)z', 'c/z' ) ); 1070 | // t.true ( !isMatch ( 'c!(@)z', 'c/z' ) ); 1071 | 1072 | // t.true ( !isMatch ( 'a!(z)', 'c/z' ) ); 1073 | // t.true ( !isMatch ( 'c!(.)z', 'c/z' ) ); 1074 | // t.true ( !isMatch ( 'c!(/)z', 'c/z' ) ); 1075 | // t.true ( !isMatch ( 'c!(/z)z', 'c/z' ) ); 1076 | // t.true ( !isMatch ( 'c!(/z)z', 'c/b' ) ); 1077 | // t.true ( isMatch ( 'c!(/z)z', 'c/b/z' ) ); 1078 | 1079 | // t.true ( isMatch ( '!!(abc)', 'abc' ) ); 1080 | // t.true ( !isMatch ( '!!!(abc)', 'abc' ) ); 1081 | // t.true ( isMatch ( '!!!!(abc)', 'abc' ) ); 1082 | // t.true ( !isMatch ( '!!!!!(abc)', 'abc' ) ); 1083 | // t.true ( isMatch ( '!!!!!!(abc)', 'abc' ) ); 1084 | // t.true ( !isMatch ( '!!!!!!!(abc)', 'abc' ) ); 1085 | // t.true ( isMatch ( '!!!!!!!!(abc)', 'abc' ) ); 1086 | 1087 | // t.true ( isMatch ( '!(!(abc))', 'abc' ) ); 1088 | // t.true ( !isMatch ( '!(!(!(abc)))', 'abc' ) ); 1089 | // t.true ( isMatch ( '!(!(!(!(abc))))', 'abc' ) ); 1090 | // t.true ( !isMatch ( '!(!(!(!(!(abc)))))', 'abc' ) ); 1091 | // t.true ( isMatch ( '!(!(!(!(!(!(abc))))))', 'abc' ) ); 1092 | // t.true ( !isMatch ( '!(!(!(!(!(!(!(abc)))))))', 'abc' ) ); 1093 | // t.true ( isMatch ( '!(!(!(!(!(!(!(!(abc))))))))', 'abc' ) ); 1094 | 1095 | // t.true ( isMatch ( 'foo/!(!(abc))', 'foo/abc' ) ); 1096 | // t.true ( !isMatch ( 'foo/!(!(!(abc)))', 'foo/abc' ) ); 1097 | // t.true ( isMatch ( 'foo/!(!(!(!(abc))))', 'foo/abc' ) ); 1098 | // t.true ( !isMatch ( 'foo/!(!(!(!(!(abc)))))', 'foo/abc' ) ); 1099 | // t.true ( isMatch ( 'foo/!(!(!(!(!(!(abc))))))', 'foo/abc' ) ); 1100 | // t.true ( !isMatch ( 'foo/!(!(!(!(!(!(!(abc)))))))', 'foo/abc' ) ); 1101 | // t.true ( isMatch ( 'foo/!(!(!(!(!(!(!(!(abc))))))))', 'foo/abc' ) ); 1102 | 1103 | t.true ( !isMatch ( '!(moo).!(cow)', 'moo.cow' ) ); 1104 | t.true ( !isMatch ( '!(moo).!(cow)', 'foo.cow' ) ); 1105 | t.true ( !isMatch ( '!(moo).!(cow)', 'moo.bar' ) ); 1106 | t.true ( isMatch ( '!(moo).!(cow)', 'foo.bar' ) ); 1107 | 1108 | // t.true ( !isMatch ( '@(!(a) )*', 'a ' ) ); 1109 | // t.true ( !isMatch ( '@(!(a) )*', 'a b' ) ); 1110 | // t.true ( !isMatch ( '@(!(a) )*', 'a b' ) ); 1111 | // t.true ( !isMatch ( '@(!(a) )*', 'a ' ) ); 1112 | // t.true ( !isMatch ( '@(!(a) )*', 'a ' ) ); 1113 | // t.true ( !isMatch ( '@(!(a) )*', 'a' ) ); 1114 | // t.true ( !isMatch ( '@(!(a) )*', 'aa' ) ); 1115 | // t.true ( !isMatch ( '@(!(a) )*', 'b' ) ); 1116 | // t.true ( !isMatch ( '@(!(a) )*', 'bb' ) ); 1117 | // t.true ( isMatch ( '@(!(a) )*', ' a ' ) ); 1118 | // t.true ( isMatch ( '@(!(a) )*', 'b ' ) ); 1119 | // t.true ( isMatch ( '@(!(a) )*', 'b ' ) ); 1120 | 1121 | t.true ( !isMatch ( 'a*!(z)', 'c/z' ) ); 1122 | t.true ( isMatch ( 'a*!(z)', 'abz' ) ); 1123 | t.true ( isMatch ( 'a*!(z)', 'az' ) ); 1124 | 1125 | t.true ( !isMatch ( '!(a*)', 'a' ) ); 1126 | t.true ( !isMatch ( '!(a*)', 'aa' ) ); 1127 | t.true ( !isMatch ( '!(a*)', 'ab' ) ); 1128 | t.true ( isMatch ( '!(a*)', 'b' ) ); 1129 | 1130 | t.true ( !isMatch ( '!(*a*)', 'a' ) ); 1131 | t.true ( !isMatch ( '!(*a*)', 'aa' ) ); 1132 | t.true ( !isMatch ( '!(*a*)', 'ab' ) ); 1133 | t.true ( !isMatch ( '!(*a*)', 'ac' ) ); 1134 | t.true ( isMatch ( '!(*a*)', 'b' ) ); 1135 | 1136 | // t.true ( !isMatch ( '!(*a)', 'a' ) ); 1137 | // t.true ( !isMatch ( '!(*a)', 'aa' ) ); 1138 | // t.true ( !isMatch ( '!(*a)', 'bba' ) ); 1139 | // t.true ( isMatch ( '!(*a)', 'ab' ) ); 1140 | // t.true ( isMatch ( '!(*a)', 'ac' ) ); 1141 | // t.true ( isMatch ( '!(*a)', 'b' ) ); 1142 | 1143 | t.true ( !isMatch ( '!(*a)*', 'a' ) ); 1144 | t.true ( !isMatch ( '!(*a)*', 'aa' ) ); 1145 | t.true ( !isMatch ( '!(*a)*', 'bba' ) ); 1146 | t.true ( !isMatch ( '!(*a)*', 'ab' ) ); 1147 | t.true ( !isMatch ( '!(*a)*', 'ac' ) ); 1148 | t.true ( isMatch ( '!(*a)*', 'b' ) ); 1149 | 1150 | t.true ( !isMatch ( '!(a)*', 'a' ) ); 1151 | t.true ( !isMatch ( '!(a)*', 'abb' ) ); 1152 | t.true ( isMatch ( '!(a)*', 'ba' ) ); 1153 | 1154 | t.true ( isMatch ( 'a!(b)*', 'aa' ) ); 1155 | t.true ( !isMatch ( 'a!(b)*', 'ab' ) ); 1156 | t.true ( !isMatch ( 'a!(b)*', 'aba' ) ); 1157 | t.true ( isMatch ( 'a!(b)*', 'ac' ) ); 1158 | 1159 | // t.true ( isMatch ( '!(!(moo)).!(!(cow))', 'moo.cow' ) ); 1160 | 1161 | t.true ( !isMatch ( '!(a|b)c', 'ac' ) ); 1162 | t.true ( !isMatch ( '!(a|b)c', 'bc' ) ); 1163 | t.true ( isMatch ( '!(a|b)c', 'cc' ) ); 1164 | 1165 | t.true ( !isMatch ( '!(a|b)c.!(d|e)', 'ac.d' ) ); 1166 | t.true ( !isMatch ( '!(a|b)c.!(d|e)', 'bc.d' ) ); 1167 | t.true ( !isMatch ( '!(a|b)c.!(d|e)', 'cc.d' ) ); 1168 | t.true ( !isMatch ( '!(a|b)c.!(d|e)', 'ac.e' ) ); 1169 | t.true ( !isMatch ( '!(a|b)c.!(d|e)', 'bc.e' ) ); 1170 | t.true ( !isMatch ( '!(a|b)c.!(d|e)', 'cc.e' ) ); 1171 | t.true ( !isMatch ( '!(a|b)c.!(d|e)', 'ac.f' ) ); 1172 | t.true ( !isMatch ( '!(a|b)c.!(d|e)', 'bc.f' ) ); 1173 | t.true ( isMatch ( '!(a|b)c.!(d|e)', 'cc.f' ) ); 1174 | t.true ( isMatch ( '!(a|b)c.!(d|e)', 'dc.g' ) ); 1175 | 1176 | // t.true ( isMatch ( '!(!(a|b)c.!(d|e))', 'ac.d' ) ); 1177 | // t.true ( isMatch ( '!(!(a|b)c.!(d|e))', 'bc.d' ) ); 1178 | // t.true ( !isMatch ( '!(a|b)c.!(d|e)', 'cc.d' ) ); 1179 | // t.true ( isMatch ( '!(!(a|b)c.!(d|e))', 'cc.d' ) ); 1180 | // t.true ( isMatch ( '!(!(a|b)c.!(d|e))', 'cc.d' ) ); 1181 | // t.true ( isMatch ( '!(!(a|b)c.!(d|e))', 'ac.e' ) ); 1182 | // t.true ( isMatch ( '!(!(a|b)c.!(d|e))', 'bc.e' ) ); 1183 | // t.true ( isMatch ( '!(!(a|b)c.!(d|e))', 'cc.e' ) ); 1184 | // t.true ( isMatch ( '!(!(a|b)c.!(d|e))', 'ac.f' ) ); 1185 | // t.true ( isMatch ( '!(!(a|b)c.!(d|e))', 'bc.f' ) ); 1186 | // t.true ( !isMatch ( '!(!(a|b)c.!(d|e))', 'cc.f' ) ); 1187 | // t.true ( !isMatch ( '!(!(a|b)c.!(d|e))', 'dc.g' ) ); 1188 | 1189 | // t.true ( !isMatch ( '@(a|b).md', '.md' ) ); 1190 | // t.true ( !isMatch ( '@(a|b).md', 'a.js' ) ); 1191 | // t.true ( !isMatch ( '@(a|b).md', 'c.md' ) ); 1192 | // t.true ( isMatch ( '@(a|b).md', 'a.md' ) ); 1193 | // t.true ( isMatch ( '@(a|b).md', 'b.md' ) ); 1194 | 1195 | t.true ( !isMatch ( '+(a|b).md', '.md' ) ); 1196 | t.true ( !isMatch ( '+(a|b).md', 'a.js' ) ); 1197 | t.true ( !isMatch ( '+(a|b).md', 'c.md' ) ); 1198 | t.true ( isMatch ( '+(a|b).md', 'a.md' ) ); 1199 | t.true ( isMatch ( '+(a|b).md', 'aa.md' ) ); 1200 | t.true ( isMatch ( '+(a|b).md', 'ab.md' ) ); 1201 | t.true ( isMatch ( '+(a|b).md', 'b.md' ) ); 1202 | t.true ( isMatch ( '+(a|b).md', 'bb.md' ) ); 1203 | 1204 | t.true ( !isMatch ( '*(a|b).md', 'a.js' ) ); 1205 | t.true ( !isMatch ( '*(a|b).md', 'c.md' ) ); 1206 | t.true ( isMatch ( '*(a|b).md', '.md' ) ); 1207 | t.true ( isMatch ( '*(a|b).md', 'a.md' ) ); 1208 | t.true ( isMatch ( '*(a|b).md', 'aa.md' ) ); 1209 | t.true ( isMatch ( '*(a|b).md', 'ab.md' ) ); 1210 | t.true ( isMatch ( '*(a|b).md', 'b.md' ) ); 1211 | t.true ( isMatch ( '*(a|b).md', 'bb.md' ) ); 1212 | 1213 | t.true ( !isMatch ( '?(a|b).md', 'a.js' ) ); 1214 | t.true ( !isMatch ( '?(a|b).md', 'bb.md' ) ); 1215 | t.true ( !isMatch ( '?(a|b).md', 'c.md' ) ); 1216 | t.true ( isMatch ( '?(a|b).md', '.md' ) ); 1217 | t.true ( isMatch ( '?(a|ab|b).md', 'a.md' ) ); 1218 | t.true ( isMatch ( '?(a|b).md', 'a.md' ) ); 1219 | t.true ( isMatch ( '?(a|aa|b).md', 'aa.md' ) ); 1220 | t.true ( isMatch ( '?(a|ab|b).md', 'ab.md' ) ); 1221 | t.true ( isMatch ( '?(a|ab|b).md', 'b.md' ) ); 1222 | 1223 | t.true ( isMatch ( '+(a)?(b)', 'ab' ) ); 1224 | t.true ( isMatch ( '+(a)?(b)', 'aab' ) ); 1225 | t.true ( isMatch ( '+(a)?(b)', 'aa' ) ); 1226 | t.true ( isMatch ( '+(a)?(b)', 'a' ) ); 1227 | 1228 | t.true ( !isMatch ( 'a?(b*)', 'ax' ) ); 1229 | t.true ( isMatch ( '?(a*|b)', 'ax' ) ); 1230 | 1231 | t.true ( !isMatch ( 'a*(b*)', 'ax' ) ); 1232 | t.true ( isMatch ( '*(a*|b)', 'ax' ) ); 1233 | 1234 | t.true ( !isMatch ( 'a@(b*)', 'ax' ) ); 1235 | t.true ( isMatch ( '@(a*|b)', 'ax' ) ); 1236 | 1237 | t.true ( !isMatch ( 'a?(b*)', 'ax' ) ); 1238 | t.true ( isMatch ( '?(a*|b)', 'ax' ) ); 1239 | 1240 | t.true ( isMatch ( 'a!(b*)', 'ax' ) ); 1241 | t.true ( !isMatch ( '!(a*|b)', 'ax' ) ); 1242 | 1243 | // t.true ( isMatch ( '!(a/**)', 'a' ) ); 1244 | // t.true ( !isMatch ( '!(a/**)', 'a/' ) ); 1245 | // t.true ( !isMatch ( '!(a/**)', 'a/b' ) ); 1246 | // t.true ( !isMatch ( '!(a/**)', 'a/b/c' ) ); 1247 | // t.true ( isMatch ( '!(a/**)', 'b' ) ); 1248 | // t.true ( isMatch ( '!(a/**)', 'b/c' ) ); 1249 | 1250 | t.true ( isMatch ( 'a/!(b*)', 'a/a' ) ); 1251 | t.true ( !isMatch ( 'a/!(b*)', 'a/b' ) ); 1252 | t.true ( !isMatch ( 'a/!(b/*)', 'a/b/c' ) ); 1253 | t.true ( !isMatch ( 'a/!(b*)', 'a/b/c' ) ); 1254 | t.true ( isMatch ( 'a/!(b*)', 'a/c' ) ); 1255 | 1256 | t.true ( isMatch ( 'a/!(b*)/**', 'a/a/' ) ); 1257 | t.true ( isMatch ( 'a/!(b*)', 'a/a' ) ); 1258 | t.true ( isMatch ( 'a/!(b*)/**', 'a/a' ) ); 1259 | t.true ( !isMatch ( 'a/!(b*)/**', 'a/b' ) ); 1260 | t.true ( !isMatch ( 'a/!(b*)/**', 'a/b/c' ) ); 1261 | t.true ( isMatch ( 'a/!(b*)/**', 'a/c' ) ); 1262 | t.true ( isMatch ( 'a/!(b*)', 'a/c' ) ); 1263 | t.true ( isMatch ( 'a/!(b*)/**', 'a/c/' ) ); 1264 | 1265 | t.true ( isMatch ( 'a*(z)', 'a' ) ); 1266 | t.true ( isMatch ( 'a*(z)', 'az' ) ); 1267 | t.true ( isMatch ( 'a*(z)', 'azz' ) ); 1268 | t.true ( isMatch ( 'a*(z)', 'azzz' ) ); 1269 | t.true ( !isMatch ( 'a*(z)', 'abz' ) ); 1270 | t.true ( !isMatch ( 'a*(z)', 'cz' ) ); 1271 | 1272 | t.true ( !isMatch ( '*(b/a)', 'a/a' ) ); 1273 | t.true ( !isMatch ( '*(b/a)', 'a/b' ) ); 1274 | t.true ( !isMatch ( '*(b/a)', 'a/c' ) ); 1275 | t.true ( isMatch ( '*(b/a)', 'b/a' ) ); 1276 | t.true ( !isMatch ( '*(b/a)', 'b/b' ) ); 1277 | t.true ( !isMatch ( '*(b/a)', 'b/c' ) ); 1278 | 1279 | // t.true ( !isMatch ( 'a**(z)', 'cz' ) ); 1280 | // t.true ( isMatch ( 'a**(z)', 'abz' ) ); 1281 | // t.true ( isMatch ( 'a**(z)', 'az' ) ); 1282 | 1283 | t.true ( !isMatch ( '*(z)', 'c/z/v' ) ); 1284 | t.true ( isMatch ( '*(z)', 'z' ) ); 1285 | t.true ( !isMatch ( '*(z)', 'zf' ) ); 1286 | t.true ( !isMatch ( '*(z)', 'fz' ) ); 1287 | 1288 | t.true ( !isMatch ( 'c/*(z)/v', 'c/a/v' ) ); 1289 | t.true ( isMatch ( 'c/*(z)/v', 'c/z/v' ) ); 1290 | 1291 | t.true ( !isMatch ( '*.*(js).js', 'a.md.js' ) ); 1292 | t.true ( isMatch ( '*.*(js).js', 'a.js.js' ) ); 1293 | 1294 | t.true ( !isMatch ( 'a+(z)', 'a' ) ); 1295 | t.true ( isMatch ( 'a+(z)', 'az' ) ); 1296 | t.true ( !isMatch ( 'a+(z)', 'cz' ) ); 1297 | t.true ( !isMatch ( 'a+(z)', 'abz' ) ); 1298 | t.true ( !isMatch ( 'a+(z)', 'a+z' ) ); 1299 | t.true ( isMatch ( 'a++(z)', 'a+z' ) ); 1300 | t.true ( !isMatch ( 'a+(z)', 'c+z' ) ); 1301 | t.true ( !isMatch ( 'a+(z)', 'a+bz' ) ); 1302 | t.true ( !isMatch ( '+(z)', 'az' ) ); 1303 | t.true ( !isMatch ( '+(z)', 'cz' ) ); 1304 | t.true ( !isMatch ( '+(z)', 'abz' ) ); 1305 | t.true ( !isMatch ( '+(z)', 'fz' ) ); 1306 | t.true ( isMatch ( '+(z)', 'z' ) ); 1307 | t.true ( isMatch ( '+(z)', 'zz' ) ); 1308 | t.true ( isMatch ( 'c/+(z)/v', 'c/z/v' ) ); 1309 | t.true ( isMatch ( 'c/+(z)/v', 'c/zz/v' ) ); 1310 | t.true ( !isMatch ( 'c/+(z)/v', 'c/a/v' ) ); 1311 | 1312 | t.true ( isMatch ( 'a??(z)', 'a?z' ) ); 1313 | t.true ( isMatch ( 'a??(z)', 'a.z' ) ); 1314 | t.true ( !isMatch ( 'a??(z)', 'a/z' ) ); 1315 | t.true ( isMatch ( 'a??(z)', 'a?' ) ); 1316 | t.true ( isMatch ( 'a??(z)', 'ab' ) ); 1317 | t.true ( !isMatch ( 'a??(z)', 'a/' ) ); 1318 | 1319 | t.true ( !isMatch ( 'a?(z)', 'a?z' ) ); 1320 | t.true ( !isMatch ( 'a?(z)', 'abz' ) ); 1321 | t.true ( !isMatch ( 'a?(z)', 'z' ) ); 1322 | t.true ( isMatch ( 'a?(z)', 'a' ) ); 1323 | t.true ( isMatch ( 'a?(z)', 'az' ) ); 1324 | 1325 | t.true ( !isMatch ( '?(z)', 'abz' ) ); 1326 | t.true ( !isMatch ( '?(z)', 'az' ) ); 1327 | t.true ( !isMatch ( '?(z)', 'cz' ) ); 1328 | t.true ( !isMatch ( '?(z)', 'fz' ) ); 1329 | t.true ( !isMatch ( '?(z)', 'zz' ) ); 1330 | t.true ( isMatch ( '?(z)', 'z' ) ); 1331 | 1332 | t.true ( !isMatch ( 'c/?(z)/v', 'c/a/v' ) ); 1333 | t.true ( !isMatch ( 'c/?(z)/v', 'c/zz/v' ) ); 1334 | t.true ( isMatch ( 'c/?(z)/v', 'c/z/v' ) ); 1335 | 1336 | t.true ( isMatch ( 'c/@(z)/v', 'c/z/v' ) ); 1337 | t.true ( !isMatch ( 'c/@(z)/v', 'c/a/v' ) ); 1338 | t.true ( isMatch ( '@(*.*)', 'moo.cow' ) ); 1339 | 1340 | t.true ( !isMatch ( 'a*@(z)', 'cz' ) ); 1341 | t.true ( isMatch ( 'a*@(z)', 'abz' ) ); 1342 | t.true ( isMatch ( 'a*@(z)', 'az' ) ); 1343 | 1344 | t.true ( !isMatch ( 'a@(z)', 'cz' ) ); 1345 | t.true ( !isMatch ( 'a@(z)', 'abz' ) ); 1346 | t.true ( isMatch ( 'a@(z)', 'az' ) ); 1347 | 1348 | t.true ( !isMatch ( '(b|a).(a)', 'aa.aa' ) ); 1349 | t.true ( !isMatch ( '(b|a).(a)', 'a.bb' ) ); 1350 | t.true ( !isMatch ( '(b|a).(a)', 'a.aa.a' ) ); 1351 | t.true ( !isMatch ( '(b|a).(a)', 'cc.a' ) ); 1352 | // t.true ( isMatch ( '(b|a).(a)', 'a.a' ) ); 1353 | t.true ( !isMatch ( '(b|a).(a)', 'c.a' ) ); 1354 | t.true ( !isMatch ( '(b|a).(a)', 'dd.aa.d' ) ); 1355 | // t.true ( isMatch ( '(b|a).(a)', 'b.a' ) ); 1356 | 1357 | // t.true ( !isMatch ( '@(b|a).@(a)', 'aa.aa' ) ); 1358 | // t.true ( !isMatch ( '@(b|a).@(a)', 'a.bb' ) ); 1359 | // t.true ( !isMatch ( '@(b|a).@(a)', 'a.aa.a' ) ); 1360 | // t.true ( !isMatch ( '@(b|a).@(a)', 'cc.a' ) ); 1361 | // t.true ( isMatch ( '@(b|a).@(a)', 'a.a' ) ); 1362 | // t.true ( !isMatch ( '@(b|a).@(a)', 'c.a' ) ); 1363 | // t.true ( !isMatch ( '@(b|a).@(a)', 'dd.aa.d' ) ); 1364 | // t.true ( isMatch ( '@(b|a).@(a)', 'b.a' ) ); 1365 | 1366 | // t.true ( !isMatch ( '*(0|1|3|5|7|9)', '' ) ); 1367 | 1368 | t.true ( isMatch ( '*(0|1|3|5|7|9)', '137577991' ) ); 1369 | t.true ( !isMatch ( '*(0|1|3|5|7|9)', '2468' ) ); 1370 | 1371 | t.true ( isMatch ( '*.c?(c)', 'file.c' ) ); 1372 | t.true ( !isMatch ( '*.c?(c)', 'file.C' ) ); 1373 | t.true ( isMatch ( '*.c?(c)', 'file.cc' ) ); 1374 | t.true ( !isMatch ( '*.c?(c)', 'file.ccc' ) ); 1375 | 1376 | t.true ( isMatch ( '!(*.c|*.h|Makefile.in|config*|README)', 'parse.y' ) ); 1377 | t.true ( !isMatch ( '!(*.c|*.h|Makefile.in|config*|README)', 'shell.c' ) ); 1378 | t.true ( isMatch ( '!(*.c|*.h|Makefile.in|config*|README)', 'Makefile' ) ); 1379 | t.true ( !isMatch ( '!(*.c|*.h|Makefile.in|config*|README)', 'Makefile.in' ) ); 1380 | 1381 | t.true ( !isMatch ( '*\\;[1-9]*([0-9])', 'VMS.FILE;' ) ); 1382 | t.true ( !isMatch ( '*\\;[1-9]*([0-9])', 'VMS.FILE;0' ) ); 1383 | t.true ( isMatch ( '*\\;[1-9]*([0-9])', 'VMS.FILE;1' ) ); 1384 | t.true ( isMatch ( '*\\;[1-9]*([0-9])', 'VMS.FILE;139' ) ); 1385 | t.true ( !isMatch ( '*\\;[1-9]*([0-9])', 'VMS.FILE;1N' ) ); 1386 | 1387 | t.true ( isMatch ( '!([*)*', 'abcx' ) ); 1388 | t.true ( isMatch ( '!([*)*', 'abcz' ) ); 1389 | t.true ( isMatch ( '!([*)*', 'bbc' ) ); 1390 | 1391 | t.true ( isMatch ( '!([[*])*', 'abcx' ) ); 1392 | t.true ( isMatch ( '!([[*])*', 'abcz' ) ); 1393 | t.true ( isMatch ( '!([[*])*', 'bbc' ) ); 1394 | 1395 | t.true ( isMatch ( '+(a|b\\[)*', 'abcx' ) ); 1396 | t.true ( isMatch ( '+(a|b\\[)*', 'abcz' ) ); 1397 | t.true ( !isMatch ( '+(a|b\\[)*', 'bbc' ) ); 1398 | 1399 | t.true ( isMatch ( '+(a|b[)*', 'abcx' ) ); 1400 | t.true ( isMatch ( '+(a|b[)*', 'abcz' ) ); 1401 | t.true ( !isMatch ( '+(a|b[)*', 'bbc' ) ); 1402 | 1403 | t.true ( !isMatch ( '[a*(]*z', 'abcx' ) ); 1404 | t.true ( isMatch ( '[a*(]*z', 'abcz' ) ); 1405 | t.true ( !isMatch ( '[a*(]*z', 'bbc' ) ); 1406 | t.true ( isMatch ( '[a*(]*z', 'aaz' ) ); 1407 | t.true ( isMatch ( '[a*(]*z', 'aaaz' ) ); 1408 | 1409 | t.true ( !isMatch ( '[a*(]*)z', 'abcx' ) ); 1410 | t.true ( !isMatch ( '[a*(]*)z', 'abcz' ) ); 1411 | t.true ( !isMatch ( '[a*(]*)z', 'bbc' ) ); 1412 | 1413 | t.true ( !isMatch ( '+()c', 'abc' ) ); 1414 | t.true ( !isMatch ( '+()x', 'abc' ) ); 1415 | t.true ( isMatch ( '+(*)c', 'abc' ) ); 1416 | t.true ( !isMatch ( '+(*)x', 'abc' ) ); 1417 | t.true ( !isMatch ( 'no-file+(a|b)stuff', 'abc' ) ); 1418 | t.true ( !isMatch ( 'no-file+(a*(c)|b)stuff', 'abc' ) ); 1419 | 1420 | t.true ( isMatch ( 'a+(b|c)d', 'abd' ) ); 1421 | t.true ( isMatch ( 'a+(b|c)d', 'acd' ) ); 1422 | 1423 | t.true ( !isMatch ( 'a+(b|c)d', 'abc' ) ); 1424 | 1425 | // t.true ( isMatch ( 'a!(b|B)', 'abd' ) ); 1426 | // t.true ( isMatch ( 'a!(@(b|B))', 'acd' ) ); 1427 | // t.true ( isMatch ( 'a!(@(b|B))', 'ac' ) ); 1428 | // t.true ( !isMatch ( 'a!(@(b|B))', 'ab' ) ); 1429 | 1430 | // t.true ( !isMatch ( 'a!(@(b|B))d', 'abc' ) ); 1431 | // t.true ( !isMatch ( 'a!(@(b|B))d', 'abd' ) ); 1432 | // t.true ( isMatch ( 'a!(@(b|B))d', 'acd' ) ); 1433 | 1434 | t.true ( isMatch ( 'a[b*(foo|bar)]d', 'abd' ) ); 1435 | t.true ( !isMatch ( 'a[b*(foo|bar)]d', 'abc' ) ); 1436 | t.true ( !isMatch ( 'a[b*(foo|bar)]d', 'acd' ) ); 1437 | 1438 | // t.true ( !isMatch ( 'para+([0-9])', 'para' ) ); 1439 | // t.true ( !isMatch ( 'para?([345]|99)1', 'para381' ) ); 1440 | // t.true ( !isMatch ( 'para*([0-9])', 'paragraph' ) ); 1441 | // t.true ( !isMatch ( 'para@(chute|graph)', 'paramour' ) ); 1442 | // t.true ( isMatch ( 'para*([0-9])', 'para' ) ); 1443 | // t.true ( isMatch ( 'para!(*.[0-9])', 'para.38' ) ); 1444 | // t.true ( isMatch ( 'para!(*.[00-09])', 'para.38' ) ); 1445 | // t.true ( isMatch ( 'para!(*.[0-9])', 'para.graph' ) ); 1446 | // t.true ( isMatch ( 'para*([0-9])', 'para13829383746592' ) ); 1447 | // t.true ( isMatch ( 'para!(*.[0-9])', 'para39' ) ); 1448 | // t.true ( isMatch ( 'para+([0-9])', 'para987346523' ) ); 1449 | // t.true ( isMatch ( 'para?([345]|99)1', 'para991' ) ); 1450 | // t.true ( isMatch ( 'para!(*.[0-9])', 'paragraph' ) ); 1451 | // t.true ( isMatch ( 'para@(chute|graph)', 'paragraph' ) ); 1452 | 1453 | t.true ( !isMatch ( '*(a|b[)', 'foo' ) ); 1454 | t.true ( !isMatch ( '*(a|b[)', '(' ) ); 1455 | t.true ( !isMatch ( '*(a|b[)', ')' ) ); 1456 | t.true ( !isMatch ( '*(a|b[)', '|' ) ); 1457 | t.true ( isMatch ( '*(a|b)', 'a' ) ); 1458 | t.true ( isMatch ( '*(a|b)', 'b' ) ); 1459 | t.true ( isMatch ( '*(a|b\\[)', 'b[' ) ); 1460 | t.true ( isMatch ( '+(a|b\\[)', 'ab[' ) ); 1461 | t.true ( !isMatch ( '+(a|b\\[)', 'ab[cde' ) ); 1462 | t.true ( isMatch ( '+(a|b\\[)*', 'ab[cde' ) ); 1463 | 1464 | // t.true ( isMatch ( '*(a|b|f)*', 'foo' ) ); 1465 | // t.true ( isMatch ( '*(a|b|o)*', 'foo' ) ); 1466 | // t.true ( isMatch ( '*(a|b|f|o)', 'foo' ) ); 1467 | // t.true ( isMatch ( '\\*\\(a\\|b\\[\\)', '*(a|b[)' ) ); 1468 | // t.true ( !isMatch ( '*(a|b)', 'foo' ) ); 1469 | // t.true ( !isMatch ( '*(a|b\\[)', 'foo' ) ); 1470 | // t.true ( isMatch ( '*(a|b\\[)|f*', 'foo' ) ); 1471 | 1472 | // t.true ( isMatch ( '@(*).@(*)', 'moo.cow' ) ); 1473 | // t.true ( isMatch ( '*.@(a|b|@(ab|a*@(b))*@(c)d)', 'a.a' ) ); 1474 | // t.true ( isMatch ( '*.@(a|b|@(ab|a*@(b))*@(c)d)', 'a.b' ) ); 1475 | // t.true ( !isMatch ( '*.@(a|b|@(ab|a*@(b))*@(c)d)', 'a.c' ) ); 1476 | // t.true ( !isMatch ( '*.@(a|b|@(ab|a*@(b))*@(c)d)', 'a.c.d' ) ); 1477 | // t.true ( !isMatch ( '*.@(a|b|@(ab|a*@(b))*@(c)d)', 'c.c' ) ); 1478 | // t.true ( !isMatch ( '*.@(a|b|@(ab|a*@(b))*@(c)d)', 'a.' ) ); 1479 | // t.true ( !isMatch ( '*.@(a|b|@(ab|a*@(b))*@(c)d)', 'd.d' ) ); 1480 | // t.true ( !isMatch ( '*.@(a|b|@(ab|a*@(b))*@(c)d)', 'e.e' ) ); 1481 | // t.true ( !isMatch ( '*.@(a|b|@(ab|a*@(b))*@(c)d)', 'f.f' ) ); 1482 | // t.true ( isMatch ( '*.@(a|b|@(ab|a*@(b))*@(c)d)', 'a.abcd' ) ); 1483 | 1484 | // t.true ( !isMatch ( '!(*.a|*.b|*.c)', 'a.a' ) ); 1485 | // t.true ( !isMatch ( '!(*.a|*.b|*.c)', 'a.b' ) ); 1486 | // t.true ( !isMatch ( '!(*.a|*.b|*.c)', 'a.c' ) ); 1487 | // t.true ( isMatch ( '!(*.a|*.b|*.c)', 'a.c.d' ) ); 1488 | // t.true ( !isMatch ( '!(*.a|*.b|*.c)', 'c.c' ) ); 1489 | // t.true ( isMatch ( '!(*.a|*.b|*.c)', 'a.' ) ); 1490 | // t.true ( isMatch ( '!(*.a|*.b|*.c)', 'd.d' ) ); 1491 | // t.true ( isMatch ( '!(*.a|*.b|*.c)', 'e.e' ) ); 1492 | // t.true ( isMatch ( '!(*.a|*.b|*.c)', 'f.f' ) ); 1493 | // t.true ( isMatch ( '!(*.a|*.b|*.c)', 'a.abcd' ) ); 1494 | 1495 | t.true ( isMatch ( '!(*.[^a-c])', 'a.a' ) ); 1496 | t.true ( isMatch ( '!(*.[^a-c])', 'a.b' ) ); 1497 | t.true ( isMatch ( '!(*.[^a-c])', 'a.c' ) ); 1498 | t.true ( !isMatch ( '!(*.[^a-c])', 'a.c.d' ) ); 1499 | t.true ( isMatch ( '!(*.[^a-c])', 'c.c' ) ); 1500 | t.true ( isMatch ( '!(*.[^a-c])', 'a.' ) ); 1501 | t.true ( !isMatch ( '!(*.[^a-c])', 'd.d' ) ); 1502 | t.true ( !isMatch ( '!(*.[^a-c])', 'e.e' ) ); 1503 | t.true ( !isMatch ( '!(*.[^a-c])', 'f.f' ) ); 1504 | t.true ( isMatch ( '!(*.[^a-c])', 'a.abcd' ) ); 1505 | 1506 | // t.true ( !isMatch ( '!(*.[a-c])', 'a.a' ) ); 1507 | // t.true ( !isMatch ( '!(*.[a-c])', 'a.b' ) ); 1508 | // t.true ( !isMatch ( '!(*.[a-c])', 'a.c' ) ); 1509 | // t.true ( isMatch ( '!(*.[a-c])', 'a.c.d' ) ); 1510 | // t.true ( !isMatch ( '!(*.[a-c])', 'c.c' ) ); 1511 | // t.true ( isMatch ( '!(*.[a-c])', 'a.' ) ); 1512 | // t.true ( isMatch ( '!(*.[a-c])', 'd.d' ) ); 1513 | // t.true ( isMatch ( '!(*.[a-c])', 'e.e' ) ); 1514 | // t.true ( isMatch ( '!(*.[a-c])', 'f.f' ) ); 1515 | // t.true ( isMatch ( '!(*.[a-c])', 'a.abcd' ) ); 1516 | 1517 | t.true ( !isMatch ( '!(*.[a-c]*)', 'a.a' ) ); 1518 | t.true ( !isMatch ( '!(*.[a-c]*)', 'a.b' ) ); 1519 | t.true ( !isMatch ( '!(*.[a-c]*)', 'a.c' ) ); 1520 | t.true ( !isMatch ( '!(*.[a-c]*)', 'a.c.d' ) ); 1521 | t.true ( !isMatch ( '!(*.[a-c]*)', 'c.c' ) ); 1522 | t.true ( isMatch ( '!(*.[a-c]*)', 'a.' ) ); 1523 | t.true ( isMatch ( '!(*.[a-c]*)', 'd.d' ) ); 1524 | t.true ( isMatch ( '!(*.[a-c]*)', 'e.e' ) ); 1525 | t.true ( isMatch ( '!(*.[a-c]*)', 'f.f' ) ); 1526 | t.true ( !isMatch ( '!(*.[a-c]*)', 'a.abcd' ) ); 1527 | 1528 | // t.true ( !isMatch ( '*.!(a|b|c)', 'a.a' ) ); 1529 | // t.true ( !isMatch ( '*.!(a|b|c)', 'a.b' ) ); 1530 | // t.true ( !isMatch ( '*.!(a|b|c)', 'a.c' ) ); 1531 | // t.true ( isMatch ( '*.!(a|b|c)', 'a.c.d' ) ); 1532 | // t.true ( !isMatch ( '*.!(a|b|c)', 'c.c' ) ); 1533 | // t.true ( isMatch ( '*.!(a|b|c)', 'a.' ) ); 1534 | // t.true ( isMatch ( '*.!(a|b|c)', 'd.d' ) ); 1535 | // t.true ( isMatch ( '*.!(a|b|c)', 'e.e' ) ); 1536 | // t.true ( isMatch ( '*.!(a|b|c)', 'f.f' ) ); 1537 | // t.true ( isMatch ( '*.!(a|b|c)', 'a.abcd' ) ); 1538 | 1539 | t.true ( isMatch ( '*!(.a|.b|.c)', 'a.a' ) ); 1540 | t.true ( isMatch ( '*!(.a|.b|.c)', 'a.b' ) ); 1541 | t.true ( isMatch ( '*!(.a|.b|.c)', 'a.c' ) ); 1542 | t.true ( isMatch ( '*!(.a|.b|.c)', 'a.c.d' ) ); 1543 | t.true ( isMatch ( '*!(.a|.b|.c)', 'c.c' ) ); 1544 | t.true ( isMatch ( '*!(.a|.b|.c)', 'a.' ) ); 1545 | t.true ( isMatch ( '*!(.a|.b|.c)', 'd.d' ) ); 1546 | t.true ( isMatch ( '*!(.a|.b|.c)', 'e.e' ) ); 1547 | t.true ( isMatch ( '*!(.a|.b|.c)', 'f.f' ) ); 1548 | t.true ( isMatch ( '*!(.a|.b|.c)', 'a.abcd' ) ); 1549 | 1550 | t.true ( !isMatch ( '!(*.[a-c])*', 'a.a' ) ); 1551 | t.true ( !isMatch ( '!(*.[a-c])*', 'a.b' ) ); 1552 | t.true ( !isMatch ( '!(*.[a-c])*', 'a.c' ) ); 1553 | t.true ( !isMatch ( '!(*.[a-c])*', 'a.c.d' ) ); 1554 | t.true ( !isMatch ( '!(*.[a-c])*', 'c.c' ) ); 1555 | t.true ( isMatch ( '!(*.[a-c])*', 'a.' ) ); 1556 | t.true ( isMatch ( '!(*.[a-c])*', 'd.d' ) ); 1557 | t.true ( isMatch ( '!(*.[a-c])*', 'e.e' ) ); 1558 | t.true ( isMatch ( '!(*.[a-c])*', 'f.f' ) ); 1559 | t.true ( !isMatch ( '!(*.[a-c])*', 'a.abcd' ) ); 1560 | 1561 | t.true ( isMatch ( '*!(.a|.b|.c)*', 'a.a' ) ); 1562 | t.true ( isMatch ( '*!(.a|.b|.c)*', 'a.b' ) ); 1563 | t.true ( isMatch ( '*!(.a|.b|.c)*', 'a.c' ) ); 1564 | t.true ( isMatch ( '*!(.a|.b|.c)*', 'a.c.d' ) ); 1565 | t.true ( isMatch ( '*!(.a|.b|.c)*', 'c.c' ) ); 1566 | t.true ( isMatch ( '*!(.a|.b|.c)*', 'a.' ) ); 1567 | t.true ( isMatch ( '*!(.a|.b|.c)*', 'd.d' ) ); 1568 | t.true ( isMatch ( '*!(.a|.b|.c)*', 'e.e' ) ); 1569 | t.true ( isMatch ( '*!(.a|.b|.c)*', 'f.f' ) ); 1570 | t.true ( isMatch ( '*!(.a|.b|.c)*', 'a.abcd' ) ); 1571 | 1572 | t.true ( !isMatch ( '*.!(a|b|c)*', 'a.a' ) ); 1573 | t.true ( !isMatch ( '*.!(a|b|c)*', 'a.b' ) ); 1574 | t.true ( !isMatch ( '*.!(a|b|c)*', 'a.c' ) ); 1575 | t.true ( isMatch ( '*.!(a|b|c)*', 'a.c.d' ) ); 1576 | t.true ( !isMatch ( '*.!(a|b|c)*', 'c.c' ) ); 1577 | t.true ( isMatch ( '*.!(a|b|c)*', 'a.' ) ); 1578 | t.true ( isMatch ( '*.!(a|b|c)*', 'd.d' ) ); 1579 | t.true ( isMatch ( '*.!(a|b|c)*', 'e.e' ) ); 1580 | t.true ( isMatch ( '*.!(a|b|c)*', 'f.f' ) ); 1581 | t.true ( !isMatch ( '*.!(a|b|c)*', 'a.abcd' ) ); 1582 | 1583 | // t.true ( !isMatch ( '@()ef', 'def' ) ); 1584 | // t.true ( isMatch ( '@()ef', 'ef' ) ); 1585 | 1586 | // t.true ( !isMatch ( '()ef', 'def' ) ); 1587 | // t.true ( isMatch ( '()ef', 'ef' ) ); 1588 | 1589 | // t.true ( isMatch ( 'a\\\\\\(b', 'a\\(b' ) ); 1590 | // t.true ( isMatch ( 'a(b', 'a(b' ) ); 1591 | // t.true ( isMatch ( 'a\\(b', 'a(b' ) ); 1592 | // t.true ( !isMatch ( 'a(b', 'a((b' ) ); 1593 | // t.true ( !isMatch ( 'a(b', 'a((((b' ) ); 1594 | // t.true ( !isMatch ( 'a(b', 'ab' ) ); 1595 | 1596 | t.true ( isMatch ( 'a\\(b', 'a(b' ) ); 1597 | t.true ( !isMatch ( 'a\\(b', 'a((b' ) ); 1598 | t.true ( !isMatch ( 'a\\(b', 'a((((b' ) ); 1599 | t.true ( !isMatch ( 'a\\(b', 'ab' ) ); 1600 | 1601 | t.true ( isMatch ( 'a(*b', 'a(b' ) ); 1602 | t.true ( isMatch ( 'a\\(*b', 'a(ab' ) ); 1603 | t.true ( isMatch ( 'a(*b', 'a((b' ) ); 1604 | t.true ( isMatch ( 'a(*b', 'a((((b' ) ); 1605 | t.true ( !isMatch ( 'a(*b', 'ab' ) ); 1606 | 1607 | t.true ( isMatch ( 'a\\(b', 'a(b' ) ); 1608 | t.true ( isMatch ( 'a\\(\\(b', 'a((b' ) ); 1609 | t.true ( isMatch ( 'a\\(\\(\\(\\(b', 'a((((b' ) ); 1610 | 1611 | t.true ( !isMatch ( 'a\\\\(b', 'a(b' ) ); 1612 | t.true ( !isMatch ( 'a\\\\(b', 'a((b' ) ); 1613 | t.true ( !isMatch ( 'a\\\\(b', 'a((((b' ) ); 1614 | t.true ( !isMatch ( 'a\\\\(b', 'ab' ) ); 1615 | 1616 | t.true ( !isMatch ( 'a\\\\b', 'a/b' ) ); 1617 | t.true ( !isMatch ( 'a\\\\b', 'ab' ) ); 1618 | 1619 | }); 1620 | 1621 | // Tests adapted from "glob-match": https://github.com/devongovett/glob-match 1622 | // License: https://github.com/devongovett/glob-match/blob/main/LICENSE 1623 | 1624 | it ( 'basic', t => { 1625 | 1626 | t.true ( isMatch ( "abc", "abc" ) ); 1627 | t.true ( isMatch ( "*", "abc" ) ); 1628 | t.true ( isMatch ( "*", "" ) ); 1629 | t.true ( isMatch ( "**", "" ) ); 1630 | t.true ( isMatch ( "*c", "abc" ) ); 1631 | t.true ( !isMatch ( "*b", "abc" ) ); 1632 | t.true ( isMatch ( "a*", "abc" ) ); 1633 | t.true ( !isMatch ( "b*", "abc" ) ); 1634 | t.true ( isMatch ( "a*", "a" ) ); 1635 | t.true ( isMatch ( "*a", "a" ) ); 1636 | t.true ( isMatch ( "a*b*c*d*e*", "axbxcxdxe" ) ); 1637 | t.true ( isMatch ( "a*b*c*d*e*", "axbxcxdxexxx" ) ); 1638 | t.true ( isMatch ( "a*b?c*x", "abxbbxdbxebxczzx" ) ); 1639 | t.true ( !isMatch ( "a*b?c*x", "abxbbxdbxebxczzy" ) ); 1640 | 1641 | t.true ( isMatch ( "a/*/test", "a/foo/test" ) ); 1642 | t.true ( !isMatch ( "a/*/test", "a/foo/bar/test" ) ); 1643 | t.true ( isMatch ( "a/**/test", "a/foo/test" ) ); 1644 | t.true ( isMatch ( "a/**/test", "a/foo/bar/test" ) ); 1645 | t.true ( isMatch ( "a/**/b/c", "a/foo/bar/b/c" ) ); 1646 | t.true ( isMatch ( "a\\*b", "a*b" ) ); 1647 | t.true ( !isMatch ( "a\\*b", "axb" ) ); 1648 | 1649 | t.true ( isMatch ( "[abc]", "a" ) ); 1650 | t.true ( isMatch ( "[abc]", "b" ) ); 1651 | t.true ( isMatch ( "[abc]", "c" ) ); 1652 | t.true ( !isMatch ( "[abc]", "d" ) ); 1653 | t.true ( isMatch ( "x[abc]x", "xax" ) ); 1654 | t.true ( isMatch ( "x[abc]x", "xbx" ) ); 1655 | t.true ( isMatch ( "x[abc]x", "xcx" ) ); 1656 | t.true ( !isMatch ( "x[abc]x", "xdx" ) ); 1657 | t.true ( !isMatch ( "x[abc]x", "xay" ) ); 1658 | t.true ( isMatch ( "[?]", "?" ) ); 1659 | t.true ( !isMatch ( "[?]", "a" ) ); 1660 | t.true ( isMatch ( "[*]", "*" ) ); 1661 | t.true ( !isMatch ( "[*]", "a" ) ); 1662 | 1663 | t.true ( isMatch ( "[a-cx]", "a" ) ); 1664 | t.true ( isMatch ( "[a-cx]", "b" ) ); 1665 | t.true ( isMatch ( "[a-cx]", "c" ) ); 1666 | t.true ( !isMatch ( "[a-cx]", "d" ) ); 1667 | t.true ( isMatch ( "[a-cx]", "x" ) ); 1668 | 1669 | t.true ( !isMatch ( "[^abc]", "a" ) ); 1670 | t.true ( !isMatch ( "[^abc]", "b" ) ); 1671 | t.true ( !isMatch ( "[^abc]", "c" ) ); 1672 | t.true ( isMatch ( "[^abc]", "d" ) ); 1673 | t.true ( !isMatch ( "[!abc]", "a" ) ); 1674 | t.true ( !isMatch ( "[!abc]", "b" ) ); 1675 | t.true ( !isMatch ( "[!abc]", "c" ) ); 1676 | t.true ( isMatch ( "[!abc]", "d" ) ); 1677 | t.true ( isMatch ( "[\\!]", "!" ) ); 1678 | 1679 | t.true ( isMatch ( "a*b*[cy]*d*e*", "axbxcxdxexxx" ) ); 1680 | t.true ( isMatch ( "a*b*[cy]*d*e*", "axbxyxdxexxx" ) ); 1681 | t.true ( isMatch ( "a*b*[cy]*d*e*", "axbxxxyxdxexxx" ) ); 1682 | 1683 | t.true ( isMatch ( "test.{jpg,png}", "test.jpg" ) ); 1684 | t.true ( isMatch ( "test.{jpg,png}", "test.png" ) ); 1685 | t.true ( isMatch ( "test.{j*g,p*g}", "test.jpg" ) ); 1686 | t.true ( isMatch ( "test.{j*g,p*g}", "test.jpxxxg" ) ); 1687 | t.true ( isMatch ( "test.{j*g,p*g}", "test.jxg" ) ); 1688 | t.true ( !isMatch ( "test.{j*g,p*g}", "test.jnt" ) ); 1689 | t.true ( isMatch ( "test.{j*g,j*c}", "test.jnc" ) ); 1690 | t.true ( isMatch ( "test.{jpg,p*g}", "test.png" ) ); 1691 | t.true ( isMatch ( "test.{jpg,p*g}", "test.pxg" ) ); 1692 | t.true ( !isMatch ( "test.{jpg,p*g}", "test.pnt" ) ); 1693 | t.true ( isMatch ( "test.{jpeg,png}", "test.jpeg" ) ); 1694 | t.true ( !isMatch ( "test.{jpeg,png}", "test.jpg" ) ); 1695 | t.true ( isMatch ( "test.{jpeg,png}", "test.png" ) ); 1696 | t.true ( isMatch ( "test.{jp\\,g,png}", "test.jp,g" ) ); 1697 | t.true ( !isMatch ( "test.{jp\\,g,png}", "test.jxg" ) ); 1698 | t.true ( isMatch ( "test/{foo,bar}/baz", "test/foo/baz" ) ); 1699 | t.true ( isMatch ( "test/{foo,bar}/baz", "test/bar/baz" ) ); 1700 | t.true ( !isMatch ( "test/{foo,bar}/baz", "test/baz/baz" ) ); 1701 | t.true ( isMatch ( "test/{foo*,bar*}/baz", "test/foooooo/baz" ) ); 1702 | t.true ( isMatch ( "test/{foo*,bar*}/baz", "test/barrrrr/baz" ) ); 1703 | t.true ( isMatch ( "test/{*foo,*bar}/baz", "test/xxxxfoo/baz" ) ); 1704 | t.true ( isMatch ( "test/{*foo,*bar}/baz", "test/xxxxbar/baz" ) ); 1705 | t.true ( isMatch ( "test/{foo/**,bar}/baz", "test/bar/baz" ) ); 1706 | t.true ( !isMatch ( "test/{foo/**,bar}/baz", "test/bar/test/baz" ) ); 1707 | 1708 | t.true ( !isMatch ( "*.txt", "some/big/path/to/the/needle.txt" ) ); 1709 | t.true ( isMatch ( "some/**/needle.{js,tsx,mdx,ts,jsx,txt}", "some/a/bigger/path/to/the/crazy/needle.txt" ) ); 1710 | t.true ( isMatch ( "some/**/{a,b,c}/**/needle.txt", "some/foo/a/bigger/path/to/the/crazy/needle.txt" ) ); 1711 | t.true ( !isMatch ( "some/**/{a,b,c}/**/needle.txt", "some/foo/d/bigger/path/to/the/crazy/needle.txt" ) ); 1712 | 1713 | t.true ( isMatch ( "a/{a{a,b},b}", "a/aa" ) ); 1714 | t.true ( isMatch ( "a/{a{a,b},b}", "a/ab" ) ); 1715 | t.true ( !isMatch ( "a/{a{a,b},b}", "a/ac" ) ); 1716 | t.true ( isMatch ( "a/{a{a,b},b}", "a/b" ) ); 1717 | t.true ( !isMatch ( "a/{a{a,b},b}", "a/c" ) ); 1718 | t.true ( isMatch ( "a/{b,c[}]*}", "a/b" ) ); 1719 | t.true ( isMatch ( "a/{b,c[}]*}", "a/c}xx" ) ); 1720 | 1721 | }); 1722 | 1723 | it ( 'bash', t => { 1724 | 1725 | t.true ( !isMatch ( "a*", "*" ) ); 1726 | t.true ( !isMatch ( "a*", "**" ) ); 1727 | t.true ( !isMatch ( "a*", "\\*" ) ); 1728 | t.true ( !isMatch ( "a*", "a/*" ) ); 1729 | t.true ( !isMatch ( "a*", "b" ) ); 1730 | t.true ( !isMatch ( "a*", "bc" ) ); 1731 | t.true ( !isMatch ( "a*", "bcd" ) ); 1732 | t.true ( !isMatch ( "a*", "bdir/" ) ); 1733 | t.true ( !isMatch ( "a*", "Beware" ) ); 1734 | t.true ( isMatch ( "a*", "a" ) ); 1735 | t.true ( isMatch ( "a*", "ab" ) ); 1736 | t.true ( isMatch ( "a*", "abc" ) ); 1737 | 1738 | t.true ( !isMatch ( "\\a*", "*" ) ); 1739 | t.true ( !isMatch ( "\\a*", "**" ) ); 1740 | t.true ( !isMatch ( "\\a*", "\\*" ) ); 1741 | 1742 | t.true ( isMatch ( "\\a*", "a" ) ); 1743 | t.true ( !isMatch ( "\\a*", "a/*" ) ); 1744 | t.true ( isMatch ( "\\a*", "abc" ) ); 1745 | t.true ( isMatch ( "\\a*", "abd" ) ); 1746 | t.true ( isMatch ( "\\a*", "abe" ) ); 1747 | t.true ( !isMatch ( "\\a*", "b" ) ); 1748 | t.true ( !isMatch ( "\\a*", "bb" ) ); 1749 | t.true ( !isMatch ( "\\a*", "bcd" ) ); 1750 | t.true ( !isMatch ( "\\a*", "bdir/" ) ); 1751 | t.true ( !isMatch ( "\\a*", "Beware" ) ); 1752 | t.true ( !isMatch ( "\\a*", "c" ) ); 1753 | t.true ( !isMatch ( "\\a*", "ca" ) ); 1754 | t.true ( !isMatch ( "\\a*", "cb" ) ); 1755 | t.true ( !isMatch ( "\\a*", "d" ) ); 1756 | t.true ( !isMatch ( "\\a*", "dd" ) ); 1757 | t.true ( !isMatch ( "\\a*", "de" ) ); 1758 | 1759 | }); 1760 | 1761 | it ( 'bash_directories', t => { 1762 | 1763 | t.true ( !isMatch ( "b*/", "*" ) ); 1764 | t.true ( !isMatch ( "b*/", "**" ) ); 1765 | t.true ( !isMatch ( "b*/", "\\*" ) ); 1766 | t.true ( !isMatch ( "b*/", "a" ) ); 1767 | t.true ( !isMatch ( "b*/", "a/*" ) ); 1768 | t.true ( !isMatch ( "b*/", "abc" ) ); 1769 | t.true ( !isMatch ( "b*/", "abd" ) ); 1770 | t.true ( !isMatch ( "b*/", "abe" ) ); 1771 | t.true ( !isMatch ( "b*/", "b" ) ); 1772 | t.true ( !isMatch ( "b*/", "bb" ) ); 1773 | t.true ( !isMatch ( "b*/", "bcd" ) ); 1774 | t.true ( isMatch ( "b*/", "bdir/" ) ); 1775 | t.true ( !isMatch ( "b*/", "Beware" ) ); 1776 | t.true ( !isMatch ( "b*/", "c" ) ); 1777 | t.true ( !isMatch ( "b*/", "ca" ) ); 1778 | t.true ( !isMatch ( "b*/", "cb" ) ); 1779 | t.true ( !isMatch ( "b*/", "d" ) ); 1780 | t.true ( !isMatch ( "b*/", "dd" ) ); 1781 | t.true ( !isMatch ( "b*/", "de" ) ); 1782 | 1783 | }); 1784 | 1785 | it ( 'bash_escaping', t => { 1786 | 1787 | t.true ( !isMatch ( "\\^", "*" ) ); 1788 | t.true ( !isMatch ( "\\^", "**" ) ); 1789 | t.true ( !isMatch ( "\\^", "\\*" ) ); 1790 | t.true ( !isMatch ( "\\^", "a" ) ); 1791 | t.true ( !isMatch ( "\\^", "a/*" ) ); 1792 | t.true ( !isMatch ( "\\^", "abc" ) ); 1793 | t.true ( !isMatch ( "\\^", "abd" ) ); 1794 | t.true ( !isMatch ( "\\^", "abe" ) ); 1795 | t.true ( !isMatch ( "\\^", "b" ) ); 1796 | t.true ( !isMatch ( "\\^", "bb" ) ); 1797 | t.true ( !isMatch ( "\\^", "bcd" ) ); 1798 | t.true ( !isMatch ( "\\^", "bdir/" ) ); 1799 | t.true ( !isMatch ( "\\^", "Beware" ) ); 1800 | t.true ( !isMatch ( "\\^", "c" ) ); 1801 | t.true ( !isMatch ( "\\^", "ca" ) ); 1802 | t.true ( !isMatch ( "\\^", "cb" ) ); 1803 | t.true ( !isMatch ( "\\^", "d" ) ); 1804 | t.true ( !isMatch ( "\\^", "dd" ) ); 1805 | t.true ( !isMatch ( "\\^", "de" ) ); 1806 | 1807 | t.true ( isMatch ( "\\*", "*" ) ); 1808 | t.true ( !isMatch ( "\\*", "\\*" ) ); // Why would this match? https://github.com/micromatch/picomatch/issues/117 1809 | t.true ( !isMatch ( "\\*", "**" ) ); 1810 | t.true ( !isMatch ( "\\*", "a" ) ); 1811 | t.true ( !isMatch ( "\\*", "a/*" ) ); 1812 | t.true ( !isMatch ( "\\*", "abc" ) ); 1813 | t.true ( !isMatch ( "\\*", "abd" ) ); 1814 | t.true ( !isMatch ( "\\*", "abe" ) ); 1815 | t.true ( !isMatch ( "\\*", "b" ) ); 1816 | t.true ( !isMatch ( "\\*", "bb" ) ); 1817 | t.true ( !isMatch ( "\\*", "bcd" ) ); 1818 | t.true ( !isMatch ( "\\*", "bdir/" ) ); 1819 | t.true ( !isMatch ( "\\*", "Beware" ) ); 1820 | t.true ( !isMatch ( "\\*", "c" ) ); 1821 | t.true ( !isMatch ( "\\*", "ca" ) ); 1822 | t.true ( !isMatch ( "\\*", "cb" ) ); 1823 | t.true ( !isMatch ( "\\*", "d" ) ); 1824 | t.true ( !isMatch ( "\\*", "dd" ) ); 1825 | t.true ( !isMatch ( "\\*", "de" ) ); 1826 | 1827 | t.true ( !isMatch ( "a\\*", "*" ) ); 1828 | t.true ( !isMatch ( "a\\*", "**" ) ); 1829 | t.true ( !isMatch ( "a\\*", "\\*" ) ); 1830 | t.true ( !isMatch ( "a\\*", "a" ) ); 1831 | t.true ( !isMatch ( "a\\*", "a/*" ) ); 1832 | t.true ( !isMatch ( "a\\*", "abc" ) ); 1833 | t.true ( !isMatch ( "a\\*", "abd" ) ); 1834 | t.true ( !isMatch ( "a\\*", "abe" ) ); 1835 | t.true ( !isMatch ( "a\\*", "b" ) ); 1836 | t.true ( !isMatch ( "a\\*", "bb" ) ); 1837 | t.true ( !isMatch ( "a\\*", "bcd" ) ); 1838 | t.true ( !isMatch ( "a\\*", "bdir/" ) ); 1839 | t.true ( !isMatch ( "a\\*", "Beware" ) ); 1840 | t.true ( !isMatch ( "a\\*", "c" ) ); 1841 | t.true ( !isMatch ( "a\\*", "ca" ) ); 1842 | t.true ( !isMatch ( "a\\*", "cb" ) ); 1843 | t.true ( !isMatch ( "a\\*", "d" ) ); 1844 | t.true ( !isMatch ( "a\\*", "dd" ) ); 1845 | t.true ( !isMatch ( "a\\*", "de" ) ); 1846 | 1847 | t.true ( isMatch ( "*q*", "aqa" ) ); 1848 | t.true ( isMatch ( "*q*", "aaqaa" ) ); 1849 | t.true ( !isMatch ( "*q*", "*" ) ); 1850 | t.true ( !isMatch ( "*q*", "**" ) ); 1851 | t.true ( !isMatch ( "*q*", "\\*" ) ); 1852 | t.true ( !isMatch ( "*q*", "a" ) ); 1853 | t.true ( !isMatch ( "*q*", "a/*" ) ); 1854 | t.true ( !isMatch ( "*q*", "abc" ) ); 1855 | t.true ( !isMatch ( "*q*", "abd" ) ); 1856 | t.true ( !isMatch ( "*q*", "abe" ) ); 1857 | t.true ( !isMatch ( "*q*", "b" ) ); 1858 | t.true ( !isMatch ( "*q*", "bb" ) ); 1859 | t.true ( !isMatch ( "*q*", "bcd" ) ); 1860 | t.true ( !isMatch ( "*q*", "bdir/" ) ); 1861 | t.true ( !isMatch ( "*q*", "Beware" ) ); 1862 | t.true ( !isMatch ( "*q*", "c" ) ); 1863 | t.true ( !isMatch ( "*q*", "ca" ) ); 1864 | t.true ( !isMatch ( "*q*", "cb" ) ); 1865 | t.true ( !isMatch ( "*q*", "d" ) ); 1866 | t.true ( !isMatch ( "*q*", "dd" ) ); 1867 | t.true ( !isMatch ( "*q*", "de" ) ); 1868 | 1869 | t.true ( isMatch ( "\\**", "*" ) ); 1870 | t.true ( isMatch ( "\\**", "**" ) ); 1871 | t.true ( !isMatch ( "\\**", "\\*" ) ); 1872 | t.true ( !isMatch ( "\\**", "a" ) ); 1873 | t.true ( !isMatch ( "\\**", "a/*" ) ); 1874 | t.true ( !isMatch ( "\\**", "abc" ) ); 1875 | t.true ( !isMatch ( "\\**", "abd" ) ); 1876 | t.true ( !isMatch ( "\\**", "abe" ) ); 1877 | t.true ( !isMatch ( "\\**", "b" ) ); 1878 | t.true ( !isMatch ( "\\**", "bb" ) ); 1879 | t.true ( !isMatch ( "\\**", "bcd" ) ); 1880 | t.true ( !isMatch ( "\\**", "bdir/" ) ); 1881 | t.true ( !isMatch ( "\\**", "Beware" ) ); 1882 | t.true ( !isMatch ( "\\**", "c" ) ); 1883 | t.true ( !isMatch ( "\\**", "ca" ) ); 1884 | t.true ( !isMatch ( "\\**", "cb" ) ); 1885 | t.true ( !isMatch ( "\\**", "d" ) ); 1886 | t.true ( !isMatch ( "\\**", "dd" ) ); 1887 | t.true ( !isMatch ( "\\**", "de" ) ); 1888 | 1889 | }); 1890 | 1891 | it ( 'bash_classes', t => { 1892 | 1893 | t.true ( !isMatch ( "a*[^c]", "*" ) ); 1894 | t.true ( !isMatch ( "a*[^c]", "**" ) ); 1895 | t.true ( !isMatch ( "a*[^c]", "\\*" ) ); 1896 | t.true ( !isMatch ( "a*[^c]", "a" ) ); 1897 | t.true ( !isMatch ( "a*[^c]", "a/*" ) ); 1898 | t.true ( !isMatch ( "a*[^c]", "abc" ) ); 1899 | t.true ( isMatch ( "a*[^c]", "abd" ) ); 1900 | t.true ( isMatch ( "a*[^c]", "abe" ) ); 1901 | t.true ( !isMatch ( "a*[^c]", "b" ) ); 1902 | t.true ( !isMatch ( "a*[^c]", "bb" ) ); 1903 | t.true ( !isMatch ( "a*[^c]", "bcd" ) ); 1904 | t.true ( !isMatch ( "a*[^c]", "bdir/" ) ); 1905 | t.true ( !isMatch ( "a*[^c]", "Beware" ) ); 1906 | t.true ( !isMatch ( "a*[^c]", "c" ) ); 1907 | t.true ( !isMatch ( "a*[^c]", "ca" ) ); 1908 | t.true ( !isMatch ( "a*[^c]", "cb" ) ); 1909 | t.true ( !isMatch ( "a*[^c]", "d" ) ); 1910 | t.true ( !isMatch ( "a*[^c]", "dd" ) ); 1911 | t.true ( !isMatch ( "a*[^c]", "de" ) ); 1912 | t.true ( !isMatch ( "a*[^c]", "baz" ) ); 1913 | t.true ( !isMatch ( "a*[^c]", "bzz" ) ); 1914 | t.true ( !isMatch ( "a*[^c]", "BZZ" ) ); 1915 | t.true ( !isMatch ( "a*[^c]", "beware" ) ); 1916 | t.true ( !isMatch ( "a*[^c]", "BewAre" ) ); 1917 | 1918 | t.true ( isMatch ( "a[X-]b", "a-b" ) ); 1919 | t.true ( isMatch ( "a[X-]b", "aXb" ) ); 1920 | 1921 | t.true ( !isMatch ( "[a-y]*[^c]", "*" ) ); 1922 | t.true ( isMatch ( "[a-y]*[^c]", "a*" ) ); 1923 | t.true ( !isMatch ( "[a-y]*[^c]", "**" ) ); 1924 | t.true ( !isMatch ( "[a-y]*[^c]", "\\*" ) ); 1925 | t.true ( !isMatch ( "[a-y]*[^c]", "a" ) ); 1926 | t.true ( isMatch ( "[a-y]*[^c]", "a123b" ) ); 1927 | t.true ( !isMatch ( "[a-y]*[^c]", "a123c" ) ); 1928 | t.true ( isMatch ( "[a-y]*[^c]", "ab" ) ); 1929 | t.true ( !isMatch ( "[a-y]*[^c]", "a/*" ) ); 1930 | t.true ( !isMatch ( "[a-y]*[^c]", "abc" ) ); 1931 | t.true ( isMatch ( "[a-y]*[^c]", "abd" ) ); 1932 | t.true ( isMatch ( "[a-y]*[^c]", "abe" ) ); 1933 | t.true ( !isMatch ( "[a-y]*[^c]", "b" ) ); 1934 | t.true ( isMatch ( "[a-y]*[^c]", "bd" ) ); 1935 | t.true ( isMatch ( "[a-y]*[^c]", "bb" ) ); 1936 | t.true ( isMatch ( "[a-y]*[^c]", "bcd" ) ); 1937 | t.true ( isMatch ( "[a-y]*[^c]", "bdir/" ) ); 1938 | t.true ( !isMatch ( "[a-y]*[^c]", "Beware" ) ); 1939 | t.true ( !isMatch ( "[a-y]*[^c]", "c" ) ); 1940 | t.true ( isMatch ( "[a-y]*[^c]", "ca" ) ); 1941 | t.true ( isMatch ( "[a-y]*[^c]", "cb" ) ); 1942 | t.true ( !isMatch ( "[a-y]*[^c]", "d" ) ); 1943 | t.true ( isMatch ( "[a-y]*[^c]", "dd" ) ); 1944 | t.true ( isMatch ( "[a-y]*[^c]", "dd" ) ); 1945 | t.true ( isMatch ( "[a-y]*[^c]", "dd" ) ); 1946 | t.true ( isMatch ( "[a-y]*[^c]", "de" ) ); 1947 | t.true ( isMatch ( "[a-y]*[^c]", "baz" ) ); 1948 | t.true ( isMatch ( "[a-y]*[^c]", "bzz" ) ); 1949 | t.true ( isMatch ( "[a-y]*[^c]", "bzz" ) ); 1950 | t.true ( !isMatch ( "bzz", "[a-y]*[^c]" ) ); 1951 | t.true ( !isMatch ( "[a-y]*[^c]", "BZZ" ) ); 1952 | t.true ( isMatch ( "[a-y]*[^c]", "beware" ) ); 1953 | t.true ( !isMatch ( "[a-y]*[^c]", "BewAre" ) ); 1954 | 1955 | t.true ( isMatch ( "a\\*b/*", "a*b/ooo" ) ); 1956 | t.true ( isMatch ( "a\\*?/*", "a*b/ooo" ) ); 1957 | 1958 | t.true ( !isMatch ( "a[b]c", "*" ) ); 1959 | t.true ( !isMatch ( "a[b]c", "**" ) ); 1960 | t.true ( !isMatch ( "a[b]c", "\\*" ) ); 1961 | t.true ( !isMatch ( "a[b]c", "a" ) ); 1962 | t.true ( !isMatch ( "a[b]c", "a/*" ) ); 1963 | t.true ( isMatch ( "a[b]c", "abc" ) ); 1964 | t.true ( !isMatch ( "a[b]c", "abd" ) ); 1965 | t.true ( !isMatch ( "a[b]c", "abe" ) ); 1966 | t.true ( !isMatch ( "a[b]c", "b" ) ); 1967 | t.true ( !isMatch ( "a[b]c", "bb" ) ); 1968 | t.true ( !isMatch ( "a[b]c", "bcd" ) ); 1969 | t.true ( !isMatch ( "a[b]c", "bdir/" ) ); 1970 | t.true ( !isMatch ( "a[b]c", "Beware" ) ); 1971 | t.true ( !isMatch ( "a[b]c", "c" ) ); 1972 | t.true ( !isMatch ( "a[b]c", "ca" ) ); 1973 | t.true ( !isMatch ( "a[b]c", "cb" ) ); 1974 | t.true ( !isMatch ( "a[b]c", "d" ) ); 1975 | t.true ( !isMatch ( "a[b]c", "dd" ) ); 1976 | t.true ( !isMatch ( "a[b]c", "de" ) ); 1977 | t.true ( !isMatch ( "a[b]c", "baz" ) ); 1978 | t.true ( !isMatch ( "a[b]c", "bzz" ) ); 1979 | t.true ( !isMatch ( "a[b]c", "BZZ" ) ); 1980 | t.true ( !isMatch ( "a[b]c", "beware" ) ); 1981 | t.true ( !isMatch ( "a[b]c", "BewAre" ) ); 1982 | 1983 | t.true ( !isMatch ( "a[\"b\"]c", "*" ) ); 1984 | t.true ( !isMatch ( "a[\"b\"]c", "**" ) ); 1985 | t.true ( !isMatch ( "a[\"b\"]c", "\\*" ) ); 1986 | t.true ( !isMatch ( "a[\"b\"]c", "a" ) ); 1987 | t.true ( !isMatch ( "a[\"b\"]c", "a/*" ) ); 1988 | t.true ( isMatch ( "a[\"b\"]c", "abc" ) ); 1989 | t.true ( !isMatch ( "a[\"b\"]c", "abd" ) ); 1990 | t.true ( !isMatch ( "a[\"b\"]c", "abe" ) ); 1991 | t.true ( !isMatch ( "a[\"b\"]c", "b" ) ); 1992 | t.true ( !isMatch ( "a[\"b\"]c", "bb" ) ); 1993 | t.true ( !isMatch ( "a[\"b\"]c", "bcd" ) ); 1994 | t.true ( !isMatch ( "a[\"b\"]c", "bdir/" ) ); 1995 | t.true ( !isMatch ( "a[\"b\"]c", "Beware" ) ); 1996 | t.true ( !isMatch ( "a[\"b\"]c", "c" ) ); 1997 | t.true ( !isMatch ( "a[\"b\"]c", "ca" ) ); 1998 | t.true ( !isMatch ( "a[\"b\"]c", "cb" ) ); 1999 | t.true ( !isMatch ( "a[\"b\"]c", "d" ) ); 2000 | t.true ( !isMatch ( "a[\"b\"]c", "dd" ) ); 2001 | t.true ( !isMatch ( "a[\"b\"]c", "de" ) ); 2002 | t.true ( !isMatch ( "a[\"b\"]c", "baz" ) ); 2003 | t.true ( !isMatch ( "a[\"b\"]c", "bzz" ) ); 2004 | t.true ( !isMatch ( "a[\"b\"]c", "BZZ" ) ); 2005 | t.true ( !isMatch ( "a[\"b\"]c", "beware" ) ); 2006 | t.true ( !isMatch ( "a[\"b\"]c", "BewAre" ) ); 2007 | 2008 | t.true ( !isMatch ( "a[\\\\b]c", "*" ) ); 2009 | t.true ( !isMatch ( "a[\\\\b]c", "**" ) ); 2010 | t.true ( !isMatch ( "a[\\\\b]c", "\\*" ) ); 2011 | t.true ( !isMatch ( "a[\\\\b]c", "a" ) ); 2012 | t.true ( !isMatch ( "a[\\\\b]c", "a/*" ) ); 2013 | t.true ( isMatch ( "a[\\\\b]c", "abc" ) ); 2014 | t.true ( !isMatch ( "a[\\\\b]c", "abd" ) ); 2015 | t.true ( !isMatch ( "a[\\\\b]c", "abe" ) ); 2016 | t.true ( !isMatch ( "a[\\\\b]c", "b" ) ); 2017 | t.true ( !isMatch ( "a[\\\\b]c", "bb" ) ); 2018 | t.true ( !isMatch ( "a[\\\\b]c", "bcd" ) ); 2019 | t.true ( !isMatch ( "a[\\\\b]c", "bdir/" ) ); 2020 | t.true ( !isMatch ( "a[\\\\b]c", "Beware" ) ); 2021 | t.true ( !isMatch ( "a[\\\\b]c", "c" ) ); 2022 | t.true ( !isMatch ( "a[\\\\b]c", "ca" ) ); 2023 | t.true ( !isMatch ( "a[\\\\b]c", "cb" ) ); 2024 | t.true ( !isMatch ( "a[\\\\b]c", "d" ) ); 2025 | t.true ( !isMatch ( "a[\\\\b]c", "dd" ) ); 2026 | t.true ( !isMatch ( "a[\\\\b]c", "de" ) ); 2027 | t.true ( !isMatch ( "a[\\\\b]c", "baz" ) ); 2028 | t.true ( !isMatch ( "a[\\\\b]c", "bzz" ) ); 2029 | t.true ( !isMatch ( "a[\\\\b]c", "BZZ" ) ); 2030 | t.true ( !isMatch ( "a[\\\\b]c", "beware" ) ); 2031 | t.true ( !isMatch ( "a[\\\\b]c", "BewAre" ) ); 2032 | 2033 | t.true ( !isMatch ( "a[\\b]c", "*" ) ); 2034 | t.true ( !isMatch ( "a[\\b]c", "**" ) ); 2035 | t.true ( !isMatch ( "a[\\b]c", "\\*" ) ); 2036 | t.true ( !isMatch ( "a[\\b]c", "a" ) ); 2037 | t.true ( !isMatch ( "a[\\b]c", "a/*" ) ); 2038 | t.true ( !isMatch ( "a[\\b]c", "abc" ) ); 2039 | t.true ( !isMatch ( "a[\\b]c", "abd" ) ); 2040 | t.true ( !isMatch ( "a[\\b]c", "abe" ) ); 2041 | t.true ( !isMatch ( "a[\\b]c", "b" ) ); 2042 | t.true ( !isMatch ( "a[\\b]c", "bb" ) ); 2043 | t.true ( !isMatch ( "a[\\b]c", "bcd" ) ); 2044 | t.true ( !isMatch ( "a[\\b]c", "bdir/" ) ); 2045 | t.true ( !isMatch ( "a[\\b]c", "Beware" ) ); 2046 | t.true ( !isMatch ( "a[\\b]c", "c" ) ); 2047 | t.true ( !isMatch ( "a[\\b]c", "ca" ) ); 2048 | t.true ( !isMatch ( "a[\\b]c", "cb" ) ); 2049 | t.true ( !isMatch ( "a[\\b]c", "d" ) ); 2050 | t.true ( !isMatch ( "a[\\b]c", "dd" ) ); 2051 | t.true ( !isMatch ( "a[\\b]c", "de" ) ); 2052 | t.true ( !isMatch ( "a[\\b]c", "baz" ) ); 2053 | t.true ( !isMatch ( "a[\\b]c", "bzz" ) ); 2054 | t.true ( !isMatch ( "a[\\b]c", "BZZ" ) ); 2055 | t.true ( !isMatch ( "a[\\b]c", "beware" ) ); 2056 | t.true ( !isMatch ( "a[\\b]c", "BewAre" ) ); 2057 | 2058 | t.true ( !isMatch ( "a[b-d]c", "*" ) ); 2059 | t.true ( !isMatch ( "a[b-d]c", "**" ) ); 2060 | t.true ( !isMatch ( "a[b-d]c", "\\*" ) ); 2061 | t.true ( !isMatch ( "a[b-d]c", "a" ) ); 2062 | t.true ( !isMatch ( "a[b-d]c", "a/*" ) ); 2063 | t.true ( isMatch ( "a[b-d]c", "abc" ) ); 2064 | t.true ( !isMatch ( "a[b-d]c", "abd" ) ); 2065 | t.true ( !isMatch ( "a[b-d]c", "abe" ) ); 2066 | t.true ( !isMatch ( "a[b-d]c", "b" ) ); 2067 | t.true ( !isMatch ( "a[b-d]c", "bb" ) ); 2068 | t.true ( !isMatch ( "a[b-d]c", "bcd" ) ); 2069 | t.true ( !isMatch ( "a[b-d]c", "bdir/" ) ); 2070 | t.true ( !isMatch ( "a[b-d]c", "Beware" ) ); 2071 | t.true ( !isMatch ( "a[b-d]c", "c" ) ); 2072 | t.true ( !isMatch ( "a[b-d]c", "ca" ) ); 2073 | t.true ( !isMatch ( "a[b-d]c", "cb" ) ); 2074 | t.true ( !isMatch ( "a[b-d]c", "d" ) ); 2075 | t.true ( !isMatch ( "a[b-d]c", "dd" ) ); 2076 | t.true ( !isMatch ( "a[b-d]c", "de" ) ); 2077 | t.true ( !isMatch ( "a[b-d]c", "baz" ) ); 2078 | t.true ( !isMatch ( "a[b-d]c", "bzz" ) ); 2079 | t.true ( !isMatch ( "a[b-d]c", "BZZ" ) ); 2080 | t.true ( !isMatch ( "a[b-d]c", "beware" ) ); 2081 | t.true ( !isMatch ( "a[b-d]c", "BewAre" ) ); 2082 | 2083 | t.true ( !isMatch ( "a?c", "*" ) ); 2084 | t.true ( !isMatch ( "a?c", "**" ) ); 2085 | t.true ( !isMatch ( "a?c", "\\*" ) ); 2086 | t.true ( !isMatch ( "a?c", "a" ) ); 2087 | t.true ( !isMatch ( "a?c", "a/*" ) ); 2088 | t.true ( isMatch ( "a?c", "abc" ) ); 2089 | t.true ( !isMatch ( "a?c", "abd" ) ); 2090 | t.true ( !isMatch ( "a?c", "abe" ) ); 2091 | t.true ( !isMatch ( "a?c", "b" ) ); 2092 | t.true ( !isMatch ( "a?c", "bb" ) ); 2093 | t.true ( !isMatch ( "a?c", "bcd" ) ); 2094 | t.true ( !isMatch ( "a?c", "bdir/" ) ); 2095 | t.true ( !isMatch ( "a?c", "Beware" ) ); 2096 | t.true ( !isMatch ( "a?c", "c" ) ); 2097 | t.true ( !isMatch ( "a?c", "ca" ) ); 2098 | t.true ( !isMatch ( "a?c", "cb" ) ); 2099 | t.true ( !isMatch ( "a?c", "d" ) ); 2100 | t.true ( !isMatch ( "a?c", "dd" ) ); 2101 | t.true ( !isMatch ( "a?c", "de" ) ); 2102 | t.true ( !isMatch ( "a?c", "baz" ) ); 2103 | t.true ( !isMatch ( "a?c", "bzz" ) ); 2104 | t.true ( !isMatch ( "a?c", "BZZ" ) ); 2105 | t.true ( !isMatch ( "a?c", "beware" ) ); 2106 | t.true ( !isMatch ( "a?c", "BewAre" ) ); 2107 | 2108 | t.true ( isMatch ( "*/man*/bash.*", "man/man1/bash.1" ) ); 2109 | 2110 | t.true ( isMatch ( "[^a-c]*", "*" ) ); 2111 | t.true ( isMatch ( "[^a-c]*", "**" ) ); 2112 | t.true ( !isMatch ( "[^a-c]*", "a" ) ); 2113 | t.true ( !isMatch ( "[^a-c]*", "a/*" ) ); 2114 | t.true ( !isMatch ( "[^a-c]*", "abc" ) ); 2115 | t.true ( !isMatch ( "[^a-c]*", "abd" ) ); 2116 | t.true ( !isMatch ( "[^a-c]*", "abe" ) ); 2117 | t.true ( !isMatch ( "[^a-c]*", "b" ) ); 2118 | t.true ( !isMatch ( "[^a-c]*", "bb" ) ); 2119 | t.true ( !isMatch ( "[^a-c]*", "bcd" ) ); 2120 | t.true ( !isMatch ( "[^a-c]*", "bdir/" ) ); 2121 | t.true ( isMatch ( "[^a-c]*", "Beware" ) ); 2122 | t.true ( isMatch ( "[^a-c]*", "Beware" ) ); 2123 | t.true ( !isMatch ( "[^a-c]*", "c" ) ); 2124 | t.true ( !isMatch ( "[^a-c]*", "ca" ) ); 2125 | t.true ( !isMatch ( "[^a-c]*", "cb" ) ); 2126 | t.true ( isMatch ( "[^a-c]*", "d" ) ); 2127 | t.true ( isMatch ( "[^a-c]*", "dd" ) ); 2128 | t.true ( isMatch ( "[^a-c]*", "de" ) ); 2129 | t.true ( !isMatch ( "[^a-c]*", "baz" ) ); 2130 | t.true ( !isMatch ( "[^a-c]*", "bzz" ) ); 2131 | t.true ( isMatch ( "[^a-c]*", "BZZ" ) ); 2132 | t.true ( !isMatch ( "[^a-c]*", "beware" ) ); 2133 | t.true ( isMatch ( "[^a-c]*", "BewAre" ) ); 2134 | 2135 | }); 2136 | 2137 | it ( 'bash_wildmatch', t => { 2138 | 2139 | t.true ( !isMatch ( "a[]-]b", "aab" ) ); 2140 | t.true ( !isMatch ( "[ten]", "ten" ) ); 2141 | t.true ( isMatch ( "]", "]" ) ); 2142 | // t.true ( isMatch ( "a[]-]b", "a-b" ) ); 2143 | // t.true ( isMatch ( "a[]-]b", "a]b" ) ); 2144 | // t.true ( isMatch ( "a[]]b", "a]b" ) ); 2145 | // t.true ( isMatch ( "a[\\]a\\-]b", "aab" ) ); 2146 | t.true ( isMatch ( "t[a-g]n", "ten" ) ); 2147 | t.true ( isMatch ( "t[^a-g]n", "ton" ) ); 2148 | 2149 | }); 2150 | 2151 | it ( 'bash_slashmatch', t => { 2152 | 2153 | t.true ( !isMatch ( "f[^eiu][^eiu][^eiu][^eiu][^eiu]r", "foo/bar" ) ); 2154 | t.true ( isMatch ( "foo[/]bar", "foo/bar" ) ); 2155 | t.true ( isMatch ( "f[^eiu][^eiu][^eiu][^eiu][^eiu]r", "foo-bar" ) ); 2156 | 2157 | }); 2158 | 2159 | it ( 'bash_extra_stars', t => { 2160 | 2161 | t.true ( !isMatch ( "a**c", "bbc" ) ); 2162 | t.true ( isMatch ( "a**c", "abc" ) ); 2163 | t.true ( !isMatch ( "a**c", "bbd" ) ); 2164 | 2165 | t.true ( !isMatch ( "a***c", "bbc" ) ); 2166 | t.true ( isMatch ( "a***c", "abc" ) ); 2167 | t.true ( !isMatch ( "a***c", "bbd" ) ); 2168 | 2169 | t.true ( !isMatch ( "a*****?c", "bbc" ) ); 2170 | t.true ( isMatch ( "a*****?c", "abc" ) ); 2171 | t.true ( !isMatch ( "a*****?c", "bbc" ) ); 2172 | 2173 | t.true ( isMatch ( "?*****??", "bbc" ) ); 2174 | t.true ( isMatch ( "?*****??", "abc" ) ); 2175 | 2176 | t.true ( isMatch ( "*****??", "bbc" ) ); 2177 | t.true ( isMatch ( "*****??", "abc" ) ); 2178 | 2179 | t.true ( isMatch ( "?*****?c", "bbc" ) ); 2180 | t.true ( isMatch ( "?*****?c", "abc" ) ); 2181 | 2182 | t.true ( isMatch ( "?***?****c", "bbc" ) ); 2183 | t.true ( isMatch ( "?***?****c", "abc" ) ); 2184 | t.true ( !isMatch ( "?***?****c", "bbd" ) ); 2185 | 2186 | t.true ( isMatch ( "?***?****?", "bbc" ) ); 2187 | t.true ( isMatch ( "?***?****?", "abc" ) ); 2188 | 2189 | t.true ( isMatch ( "?***?****", "bbc" ) ); 2190 | t.true ( isMatch ( "?***?****", "abc" ) ); 2191 | 2192 | t.true ( isMatch ( "*******c", "bbc" ) ); 2193 | t.true ( isMatch ( "*******c", "abc" ) ); 2194 | 2195 | t.true ( isMatch ( "*******?", "bbc" ) ); 2196 | t.true ( isMatch ( "*******?", "abc" ) ); 2197 | 2198 | t.true ( isMatch ( "a*cd**?**??k", "abcdecdhjk" ) ); 2199 | t.true ( isMatch ( "a**?**cd**?**??k", "abcdecdhjk" ) ); 2200 | t.true ( isMatch ( "a**?**cd**?**??k***", "abcdecdhjk" ) ); 2201 | t.true ( isMatch ( "a**?**cd**?**??***k", "abcdecdhjk" ) ); 2202 | t.true ( isMatch ( "a**?**cd**?**??***k**", "abcdecdhjk" ) ); 2203 | t.true ( isMatch ( "a****c**?**??*****", "abcdecdhjk" ) ); 2204 | 2205 | }); 2206 | 2207 | it ( 'stars', t => { 2208 | 2209 | t.true ( !isMatch ( "*.js", "a/b/c/z.js" ) ); 2210 | t.true ( !isMatch ( "*.js", "a/b/z.js" ) ); 2211 | t.true ( !isMatch ( "*.js", "a/z.js" ) ); 2212 | t.true ( isMatch ( "*.js", "z.js" ) ); 2213 | 2214 | t.true ( isMatch ( "*/*", "a/.ab" ) ); 2215 | t.true ( isMatch ( "*", ".ab" ) ); 2216 | 2217 | t.true ( isMatch ( "z*.js", "z.js" ) ); 2218 | t.true ( isMatch ( "*/*", "a/z" ) ); 2219 | t.true ( isMatch ( "*/z*.js", "a/z.js" ) ); 2220 | t.true ( isMatch ( "a/z*.js", "a/z.js" ) ); 2221 | 2222 | t.true ( isMatch ( "*", "ab" ) ); 2223 | t.true ( isMatch ( "*", "abc" ) ); 2224 | 2225 | t.true ( !isMatch ( "f*", "bar" ) ); 2226 | t.true ( !isMatch ( "*r", "foo" ) ); 2227 | t.true ( !isMatch ( "b*", "foo" ) ); 2228 | t.true ( !isMatch ( "*", "foo/bar" ) ); 2229 | t.true ( isMatch ( "*c", "abc" ) ); 2230 | t.true ( isMatch ( "a*", "abc" ) ); 2231 | t.true ( isMatch ( "a*c", "abc" ) ); 2232 | t.true ( isMatch ( "*r", "bar" ) ); 2233 | t.true ( isMatch ( "b*", "bar" ) ); 2234 | t.true ( isMatch ( "f*", "foo" ) ); 2235 | 2236 | t.true ( isMatch ( "*abc*", "one abc two" ) ); 2237 | t.true ( isMatch ( "a*b", "a b" ) ); 2238 | 2239 | t.true ( !isMatch ( "*a*", "foo" ) ); 2240 | t.true ( isMatch ( "*a*", "bar" ) ); 2241 | t.true ( isMatch ( "*abc*", "oneabctwo" ) ); 2242 | t.true ( !isMatch ( "*-bc-*", "a-b.c-d" ) ); 2243 | t.true ( isMatch ( "*-*.*-*", "a-b.c-d" ) ); 2244 | t.true ( isMatch ( "*-b*c-*", "a-b.c-d" ) ); 2245 | t.true ( isMatch ( "*-b.c-*", "a-b.c-d" ) ); 2246 | t.true ( isMatch ( "*.*", "a-b.c-d" ) ); 2247 | t.true ( isMatch ( "*.*-*", "a-b.c-d" ) ); 2248 | t.true ( isMatch ( "*.*-d", "a-b.c-d" ) ); 2249 | t.true ( isMatch ( "*.c-*", "a-b.c-d" ) ); 2250 | t.true ( isMatch ( "*b.*d", "a-b.c-d" ) ); 2251 | t.true ( isMatch ( "a*.c*", "a-b.c-d" ) ); 2252 | t.true ( isMatch ( "a-*.*-d", "a-b.c-d" ) ); 2253 | t.true ( isMatch ( "*.*", "a.b" ) ); 2254 | t.true ( isMatch ( "*.b", "a.b" ) ); 2255 | t.true ( isMatch ( "a.*", "a.b" ) ); 2256 | t.true ( isMatch ( "a.b", "a.b" ) ); 2257 | 2258 | t.true ( !isMatch ( "**-bc-**", "a-b.c-d" ) ); 2259 | t.true ( isMatch ( "**-**.**-**", "a-b.c-d" ) ); 2260 | t.true ( isMatch ( "**-b**c-**", "a-b.c-d" ) ); 2261 | t.true ( isMatch ( "**-b.c-**", "a-b.c-d" ) ); 2262 | t.true ( isMatch ( "**.**", "a-b.c-d" ) ); 2263 | t.true ( isMatch ( "**.**-**", "a-b.c-d" ) ); 2264 | t.true ( isMatch ( "**.**-d", "a-b.c-d" ) ); 2265 | t.true ( isMatch ( "**.c-**", "a-b.c-d" ) ); 2266 | t.true ( isMatch ( "**b.**d", "a-b.c-d" ) ); 2267 | t.true ( isMatch ( "a**.c**", "a-b.c-d" ) ); 2268 | t.true ( isMatch ( "a-**.**-d", "a-b.c-d" ) ); 2269 | t.true ( isMatch ( "**.**", "a.b" ) ); 2270 | t.true ( isMatch ( "**.b", "a.b" ) ); 2271 | t.true ( isMatch ( "a.**", "a.b" ) ); 2272 | t.true ( isMatch ( "a.b", "a.b" ) ); 2273 | 2274 | t.true ( isMatch ( "*/*", "/ab" ) ); 2275 | t.true ( isMatch ( ".", "." ) ); 2276 | t.true ( !isMatch ( "a/", "a/.b" ) ); 2277 | t.true ( isMatch ( "/*", "/ab" ) ); 2278 | t.true ( isMatch ( "/??", "/ab" ) ); 2279 | t.true ( isMatch ( "/?b", "/ab" ) ); 2280 | t.true ( isMatch ( "/*", "/cd" ) ); 2281 | t.true ( isMatch ( "a", "a" ) ); 2282 | t.true ( isMatch ( "a/.*", "a/.b" ) ); 2283 | t.true ( isMatch ( "?/?", "a/b" ) ); 2284 | t.true ( isMatch ( "a/**/j/**/z/*.md", "a/b/c/d/e/j/n/p/o/z/c.md" ) ); 2285 | t.true ( isMatch ( "a/**/z/*.md", "a/b/c/d/e/z/c.md" ) ); 2286 | t.true ( isMatch ( "a/b/c/*.md", "a/b/c/xyz.md" ) ); 2287 | t.true ( isMatch ( "a/b/c/*.md", "a/b/c/xyz.md" ) ); 2288 | t.true ( isMatch ( "a/*/z/.a", "a/b/z/.a" ) ); 2289 | t.true ( !isMatch ( "bz", "a/b/z/.a" ) ); 2290 | t.true ( isMatch ( "a/**/c/*.md", "a/bb.bb/aa/b.b/aa/c/xyz.md" ) ); 2291 | t.true ( isMatch ( "a/**/c/*.md", "a/bb.bb/aa/bb/aa/c/xyz.md" ) ); 2292 | t.true ( isMatch ( "a/*/c/*.md", "a/bb.bb/c/xyz.md" ) ); 2293 | t.true ( isMatch ( "a/*/c/*.md", "a/bb/c/xyz.md" ) ); 2294 | t.true ( isMatch ( "a/*/c/*.md", "a/bbbb/c/xyz.md" ) ); 2295 | t.true ( isMatch ( "*", "aaa" ) ); 2296 | t.true ( isMatch ( "*", "ab" ) ); 2297 | t.true ( isMatch ( "ab", "ab" ) ); 2298 | 2299 | t.true ( !isMatch ( "*/*/*", "aaa" ) ); 2300 | t.true ( !isMatch ( "*/*/*", "aaa/bb/aa/rr" ) ); 2301 | t.true ( !isMatch ( "aaa*", "aaa/bba/ccc" ) ); 2302 | t.true ( !isMatch ( "aaa**", "aaa/bba/ccc" ) ); 2303 | t.true ( !isMatch ( "aaa/*", "aaa/bba/ccc" ) ); 2304 | t.true ( !isMatch ( "aaa/*ccc", "aaa/bba/ccc" ) ); 2305 | t.true ( !isMatch ( "aaa/*z", "aaa/bba/ccc" ) ); 2306 | t.true ( !isMatch ( "*/*/*", "aaa/bbb" ) ); 2307 | t.true ( !isMatch ( "*/*jk*/*i", "ab/zzz/ejkl/hi" ) ); 2308 | t.true ( isMatch ( "*/*/*", "aaa/bba/ccc" ) ); 2309 | t.true ( isMatch ( "aaa/**", "aaa/bba/ccc" ) ); 2310 | t.true ( isMatch ( "aaa/*", "aaa/bbb" ) ); 2311 | t.true ( isMatch ( "*/*z*/*/*i", "ab/zzz/ejkl/hi" ) ); 2312 | t.true ( isMatch ( "*j*i", "abzzzejklhi" ) ); 2313 | 2314 | t.true ( isMatch ( "*", "a" ) ); 2315 | t.true ( isMatch ( "*", "b" ) ); 2316 | t.true ( !isMatch ( "*", "a/a" ) ); 2317 | t.true ( !isMatch ( "*", "a/a/a" ) ); 2318 | t.true ( !isMatch ( "*", "a/a/b" ) ); 2319 | t.true ( !isMatch ( "*", "a/a/a/a" ) ); 2320 | t.true ( !isMatch ( "*", "a/a/a/a/a" ) ); 2321 | 2322 | t.true ( !isMatch ( "*/*", "a" ) ); 2323 | t.true ( isMatch ( "*/*", "a/a" ) ); 2324 | t.true ( !isMatch ( "*/*", "a/a/a" ) ); 2325 | 2326 | t.true ( !isMatch ( "*/*/*", "a" ) ); 2327 | t.true ( !isMatch ( "*/*/*", "a/a" ) ); 2328 | t.true ( isMatch ( "*/*/*", "a/a/a" ) ); 2329 | t.true ( !isMatch ( "*/*/*", "a/a/a/a" ) ); 2330 | 2331 | t.true ( !isMatch ( "*/*/*/*", "a" ) ); 2332 | t.true ( !isMatch ( "*/*/*/*", "a/a" ) ); 2333 | t.true ( !isMatch ( "*/*/*/*", "a/a/a" ) ); 2334 | t.true ( isMatch ( "*/*/*/*", "a/a/a/a" ) ); 2335 | t.true ( !isMatch ( "*/*/*/*", "a/a/a/a/a" ) ); 2336 | 2337 | t.true ( !isMatch ( "*/*/*/*/*", "a" ) ); 2338 | t.true ( !isMatch ( "*/*/*/*/*", "a/a" ) ); 2339 | t.true ( !isMatch ( "*/*/*/*/*", "a/a/a" ) ); 2340 | t.true ( !isMatch ( "*/*/*/*/*", "a/a/b" ) ); 2341 | t.true ( !isMatch ( "*/*/*/*/*", "a/a/a/a" ) ); 2342 | t.true ( isMatch ( "*/*/*/*/*", "a/a/a/a/a" ) ); 2343 | t.true ( !isMatch ( "*/*/*/*/*", "a/a/a/a/a/a" ) ); 2344 | 2345 | t.true ( !isMatch ( "a/*", "a" ) ); 2346 | t.true ( isMatch ( "a/*", "a/a" ) ); 2347 | t.true ( !isMatch ( "a/*", "a/a/a" ) ); 2348 | t.true ( !isMatch ( "a/*", "a/a/a/a" ) ); 2349 | t.true ( !isMatch ( "a/*", "a/a/a/a/a" ) ); 2350 | 2351 | t.true ( !isMatch ( "a/*/*", "a" ) ); 2352 | t.true ( !isMatch ( "a/*/*", "a/a" ) ); 2353 | t.true ( isMatch ( "a/*/*", "a/a/a" ) ); 2354 | t.true ( !isMatch ( "a/*/*", "b/a/a" ) ); 2355 | t.true ( !isMatch ( "a/*/*", "a/a/a/a" ) ); 2356 | t.true ( !isMatch ( "a/*/*", "a/a/a/a/a" ) ); 2357 | 2358 | t.true ( !isMatch ( "a/*/*/*", "a" ) ); 2359 | t.true ( !isMatch ( "a/*/*/*", "a/a" ) ); 2360 | t.true ( !isMatch ( "a/*/*/*", "a/a/a" ) ); 2361 | t.true ( isMatch ( "a/*/*/*", "a/a/a/a" ) ); 2362 | t.true ( !isMatch ( "a/*/*/*", "a/a/a/a/a" ) ); 2363 | 2364 | t.true ( !isMatch ( "a/*/*/*/*", "a" ) ); 2365 | t.true ( !isMatch ( "a/*/*/*/*", "a/a" ) ); 2366 | t.true ( !isMatch ( "a/*/*/*/*", "a/a/a" ) ); 2367 | t.true ( !isMatch ( "a/*/*/*/*", "a/a/b" ) ); 2368 | t.true ( !isMatch ( "a/*/*/*/*", "a/a/a/a" ) ); 2369 | t.true ( isMatch ( "a/*/*/*/*", "a/a/a/a/a" ) ); 2370 | 2371 | t.true ( !isMatch ( "a/*/a", "a" ) ); 2372 | t.true ( !isMatch ( "a/*/a", "a/a" ) ); 2373 | t.true ( isMatch ( "a/*/a", "a/a/a" ) ); 2374 | t.true ( !isMatch ( "a/*/a", "a/a/b" ) ); 2375 | t.true ( !isMatch ( "a/*/a", "a/a/a/a" ) ); 2376 | t.true ( !isMatch ( "a/*/a", "a/a/a/a/a" ) ); 2377 | 2378 | t.true ( !isMatch ( "a/*/b", "a" ) ); 2379 | t.true ( !isMatch ( "a/*/b", "a/a" ) ); 2380 | t.true ( !isMatch ( "a/*/b", "a/a/a" ) ); 2381 | t.true ( isMatch ( "a/*/b", "a/a/b" ) ); 2382 | t.true ( !isMatch ( "a/*/b", "a/a/a/a" ) ); 2383 | t.true ( !isMatch ( "a/*/b", "a/a/a/a/a" ) ); 2384 | 2385 | t.true ( !isMatch ( "*/**/a", "a" ) ); 2386 | t.true ( !isMatch ( "*/**/a", "a/a/b" ) ); 2387 | t.true ( isMatch ( "*/**/a", "a/a" ) ); 2388 | t.true ( isMatch ( "*/**/a", "a/a/a" ) ); 2389 | t.true ( isMatch ( "*/**/a", "a/a/a/a" ) ); 2390 | t.true ( isMatch ( "*/**/a", "a/a/a/a/a" ) ); 2391 | 2392 | t.true ( !isMatch ( "*/", "a" ) ); 2393 | t.true ( !isMatch ( "*/*", "a" ) ); 2394 | t.true ( !isMatch ( "a/*", "a" ) ); 2395 | // t.true ( !isMatch ( "*/*", "a/" ) ); 2396 | // t.true ( !isMatch ( "a/*", "a/" ) ); 2397 | t.true ( !isMatch ( "*", "a/a" ) ); 2398 | t.true ( !isMatch ( "*/", "a/a" ) ); 2399 | t.true ( !isMatch ( "*/", "a/x/y" ) ); 2400 | t.true ( !isMatch ( "*/*", "a/x/y" ) ); 2401 | t.true ( !isMatch ( "a/*", "a/x/y" ) ); 2402 | t.true ( isMatch ( "*", "a/" ) ); 2403 | t.true ( isMatch ( "*", "a" ) ); 2404 | t.true ( isMatch ( "*/", "a/" ) ); 2405 | t.true ( isMatch ( "*{,/}", "a/" ) ); 2406 | t.true ( isMatch ( "*/*", "a/a" ) ); 2407 | t.true ( isMatch ( "a/*", "a/a" ) ); 2408 | 2409 | t.true ( !isMatch ( "a/**/*.txt", "a.txt" ) ); 2410 | t.true ( isMatch ( "a/**/*.txt", "a/x/y.txt" ) ); 2411 | t.true ( !isMatch ( "a/**/*.txt", "a/x/y/z" ) ); 2412 | 2413 | t.true ( !isMatch ( "a/*.txt", "a.txt" ) ); 2414 | t.true ( isMatch ( "a/*.txt", "a/b.txt" ) ); 2415 | t.true ( !isMatch ( "a/*.txt", "a/x/y.txt" ) ); 2416 | t.true ( !isMatch ( "a/*.txt", "a/x/y/z" ) ); 2417 | 2418 | t.true ( isMatch ( "a*.txt", "a.txt" ) ); 2419 | t.true ( !isMatch ( "a*.txt", "a/b.txt" ) ); 2420 | t.true ( !isMatch ( "a*.txt", "a/x/y.txt" ) ); 2421 | t.true ( !isMatch ( "a*.txt", "a/x/y/z" ) ); 2422 | 2423 | t.true ( isMatch ( "*.txt", "a.txt" ) ); 2424 | t.true ( !isMatch ( "*.txt", "a/b.txt" ) ); 2425 | t.true ( !isMatch ( "*.txt", "a/x/y.txt" ) ); 2426 | t.true ( !isMatch ( "*.txt", "a/x/y/z" ) ); 2427 | 2428 | t.true ( !isMatch ( "a*", "a/b" ) ); 2429 | t.true ( !isMatch ( "a/**/b", "a/a/bb" ) ); 2430 | t.true ( !isMatch ( "a/**/b", "a/bb" ) ); 2431 | 2432 | t.true ( !isMatch ( "*/**", "foo" ) ); 2433 | t.true ( !isMatch ( "**/", "foo/bar" ) ); 2434 | t.true ( !isMatch ( "**/*/", "foo/bar" ) ); 2435 | t.true ( !isMatch ( "*/*/", "foo/bar" ) ); 2436 | 2437 | t.true ( isMatch ( "**/..", "/home/foo/.." ) ); 2438 | t.true ( isMatch ( "**/a", "a" ) ); 2439 | t.true ( isMatch ( "**", "a/a" ) ); 2440 | t.true ( isMatch ( "a/**", "a/a" ) ); 2441 | t.true ( isMatch ( "a/**", "a/" ) ); 2442 | t.true ( isMatch ( "a/**", "a" ) ); 2443 | t.true ( !isMatch ( "**/", "a/a" ) ); 2444 | t.true ( isMatch ( "**/a/**", "a" ) ); 2445 | t.true ( isMatch ( "a/**", "a" ) ); 2446 | t.true ( !isMatch ( "**/", "a/a" ) ); 2447 | t.true ( isMatch ( "*/**/a", "a/a" ) ); 2448 | t.true ( isMatch ( "a/**", "a" ) ); 2449 | t.true ( isMatch ( "*/**", "foo/" ) ); 2450 | t.true ( isMatch ( "**/*", "foo/bar" ) ); 2451 | t.true ( isMatch ( "*/*", "foo/bar" ) ); 2452 | t.true ( isMatch ( "*/**", "foo/bar" ) ); 2453 | t.true ( isMatch ( "**/", "foo/bar/" ) ); 2454 | t.true ( isMatch ( "**/*", "foo/bar/" ) ); 2455 | t.true ( isMatch ( "**/*/", "foo/bar/" ) ); 2456 | t.true ( isMatch ( "*/**", "foo/bar/" ) ); 2457 | t.true ( isMatch ( "*/*/", "foo/bar/" ) ); 2458 | 2459 | t.true ( !isMatch ( "*/foo", "bar/baz/foo" ) ); 2460 | t.true ( !isMatch ( "**/bar/*", "deep/foo/bar" ) ); 2461 | t.true ( !isMatch ( "*/bar/**", "deep/foo/bar/baz/x" ) ); 2462 | t.true ( !isMatch ( "/*", "ef" ) ); 2463 | t.true ( !isMatch ( "foo?bar", "foo/bar" ) ); 2464 | t.true ( !isMatch ( "**/bar*", "foo/bar/baz" ) ); 2465 | t.true ( !isMatch ( "**/bar**", "foo/bar/baz" ) ); 2466 | t.true ( !isMatch ( "foo**bar", "foo/baz/bar" ) ); 2467 | t.true ( !isMatch ( "foo*bar", "foo/baz/bar" ) ); 2468 | t.true ( isMatch ( "foo/**", "foo" ) ); 2469 | t.true ( isMatch ( "/*", "/ab" ) ); 2470 | t.true ( isMatch ( "/*", "/cd" ) ); 2471 | t.true ( isMatch ( "/*", "/ef" ) ); 2472 | t.true ( isMatch ( "a/**/j/**/z/*.md", "a/b/j/c/z/x.md" ) ); 2473 | t.true ( isMatch ( "a/**/j/**/z/*.md", "a/j/z/x.md" ) ); 2474 | 2475 | t.true ( isMatch ( "**/foo", "bar/baz/foo" ) ); 2476 | t.true ( isMatch ( "**/bar/*", "deep/foo/bar/baz" ) ); 2477 | t.true ( isMatch ( "**/bar/**", "deep/foo/bar/baz/" ) ); 2478 | t.true ( isMatch ( "**/bar/*/*", "deep/foo/bar/baz/x" ) ); 2479 | t.true ( isMatch ( "foo/**/**/bar", "foo/b/a/z/bar" ) ); 2480 | t.true ( isMatch ( "foo/**/bar", "foo/b/a/z/bar" ) ); 2481 | t.true ( isMatch ( "foo/**/**/bar", "foo/bar" ) ); 2482 | t.true ( isMatch ( "foo/**/bar", "foo/bar" ) ); 2483 | t.true ( isMatch ( "*/bar/**", "foo/bar/baz/x" ) ); 2484 | t.true ( isMatch ( "foo/**/**/bar", "foo/baz/bar" ) ); 2485 | t.true ( isMatch ( "foo/**/bar", "foo/baz/bar" ) ); 2486 | t.true ( isMatch ( "**/foo", "XXX/foo" ) ); 2487 | 2488 | }); 2489 | 2490 | it ( 'globstars', t => { 2491 | 2492 | t.true ( isMatch ( "**/*.js", "a/b/c/d.js" ) ); 2493 | t.true ( isMatch ( "**/*.js", "a/b/c.js" ) ); 2494 | t.true ( isMatch ( "**/*.js", "a/b.js" ) ); 2495 | t.true ( isMatch ( "a/b/**/*.js", "a/b/c/d/e/f.js" ) ); 2496 | t.true ( isMatch ( "a/b/**/*.js", "a/b/c/d/e.js" ) ); 2497 | t.true ( isMatch ( "a/b/c/**/*.js", "a/b/c/d.js" ) ); 2498 | t.true ( isMatch ( "a/b/**/*.js", "a/b/c/d.js" ) ); 2499 | t.true ( isMatch ( "a/b/**/*.js", "a/b/d.js" ) ); 2500 | t.true ( !isMatch ( "a/b/**/*.js", "a/d.js" ) ); 2501 | t.true ( !isMatch ( "a/b/**/*.js", "d.js" ) ); 2502 | 2503 | t.true ( !isMatch ( "**c", "a/b/c" ) ); 2504 | t.true ( !isMatch ( "a/**c", "a/b/c" ) ); 2505 | t.true ( !isMatch ( "a/**z", "a/b/c" ) ); 2506 | t.true ( !isMatch ( "a/**b**/c", "a/b/c/b/c" ) ); 2507 | t.true ( !isMatch ( "a/b/c**/*.js", "a/b/c/d/e.js" ) ); 2508 | t.true ( isMatch ( "a/**/b/**/c", "a/b/c/b/c" ) ); 2509 | t.true ( isMatch ( "a/**b**/c", "a/aba/c" ) ); 2510 | t.true ( isMatch ( "a/**b**/c", "a/b/c" ) ); 2511 | t.true ( isMatch ( "a/b/c**/*.js", "a/b/c/d.js" ) ); 2512 | 2513 | t.true ( !isMatch ( "a/**/*", "a" ) ); 2514 | t.true ( !isMatch ( "a/**/**/*", "a" ) ); 2515 | t.true ( !isMatch ( "a/**/**/**/*", "a" ) ); 2516 | t.true ( isMatch ( "**/a", "a/" ) ); 2517 | // t.true ( !isMatch ( "a/**/*", "a/" ) ); 2518 | // t.true ( !isMatch ( "a/**/**/*", "a/" ) ); 2519 | // t.true ( !isMatch ( "a/**/**/**/*", "a/" ) ); 2520 | t.true ( !isMatch ( "**/a", "a/b" ) ); 2521 | t.true ( !isMatch ( "a/**/j/**/z/*.md", "a/b/c/j/e/z/c.txt" ) ); 2522 | t.true ( !isMatch ( "a/**/b", "a/bb" ) ); 2523 | t.true ( !isMatch ( "**/a", "a/c" ) ); 2524 | t.true ( !isMatch ( "**/a", "a/b" ) ); 2525 | t.true ( !isMatch ( "**/a", "a/x/y" ) ); 2526 | t.true ( !isMatch ( "**/a", "a/b/c/d" ) ); 2527 | t.true ( isMatch ( "**", "a" ) ); 2528 | t.true ( isMatch ( "**/a", "a" ) ); 2529 | t.true ( isMatch ( "a/**", "a" ) ); 2530 | t.true ( isMatch ( "**", "a/" ) ); 2531 | t.true ( isMatch ( "**/a/**", "a/" ) ); 2532 | t.true ( isMatch ( "a/**", "a/" ) ); 2533 | t.true ( isMatch ( "a/**/**", "a/" ) ); 2534 | t.true ( isMatch ( "**/a", "a/a" ) ); 2535 | t.true ( isMatch ( "**", "a/b" ) ); 2536 | t.true ( isMatch ( "*/*", "a/b" ) ); 2537 | t.true ( isMatch ( "a/**", "a/b" ) ); 2538 | t.true ( isMatch ( "a/**/*", "a/b" ) ); 2539 | t.true ( isMatch ( "a/**/**/*", "a/b" ) ); 2540 | t.true ( isMatch ( "a/**/**/**/*", "a/b" ) ); 2541 | t.true ( isMatch ( "a/**/b", "a/b" ) ); 2542 | t.true ( isMatch ( "**", "a/b/c" ) ); 2543 | t.true ( isMatch ( "**/*", "a/b/c" ) ); 2544 | t.true ( isMatch ( "**/**", "a/b/c" ) ); 2545 | t.true ( isMatch ( "*/**", "a/b/c" ) ); 2546 | t.true ( isMatch ( "a/**", "a/b/c" ) ); 2547 | t.true ( isMatch ( "a/**/*", "a/b/c" ) ); 2548 | t.true ( isMatch ( "a/**/**/*", "a/b/c" ) ); 2549 | t.true ( isMatch ( "a/**/**/**/*", "a/b/c" ) ); 2550 | t.true ( isMatch ( "**", "a/b/c/d" ) ); 2551 | t.true ( isMatch ( "a/**", "a/b/c/d" ) ); 2552 | t.true ( isMatch ( "a/**/*", "a/b/c/d" ) ); 2553 | t.true ( isMatch ( "a/**/**/*", "a/b/c/d" ) ); 2554 | t.true ( isMatch ( "a/**/**/**/*", "a/b/c/d" ) ); 2555 | t.true ( isMatch ( "a/b/**/c/**/*.*", "a/b/c/d.e" ) ); 2556 | t.true ( isMatch ( "a/**/f/*.md", "a/b/c/d/e/f/g.md" ) ); 2557 | t.true ( isMatch ( "a/**/f/**/k/*.md", "a/b/c/d/e/f/g/h/i/j/k/l.md" ) ); 2558 | t.true ( isMatch ( "a/b/c/*.md", "a/b/c/def.md" ) ); 2559 | t.true ( isMatch ( "a/*/c/*.md", "a/bb.bb/c/ddd.md" ) ); 2560 | t.true ( isMatch ( "a/**/f/*.md", "a/bb.bb/cc/d.d/ee/f/ggg.md" ) ); 2561 | t.true ( isMatch ( "a/**/f/*.md", "a/bb.bb/cc/dd/ee/f/ggg.md" ) ); 2562 | t.true ( isMatch ( "a/*/c/*.md", "a/bb/c/ddd.md" ) ); 2563 | t.true ( isMatch ( "a/*/c/*.md", "a/bbbb/c/ddd.md" ) ); 2564 | 2565 | t.true ( isMatch ( "foo/bar/**/one/**/*.*", "foo/bar/baz/one/image.png" ) ); 2566 | t.true ( isMatch ( "foo/bar/**/one/**/*.*", "foo/bar/baz/one/two/image.png" ) ); 2567 | t.true ( isMatch ( "foo/bar/**/one/**/*.*", "foo/bar/baz/one/two/three/image.png" ) ); 2568 | t.true ( !isMatch ( "a/b/**/f", "a/b/c/d/" ) ); 2569 | t.true ( isMatch ( "a/**", "a" ) ); 2570 | t.true ( isMatch ( "**", "a" ) ); 2571 | t.true ( isMatch ( "a{,/**}", "a" ) ); 2572 | t.true ( isMatch ( "**", "a/" ) ); 2573 | t.true ( isMatch ( "a/**", "a/" ) ); 2574 | t.true ( isMatch ( "**", "a/b/c/d" ) ); 2575 | t.true ( isMatch ( "**", "a/b/c/d/" ) ); 2576 | t.true ( isMatch ( "**/**", "a/b/c/d/" ) ); 2577 | t.true ( isMatch ( "**/b/**", "a/b/c/d/" ) ); 2578 | t.true ( isMatch ( "a/b/**", "a/b/c/d/" ) ); 2579 | t.true ( isMatch ( "a/b/**/", "a/b/c/d/" ) ); 2580 | t.true ( isMatch ( "a/b/**/c/**/", "a/b/c/d/" ) ); 2581 | t.true ( isMatch ( "a/b/**/c/**/d/", "a/b/c/d/" ) ); 2582 | t.true ( isMatch ( "a/b/**/**/*.*", "a/b/c/d/e.f" ) ); 2583 | t.true ( isMatch ( "a/b/**/*.*", "a/b/c/d/e.f" ) ); 2584 | t.true ( isMatch ( "a/b/**/c/**/d/*.*", "a/b/c/d/e.f" ) ); 2585 | t.true ( isMatch ( "a/b/**/d/**/*.*", "a/b/c/d/e.f" ) ); 2586 | t.true ( isMatch ( "a/b/**/d/**/*.*", "a/b/c/d/g/e.f" ) ); 2587 | t.true ( isMatch ( "a/b/**/d/**/*.*", "a/b/c/d/g/g/e.f" ) ); 2588 | t.true ( isMatch ( "a/b-*/**/z.js", "a/b-c/z.js" ) ); 2589 | t.true ( isMatch ( "a/b-*/**/z.js", "a/b-c/d/e/z.js" ) ); 2590 | 2591 | t.true ( isMatch ( "*/*", "a/b" ) ); 2592 | t.true ( isMatch ( "a/b/c/*.md", "a/b/c/xyz.md" ) ); 2593 | t.true ( isMatch ( "a/*/c/*.md", "a/bb.bb/c/xyz.md" ) ); 2594 | t.true ( isMatch ( "a/*/c/*.md", "a/bb/c/xyz.md" ) ); 2595 | t.true ( isMatch ( "a/*/c/*.md", "a/bbbb/c/xyz.md" ) ); 2596 | 2597 | t.true ( isMatch ( "**/*", "a/b/c" ) ); 2598 | t.true ( isMatch ( "**/**", "a/b/c" ) ); 2599 | t.true ( isMatch ( "*/**", "a/b/c" ) ); 2600 | t.true ( isMatch ( "a/**/j/**/z/*.md", "a/b/c/d/e/j/n/p/o/z/c.md" ) ); 2601 | t.true ( isMatch ( "a/**/z/*.md", "a/b/c/d/e/z/c.md" ) ); 2602 | t.true ( isMatch ( "a/**/c/*.md", "a/bb.bb/aa/b.b/aa/c/xyz.md" ) ); 2603 | t.true ( isMatch ( "a/**/c/*.md", "a/bb.bb/aa/bb/aa/c/xyz.md" ) ); 2604 | t.true ( !isMatch ( "a/**/j/**/z/*.md", "a/b/c/j/e/z/c.txt" ) ); 2605 | t.true ( !isMatch ( "a/b/**/c{d,e}/**/xyz.md", "a/b/c/xyz.md" ) ); 2606 | t.true ( !isMatch ( "a/b/**/c{d,e}/**/xyz.md", "a/b/d/xyz.md" ) ); 2607 | t.true ( !isMatch ( "a/**/", "a/b" ) ); 2608 | t.true ( isMatch ( "**/*", "a/b/.js/c.txt" ) ); 2609 | t.true ( !isMatch ( "a/**/", "a/b/c/d" ) ); 2610 | t.true ( !isMatch ( "a/**/", "a/bb" ) ); 2611 | t.true ( !isMatch ( "a/**/", "a/cb" ) ); 2612 | t.true ( isMatch ( "/**", "/a/b" ) ); 2613 | t.true ( isMatch ( "**/*", "a.b" ) ); 2614 | t.true ( isMatch ( "**/*", "a.js" ) ); 2615 | t.true ( isMatch ( "**/*.js", "a.js" ) ); 2616 | t.true ( isMatch ( "a/**/", "a/" ) ); 2617 | t.true ( isMatch ( "**/*.js", "a/a.js" ) ); 2618 | t.true ( isMatch ( "**/*.js", "a/a/b.js" ) ); 2619 | t.true ( isMatch ( "a/**/b", "a/b" ) ); 2620 | t.true ( isMatch ( "a/**b", "a/b" ) ); 2621 | t.true ( isMatch ( "**/*.md", "a/b.md" ) ); 2622 | t.true ( isMatch ( "**/*", "a/b/c.js" ) ); 2623 | t.true ( isMatch ( "**/*", "a/b/c.txt" ) ); 2624 | t.true ( isMatch ( "a/**/", "a/b/c/d/" ) ); 2625 | t.true ( isMatch ( "**/*", "a/b/c/d/a.js" ) ); 2626 | t.true ( isMatch ( "a/b/**/*.js", "a/b/c/z.js" ) ); 2627 | t.true ( isMatch ( "a/b/**/*.js", "a/b/z.js" ) ); 2628 | t.true ( isMatch ( "**/*", "ab" ) ); 2629 | t.true ( isMatch ( "**/*", "ab/c" ) ); 2630 | t.true ( isMatch ( "**/*", "ab/c/d" ) ); 2631 | t.true ( isMatch ( "**/*", "abc.js" ) ); 2632 | 2633 | t.true ( !isMatch ( "**/", "a" ) ); 2634 | t.true ( !isMatch ( "**/a/*", "a" ) ); 2635 | t.true ( !isMatch ( "**/a/*/*", "a" ) ); 2636 | t.true ( !isMatch ( "*/a/**", "a" ) ); 2637 | t.true ( !isMatch ( "a/**/*", "a" ) ); 2638 | t.true ( !isMatch ( "a/**/**/*", "a" ) ); 2639 | t.true ( !isMatch ( "**/", "a/b" ) ); 2640 | t.true ( !isMatch ( "**/b/*", "a/b" ) ); 2641 | t.true ( !isMatch ( "**/b/*/*", "a/b" ) ); 2642 | t.true ( !isMatch ( "b/**", "a/b" ) ); 2643 | t.true ( !isMatch ( "**/", "a/b/c" ) ); 2644 | t.true ( !isMatch ( "**/**/b", "a/b/c" ) ); 2645 | t.true ( !isMatch ( "**/b", "a/b/c" ) ); 2646 | t.true ( !isMatch ( "**/b/*/*", "a/b/c" ) ); 2647 | t.true ( !isMatch ( "b/**", "a/b/c" ) ); 2648 | t.true ( !isMatch ( "**/", "a/b/c/d" ) ); 2649 | t.true ( !isMatch ( "**/d/*", "a/b/c/d" ) ); 2650 | t.true ( !isMatch ( "b/**", "a/b/c/d" ) ); 2651 | t.true ( isMatch ( "**", "a" ) ); 2652 | t.true ( isMatch ( "**/**", "a" ) ); 2653 | t.true ( isMatch ( "**/**/*", "a" ) ); 2654 | t.true ( isMatch ( "**/**/a", "a" ) ); 2655 | t.true ( isMatch ( "**/a", "a" ) ); 2656 | t.true ( isMatch ( "**/a/**", "a" ) ); 2657 | t.true ( isMatch ( "a/**", "a" ) ); 2658 | t.true ( isMatch ( "**", "a/b" ) ); 2659 | t.true ( isMatch ( "**/**", "a/b" ) ); 2660 | t.true ( isMatch ( "**/**/*", "a/b" ) ); 2661 | t.true ( isMatch ( "**/**/b", "a/b" ) ); 2662 | t.true ( isMatch ( "**/b", "a/b" ) ); 2663 | t.true ( isMatch ( "**/b/**", "a/b" ) ); 2664 | t.true ( isMatch ( "*/b/**", "a/b" ) ); 2665 | t.true ( isMatch ( "a/**", "a/b" ) ); 2666 | t.true ( isMatch ( "a/**/*", "a/b" ) ); 2667 | t.true ( isMatch ( "a/**/**/*", "a/b" ) ); 2668 | t.true ( isMatch ( "**", "a/b/c" ) ); 2669 | t.true ( isMatch ( "**/**", "a/b/c" ) ); 2670 | t.true ( isMatch ( "**/**/*", "a/b/c" ) ); 2671 | t.true ( isMatch ( "**/b/*", "a/b/c" ) ); 2672 | t.true ( isMatch ( "**/b/**", "a/b/c" ) ); 2673 | t.true ( isMatch ( "*/b/**", "a/b/c" ) ); 2674 | t.true ( isMatch ( "a/**", "a/b/c" ) ); 2675 | t.true ( isMatch ( "a/**/*", "a/b/c" ) ); 2676 | t.true ( isMatch ( "a/**/**/*", "a/b/c" ) ); 2677 | t.true ( isMatch ( "**", "a/b/c/d" ) ); 2678 | t.true ( isMatch ( "**/**", "a/b/c/d" ) ); 2679 | t.true ( isMatch ( "**/**/*", "a/b/c/d" ) ); 2680 | t.true ( isMatch ( "**/**/d", "a/b/c/d" ) ); 2681 | t.true ( isMatch ( "**/b/**", "a/b/c/d" ) ); 2682 | t.true ( isMatch ( "**/b/*/*", "a/b/c/d" ) ); 2683 | t.true ( isMatch ( "**/d", "a/b/c/d" ) ); 2684 | t.true ( isMatch ( "*/b/**", "a/b/c/d" ) ); 2685 | t.true ( isMatch ( "a/**", "a/b/c/d" ) ); 2686 | t.true ( isMatch ( "a/**/*", "a/b/c/d" ) ); 2687 | t.true ( isMatch ( "a/**/**/*", "a/b/c/d" ) ); 2688 | 2689 | }); 2690 | 2691 | it ( 'utf8', t => { 2692 | 2693 | t.true ( isMatch ( "フ*/**/*", "フォルダ/aaa.js" ) ); 2694 | t.true ( isMatch ( "フォ*/**/*", "フォルダ/aaa.js" ) ); 2695 | t.true ( isMatch ( "フォル*/**/*", "フォルダ/aaa.js" ) ); 2696 | t.true ( isMatch ( "フ*ル*/**/*", "フォルダ/aaa.js" ) ); 2697 | t.true ( isMatch ( "フォルダ/**/*", "フォルダ/aaa.js" ) ); 2698 | 2699 | }); 2700 | 2701 | it ( 'negation', t => { 2702 | 2703 | t.true ( !isMatch ( "!*", "abc" ) ); 2704 | t.true ( !isMatch ( "!abc", "abc" ) ); 2705 | t.true ( !isMatch ( "*!.md", "bar.md" ) ); 2706 | t.true ( !isMatch ( "foo!.md", "bar.md" ) ); 2707 | t.true ( !isMatch ( "\\!*!*.md", "foo!.md" ) ); 2708 | t.true ( !isMatch ( "\\!*!*.md", "foo!bar.md" ) ); 2709 | t.true ( isMatch ( "*!*.md", "!foo!.md" ) ); 2710 | t.true ( isMatch ( "\\!*!*.md", "!foo!.md" ) ); 2711 | t.true ( isMatch ( "!*foo", "abc" ) ); 2712 | t.true ( isMatch ( "!foo*", "abc" ) ); 2713 | t.true ( isMatch ( "!xyz", "abc" ) ); 2714 | t.true ( isMatch ( "*!*.*", "ba!r.js" ) ); 2715 | t.true ( isMatch ( "*.md", "bar.md" ) ); 2716 | t.true ( isMatch ( "*!*.*", "foo!.md" ) ); 2717 | t.true ( isMatch ( "*!*.md", "foo!.md" ) ); 2718 | t.true ( isMatch ( "*!.md", "foo!.md" ) ); 2719 | t.true ( isMatch ( "*.md", "foo!.md" ) ); 2720 | t.true ( isMatch ( "foo!.md", "foo!.md" ) ); 2721 | t.true ( isMatch ( "*!*.md", "foo!bar.md" ) ); 2722 | t.true ( isMatch ( "*b*.md", "foobar.md" ) ); 2723 | 2724 | t.true ( !isMatch ( "a!!b", "a" ) ); 2725 | t.true ( !isMatch ( "a!!b", "aa" ) ); 2726 | t.true ( !isMatch ( "a!!b", "a/b" ) ); 2727 | t.true ( !isMatch ( "a!!b", "a!b" ) ); 2728 | t.true ( isMatch ( "a!!b", "a!!b" ) ); 2729 | t.true ( !isMatch ( "a!!b", "a/!!/b" ) ); 2730 | 2731 | t.true ( !isMatch ( "!a/b", "a/b" ) ); 2732 | t.true ( isMatch ( "!a/b", "a" ) ); 2733 | t.true ( isMatch ( "!a/b", "a.b" ) ); 2734 | t.true ( isMatch ( "!a/b", "a/a" ) ); 2735 | t.true ( isMatch ( "!a/b", "a/c" ) ); 2736 | t.true ( isMatch ( "!a/b", "b/a" ) ); 2737 | t.true ( isMatch ( "!a/b", "b/b" ) ); 2738 | t.true ( isMatch ( "!a/b", "b/c" ) ); 2739 | 2740 | t.true ( !isMatch ( "!abc", "abc" ) ); 2741 | t.true ( isMatch ( "!!abc", "abc" ) ); 2742 | t.true ( !isMatch ( "!!!abc", "abc" ) ); 2743 | t.true ( isMatch ( "!!!!abc", "abc" ) ); 2744 | t.true ( !isMatch ( "!!!!!abc", "abc" ) ); 2745 | t.true ( isMatch ( "!!!!!!abc", "abc" ) ); 2746 | t.true ( !isMatch ( "!!!!!!!abc", "abc" ) ); 2747 | t.true ( isMatch ( "!!!!!!!!abc", "abc" ) ); 2748 | 2749 | // t.true ( !isMatch ( "!(*/*)", "a/a" ) ); 2750 | // t.true ( !isMatch ( "!(*/*)", "a/b" ) ); 2751 | // t.true ( !isMatch ( "!(*/*)", "a/c" ) ); 2752 | // t.true ( !isMatch ( "!(*/*)", "b/a" ) ); 2753 | // t.true ( !isMatch ( "!(*/*)", "b/b" ) ); 2754 | // t.true ( !isMatch ( "!(*/*)", "b/c" ) ); 2755 | // t.true ( !isMatch ( "!(*/b)", "a/b" ) ); 2756 | // t.true ( !isMatch ( "!(*/b)", "b/b" ) ); 2757 | // t.true ( !isMatch ( "!(a/b)", "a/b" ) ); 2758 | t.true ( !isMatch ( "!*", "a" ) ); 2759 | t.true ( !isMatch ( "!*", "a.b" ) ); 2760 | t.true ( !isMatch ( "!*/*", "a/a" ) ); 2761 | t.true ( !isMatch ( "!*/*", "a/b" ) ); 2762 | t.true ( !isMatch ( "!*/*", "a/c" ) ); 2763 | t.true ( !isMatch ( "!*/*", "b/a" ) ); 2764 | t.true ( !isMatch ( "!*/*", "b/b" ) ); 2765 | t.true ( !isMatch ( "!*/*", "b/c" ) ); 2766 | t.true ( !isMatch ( "!*/b", "a/b" ) ); 2767 | t.true ( !isMatch ( "!*/b", "b/b" ) ); 2768 | t.true ( !isMatch ( "!*/c", "a/c" ) ); 2769 | t.true ( !isMatch ( "!*/c", "a/c" ) ); 2770 | t.true ( !isMatch ( "!*/c", "b/c" ) ); 2771 | t.true ( !isMatch ( "!*/c", "b/c" ) ); 2772 | t.true ( !isMatch ( "!*a*", "bar" ) ); 2773 | t.true ( !isMatch ( "!*a*", "fab" ) ); 2774 | t.true ( isMatch ( "!a/(*)", "a/a" ) ); 2775 | t.true ( isMatch ( "!a/(*)", "a/b" ) ); 2776 | t.true ( isMatch ( "!a/(*)", "a/c" ) ); 2777 | t.true ( isMatch ( "!a/(b)", "a/b" ) ); 2778 | t.true ( !isMatch ( "!a/*", "a/a" ) ); 2779 | t.true ( !isMatch ( "!a/*", "a/b" ) ); 2780 | t.true ( !isMatch ( "!a/*", "a/c" ) ); 2781 | t.true ( !isMatch ( "!f*b", "fab" ) ); 2782 | t.true ( isMatch ( "!(*/*)", "a" ) ); 2783 | t.true ( isMatch ( "!(*/*)", "a.b" ) ); 2784 | t.true ( isMatch ( "!(*/b)", "a" ) ); 2785 | t.true ( isMatch ( "!(*/b)", "a.b" ) ); 2786 | t.true ( isMatch ( "!(*/b)", "a/a" ) ); 2787 | t.true ( isMatch ( "!(*/b)", "a/c" ) ); 2788 | t.true ( isMatch ( "!(*/b)", "b/a" ) ); 2789 | t.true ( isMatch ( "!(*/b)", "b/c" ) ); 2790 | t.true ( isMatch ( "!(a/b)", "a" ) ); 2791 | t.true ( isMatch ( "!(a/b)", "a.b" ) ); 2792 | t.true ( isMatch ( "!(a/b)", "a/a" ) ); 2793 | t.true ( isMatch ( "!(a/b)", "a/c" ) ); 2794 | t.true ( isMatch ( "!(a/b)", "b/a" ) ); 2795 | t.true ( isMatch ( "!(a/b)", "b/b" ) ); 2796 | t.true ( isMatch ( "!(a/b)", "b/c" ) ); 2797 | t.true ( isMatch ( "!*", "a/a" ) ); 2798 | t.true ( isMatch ( "!*", "a/b" ) ); 2799 | t.true ( isMatch ( "!*", "a/c" ) ); 2800 | t.true ( isMatch ( "!*", "b/a" ) ); 2801 | t.true ( isMatch ( "!*", "b/b" ) ); 2802 | t.true ( isMatch ( "!*", "b/c" ) ); 2803 | t.true ( isMatch ( "!*/*", "a" ) ); 2804 | t.true ( isMatch ( "!*/*", "a.b" ) ); 2805 | t.true ( isMatch ( "!*/b", "a" ) ); 2806 | t.true ( isMatch ( "!*/b", "a.b" ) ); 2807 | t.true ( isMatch ( "!*/b", "a/a" ) ); 2808 | t.true ( isMatch ( "!*/b", "a/c" ) ); 2809 | t.true ( isMatch ( "!*/b", "b/a" ) ); 2810 | t.true ( isMatch ( "!*/b", "b/c" ) ); 2811 | t.true ( isMatch ( "!*/c", "a" ) ); 2812 | t.true ( isMatch ( "!*/c", "a.b" ) ); 2813 | t.true ( isMatch ( "!*/c", "a/a" ) ); 2814 | t.true ( isMatch ( "!*/c", "a/b" ) ); 2815 | t.true ( isMatch ( "!*/c", "b/a" ) ); 2816 | t.true ( isMatch ( "!*/c", "b/b" ) ); 2817 | t.true ( isMatch ( "!*a*", "foo" ) ); 2818 | t.true ( isMatch ( "!a/(*)", "a" ) ); 2819 | t.true ( isMatch ( "!a/(*)", "a.b" ) ); 2820 | t.true ( isMatch ( "!a/(*)", "b/a" ) ); 2821 | t.true ( isMatch ( "!a/(*)", "b/b" ) ); 2822 | t.true ( isMatch ( "!a/(*)", "b/c" ) ); 2823 | t.true ( isMatch ( "!a/(b)", "a" ) ); 2824 | t.true ( isMatch ( "!a/(b)", "a.b" ) ); 2825 | t.true ( isMatch ( "!a/(b)", "a/a" ) ); 2826 | t.true ( isMatch ( "!a/(b)", "a/c" ) ); 2827 | t.true ( isMatch ( "!a/(b)", "b/a" ) ); 2828 | t.true ( isMatch ( "!a/(b)", "b/b" ) ); 2829 | t.true ( isMatch ( "!a/(b)", "b/c" ) ); 2830 | t.true ( isMatch ( "!a/*", "a" ) ); 2831 | t.true ( isMatch ( "!a/*", "a.b" ) ); 2832 | t.true ( isMatch ( "!a/*", "b/a" ) ); 2833 | t.true ( isMatch ( "!a/*", "b/b" ) ); 2834 | t.true ( isMatch ( "!a/*", "b/c" ) ); 2835 | t.true ( isMatch ( "!f*b", "bar" ) ); 2836 | t.true ( isMatch ( "!f*b", "foo" ) ); 2837 | 2838 | t.true ( !isMatch ( "!.md", ".md" ) ); 2839 | t.true ( isMatch ( "!**/*.md", "a.js" ) ); 2840 | t.true ( !isMatch ( "!**/*.md", "b.md" ) ); 2841 | t.true ( isMatch ( "!**/*.md", "c.txt" ) ); 2842 | t.true ( isMatch ( "!*.md", "a.js" ) ); 2843 | t.true ( !isMatch ( "!*.md", "b.md" ) ); 2844 | t.true ( isMatch ( "!*.md", "c.txt" ) ); 2845 | t.true ( !isMatch ( "!*.md", "abc.md" ) ); 2846 | t.true ( isMatch ( "!*.md", "abc.txt" ) ); 2847 | t.true ( !isMatch ( "!*.md", "foo.md" ) ); 2848 | t.true ( isMatch ( "!.md", "foo.md" ) ); 2849 | 2850 | t.true ( isMatch ( "!*.md", "a.js" ) ); 2851 | t.true ( isMatch ( "!*.md", "b.txt" ) ); 2852 | t.true ( !isMatch ( "!*.md", "c.md" ) ); 2853 | t.true ( !isMatch ( "!a/*/a.js", "a/a/a.js" ) ); 2854 | t.true ( !isMatch ( "!a/*/a.js", "a/b/a.js" ) ); 2855 | t.true ( !isMatch ( "!a/*/a.js", "a/c/a.js" ) ); 2856 | t.true ( !isMatch ( "!a/*/*/a.js", "a/a/a/a.js" ) ); 2857 | t.true ( isMatch ( "!a/*/*/a.js", "b/a/b/a.js" ) ); 2858 | t.true ( isMatch ( "!a/*/*/a.js", "c/a/c/a.js" ) ); 2859 | t.true ( !isMatch ( "!a/a*.txt", "a/a.txt" ) ); 2860 | t.true ( isMatch ( "!a/a*.txt", "a/b.txt" ) ); 2861 | t.true ( isMatch ( "!a/a*.txt", "a/c.txt" ) ); 2862 | t.true ( !isMatch ( "!a.a*.txt", "a.a.txt" ) ); 2863 | t.true ( isMatch ( "!a.a*.txt", "a.b.txt" ) ); 2864 | t.true ( isMatch ( "!a.a*.txt", "a.c.txt" ) ); 2865 | t.true ( !isMatch ( "!a/*.txt", "a/a.txt" ) ); 2866 | t.true ( !isMatch ( "!a/*.txt", "a/b.txt" ) ); 2867 | t.true ( !isMatch ( "!a/*.txt", "a/c.txt" ) ); 2868 | 2869 | t.true ( isMatch ( "!*.md", "a.js" ) ); 2870 | t.true ( isMatch ( "!*.md", "b.txt" ) ); 2871 | t.true ( !isMatch ( "!*.md", "c.md" ) ); 2872 | t.true ( !isMatch ( "!**/a.js", "a/a/a.js" ) ); 2873 | t.true ( !isMatch ( "!**/a.js", "a/b/a.js" ) ); 2874 | t.true ( !isMatch ( "!**/a.js", "a/c/a.js" ) ); 2875 | t.true ( isMatch ( "!**/a.js", "a/a/b.js" ) ); 2876 | t.true ( !isMatch ( "!a/**/a.js", "a/a/a/a.js" ) ); 2877 | t.true ( isMatch ( "!a/**/a.js", "b/a/b/a.js" ) ); 2878 | t.true ( isMatch ( "!a/**/a.js", "c/a/c/a.js" ) ); 2879 | t.true ( isMatch ( "!**/*.md", "a/b.js" ) ); 2880 | t.true ( isMatch ( "!**/*.md", "a.js" ) ); 2881 | t.true ( !isMatch ( "!**/*.md", "a/b.md" ) ); 2882 | t.true ( !isMatch ( "!**/*.md", "a.md" ) ); 2883 | t.true ( !isMatch ( "**/*.md", "a/b.js" ) ); 2884 | t.true ( !isMatch ( "**/*.md", "a.js" ) ); 2885 | t.true ( isMatch ( "**/*.md", "a/b.md" ) ); 2886 | t.true ( isMatch ( "**/*.md", "a.md" ) ); 2887 | t.true ( isMatch ( "!**/*.md", "a/b.js" ) ); 2888 | t.true ( isMatch ( "!**/*.md", "a.js" ) ); 2889 | t.true ( !isMatch ( "!**/*.md", "a/b.md" ) ); 2890 | t.true ( !isMatch ( "!**/*.md", "a.md" ) ); 2891 | t.true ( isMatch ( "!*.md", "a/b.js" ) ); 2892 | t.true ( isMatch ( "!*.md", "a.js" ) ); 2893 | t.true ( isMatch ( "!*.md", "a/b.md" ) ); 2894 | t.true ( !isMatch ( "!*.md", "a.md" ) ); 2895 | t.true ( isMatch ( "!**/*.md", "a.js" ) ); 2896 | t.true ( !isMatch ( "!**/*.md", "b.md" ) ); 2897 | t.true ( isMatch ( "!**/*.md", "c.txt" ) ); 2898 | 2899 | }); 2900 | 2901 | it ( 'question_mark', t => { 2902 | 2903 | t.true ( isMatch ( "?", "a" ) ); 2904 | t.true ( !isMatch ( "?", "aa" ) ); 2905 | t.true ( !isMatch ( "?", "ab" ) ); 2906 | t.true ( !isMatch ( "?", "aaa" ) ); 2907 | t.true ( !isMatch ( "?", "abcdefg" ) ); 2908 | 2909 | t.true ( !isMatch ( "??", "a" ) ); 2910 | t.true ( isMatch ( "??", "aa" ) ); 2911 | t.true ( isMatch ( "??", "ab" ) ); 2912 | t.true ( !isMatch ( "??", "aaa" ) ); 2913 | t.true ( !isMatch ( "??", "abcdefg" ) ); 2914 | 2915 | t.true ( !isMatch ( "???", "a" ) ); 2916 | t.true ( !isMatch ( "???", "aa" ) ); 2917 | t.true ( !isMatch ( "???", "ab" ) ); 2918 | t.true ( isMatch ( "???", "aaa" ) ); 2919 | t.true ( !isMatch ( "???", "abcdefg" ) ); 2920 | 2921 | t.true ( !isMatch ( "a?c", "aaa" ) ); 2922 | t.true ( isMatch ( "a?c", "aac" ) ); 2923 | t.true ( isMatch ( "a?c", "abc" ) ); 2924 | t.true ( !isMatch ( "ab?", "a" ) ); 2925 | t.true ( !isMatch ( "ab?", "aa" ) ); 2926 | t.true ( !isMatch ( "ab?", "ab" ) ); 2927 | t.true ( !isMatch ( "ab?", "ac" ) ); 2928 | t.true ( !isMatch ( "ab?", "abcd" ) ); 2929 | t.true ( !isMatch ( "ab?", "abbb" ) ); 2930 | t.true ( isMatch ( "a?b", "acb" ) ); 2931 | 2932 | t.true ( !isMatch ( "a/?/c/?/e.md", "a/bb/c/dd/e.md" ) ); 2933 | t.true ( isMatch ( "a/??/c/??/e.md", "a/bb/c/dd/e.md" ) ); 2934 | t.true ( !isMatch ( "a/??/c.md", "a/bbb/c.md" ) ); 2935 | t.true ( isMatch ( "a/?/c.md", "a/b/c.md" ) ); 2936 | t.true ( isMatch ( "a/?/c/?/e.md", "a/b/c/d/e.md" ) ); 2937 | t.true ( !isMatch ( "a/?/c/???/e.md", "a/b/c/d/e.md" ) ); 2938 | t.true ( isMatch ( "a/?/c/???/e.md", "a/b/c/zzz/e.md" ) ); 2939 | t.true ( !isMatch ( "a/?/c.md", "a/bb/c.md" ) ); 2940 | t.true ( isMatch ( "a/??/c.md", "a/bb/c.md" ) ); 2941 | t.true ( isMatch ( "a/???/c.md", "a/bbb/c.md" ) ); 2942 | t.true ( isMatch ( "a/????/c.md", "a/bbbb/c.md" ) ); 2943 | 2944 | }); 2945 | 2946 | it ( 'braces', t => { 2947 | 2948 | t.true ( isMatch ( "{a,b,c}", "a" ) ); 2949 | t.true ( isMatch ( "{a,b,c}", "b" ) ); 2950 | t.true ( isMatch ( "{a,b,c}", "c" ) ); 2951 | t.true ( !isMatch ( "{a,b,c}", "aa" ) ); 2952 | t.true ( !isMatch ( "{a,b,c}", "bb" ) ); 2953 | t.true ( !isMatch ( "{a,b,c}", "cc" ) ); 2954 | 2955 | t.true ( isMatch ( "a/{a,b}", "a/a" ) ); 2956 | t.true ( isMatch ( "a/{a,b}", "a/b" ) ); 2957 | t.true ( !isMatch ( "a/{a,b}", "a/c" ) ); 2958 | t.true ( !isMatch ( "a/{a,b}", "b/b" ) ); 2959 | t.true ( !isMatch ( "a/{a,b,c}", "b/b" ) ); 2960 | t.true ( isMatch ( "a/{a,b,c}", "a/c" ) ); 2961 | t.true ( isMatch ( "a{b,bc}.txt", "abc.txt" ) ); 2962 | 2963 | t.true ( isMatch ( "foo[{a,b}]baz", "foo{baz" ) ); 2964 | 2965 | t.true ( !isMatch ( "a{,b}.txt", "abc.txt" ) ); 2966 | t.true ( !isMatch ( "a{a,b,}.txt", "abc.txt" ) ); 2967 | t.true ( !isMatch ( "a{b,}.txt", "abc.txt" ) ); 2968 | t.true ( isMatch ( "a{,b}.txt", "a.txt" ) ); 2969 | t.true ( isMatch ( "a{b,}.txt", "a.txt" ) ); 2970 | t.true ( isMatch ( "a{a,b,}.txt", "aa.txt" ) ); 2971 | t.true ( isMatch ( "a{a,b,}.txt", "aa.txt" ) ); 2972 | t.true ( isMatch ( "a{,b}.txt", "ab.txt" ) ); 2973 | t.true ( isMatch ( "a{b,}.txt", "ab.txt" ) ); 2974 | 2975 | t.true ( isMatch ( "{a/,}a/**", "a" ) ); 2976 | t.true ( isMatch ( "a{a,b/}*.txt", "aa.txt" ) ); 2977 | t.true ( isMatch ( "a{a,b/}*.txt", "ab/.txt" ) ); 2978 | t.true ( isMatch ( "a{a,b/}*.txt", "ab/a.txt" ) ); 2979 | t.true ( isMatch ( "{a/,}a/**", "a/" ) ); 2980 | t.true ( isMatch ( "{a/,}a/**", "a/a/" ) ); 2981 | t.true ( isMatch ( "{a/,}a/**", "a/a" ) ); 2982 | t.true ( isMatch ( "{a/,}a/**", "a/a/a" ) ); 2983 | t.true ( isMatch ( "{a/,}a/**", "a/a/" ) ); 2984 | t.true ( isMatch ( "{a/,}a/**", "a/a/a/" ) ); 2985 | t.true ( isMatch ( "{a/,}b/**", "a/b/a/" ) ); 2986 | t.true ( isMatch ( "{a/,}b/**", "b/a/" ) ); 2987 | t.true ( isMatch ( "a{,/}*.txt", "a.txt" ) ); 2988 | t.true ( isMatch ( "a{,/}*.txt", "ab.txt" ) ); 2989 | t.true ( isMatch ( "a{,/}*.txt", "a/b.txt" ) ); 2990 | t.true ( isMatch ( "a{,/}*.txt", "a/ab.txt" ) ); 2991 | 2992 | t.true ( isMatch ( "a{,.*{foo,db},\\(bar\\)}.txt", "a.txt" ) ); 2993 | t.true ( !isMatch ( "a{,.*{foo,db},\\(bar\\)}.txt", "adb.txt" ) ); 2994 | t.true ( isMatch ( "a{,.*{foo,db},\\(bar\\)}.txt", "a.db.txt" ) ); 2995 | 2996 | t.true ( isMatch ( "a{,*.{foo,db},\\(bar\\)}.txt", "a.txt" ) ); 2997 | t.true ( !isMatch ( "a{,*.{foo,db},\\(bar\\)}.txt", "adb.txt" ) ); 2998 | t.true ( isMatch ( "a{,*.{foo,db},\\(bar\\)}.txt", "a.db.txt" ) ); 2999 | 3000 | t.true ( isMatch ( "a{,.*{foo,db},\\(bar\\)}", "a" ) ); 3001 | t.true ( !isMatch ( "a{,.*{foo,db},\\(bar\\)}", "adb" ) ); 3002 | t.true ( isMatch ( "a{,.*{foo,db},\\(bar\\)}", "a.db" ) ); 3003 | 3004 | t.true ( isMatch ( "a{,*.{foo,db},\\(bar\\)}", "a" ) ); 3005 | t.true ( !isMatch ( "a{,*.{foo,db},\\(bar\\)}", "adb" ) ); 3006 | t.true ( isMatch ( "a{,*.{foo,db},\\(bar\\)}", "a.db" ) ); 3007 | 3008 | t.true ( !isMatch ( "{,.*{foo,db},\\(bar\\)}", "a" ) ); 3009 | t.true ( !isMatch ( "{,.*{foo,db},\\(bar\\)}", "adb" ) ); 3010 | t.true ( !isMatch ( "{,.*{foo,db},\\(bar\\)}", "a.db" ) ); 3011 | t.true ( isMatch ( "{,.*{foo,db},\\(bar\\)}", ".db" ) ); 3012 | 3013 | t.true ( !isMatch ( "{,*.{foo,db},\\(bar\\)}", "a" ) ); 3014 | t.true ( isMatch ( "{*,*.{foo,db},\\(bar\\)}", "a" ) ); 3015 | t.true ( !isMatch ( "{,*.{foo,db},\\(bar\\)}", "adb" ) ); 3016 | t.true ( isMatch ( "{,*.{foo,db},\\(bar\\)}", "a.db" ) ); 3017 | 3018 | t.true ( !isMatch ( "a/b/**/c{d,e}/**/`xyz.md", "a/b/c/xyz.md" ) ); 3019 | t.true ( !isMatch ( "a/b/**/c{d,e}/**/xyz.md", "a/b/d/xyz.md" ) ); 3020 | t.true ( isMatch ( "a/b/**/c{d,e}/**/xyz.md", "a/b/cd/xyz.md" ) ); 3021 | t.true ( isMatch ( "a/b/**/{c,d,e}/**/xyz.md", "a/b/c/xyz.md" ) ); 3022 | t.true ( isMatch ( "a/b/**/{c,d,e}/**/xyz.md", "a/b/d/xyz.md" ) ); 3023 | t.true ( isMatch ( "a/b/**/{c,d,e}/**/xyz.md", "a/b/e/xyz.md" ) ); 3024 | 3025 | t.true ( isMatch ( "*{a,b}*", "xax" ) ); 3026 | t.true ( isMatch ( "*{a,b}*", "xxax" ) ); 3027 | t.true ( isMatch ( "*{a,b}*", "xbx" ) ); 3028 | 3029 | t.true ( isMatch ( "*{*a,b}", "xba" ) ); 3030 | t.true ( isMatch ( "*{*a,b}", "xb" ) ); 3031 | 3032 | t.true ( !isMatch ( "*??", "a" ) ); 3033 | t.true ( !isMatch ( "*???", "aa" ) ); 3034 | t.true ( isMatch ( "*???", "aaa" ) ); 3035 | t.true ( !isMatch ( "*****??", "a" ) ); 3036 | t.true ( !isMatch ( "*****???", "aa" ) ); 3037 | t.true ( isMatch ( "*****???", "aaa" ) ); 3038 | 3039 | t.true ( !isMatch ( "a*?c", "aaa" ) ); 3040 | t.true ( isMatch ( "a*?c", "aac" ) ); 3041 | t.true ( isMatch ( "a*?c", "abc" ) ); 3042 | 3043 | t.true ( isMatch ( "a**?c", "abc" ) ); 3044 | t.true ( !isMatch ( "a**?c", "abb" ) ); 3045 | t.true ( isMatch ( "a**?c", "acc" ) ); 3046 | t.true ( isMatch ( "a*****?c", "abc" ) ); 3047 | 3048 | t.true ( isMatch ( "*****?", "a" ) ); 3049 | t.true ( isMatch ( "*****?", "aa" ) ); 3050 | t.true ( isMatch ( "*****?", "abc" ) ); 3051 | t.true ( isMatch ( "*****?", "zzz" ) ); 3052 | t.true ( isMatch ( "*****?", "bbb" ) ); 3053 | t.true ( isMatch ( "*****?", "aaaa" ) ); 3054 | 3055 | t.true ( !isMatch ( "*****??", "a" ) ); 3056 | t.true ( isMatch ( "*****??", "aa" ) ); 3057 | t.true ( isMatch ( "*****??", "abc" ) ); 3058 | t.true ( isMatch ( "*****??", "zzz" ) ); 3059 | t.true ( isMatch ( "*****??", "bbb" ) ); 3060 | t.true ( isMatch ( "*****??", "aaaa" ) ); 3061 | 3062 | t.true ( !isMatch ( "?*****??", "a" ) ); 3063 | t.true ( !isMatch ( "?*****??", "aa" ) ); 3064 | t.true ( isMatch ( "?*****??", "abc" ) ); 3065 | t.true ( isMatch ( "?*****??", "zzz" ) ); 3066 | t.true ( isMatch ( "?*****??", "bbb" ) ); 3067 | t.true ( isMatch ( "?*****??", "aaaa" ) ); 3068 | 3069 | t.true ( isMatch ( "?*****?c", "abc" ) ); 3070 | t.true ( !isMatch ( "?*****?c", "abb" ) ); 3071 | t.true ( !isMatch ( "?*****?c", "zzz" ) ); 3072 | 3073 | t.true ( isMatch ( "?***?****c", "abc" ) ); 3074 | t.true ( !isMatch ( "?***?****c", "bbb" ) ); 3075 | t.true ( !isMatch ( "?***?****c", "zzz" ) ); 3076 | 3077 | t.true ( isMatch ( "?***?****?", "abc" ) ); 3078 | t.true ( isMatch ( "?***?****?", "bbb" ) ); 3079 | t.true ( isMatch ( "?***?****?", "zzz" ) ); 3080 | 3081 | t.true ( isMatch ( "?***?****", "abc" ) ); 3082 | t.true ( isMatch ( "*******c", "abc" ) ); 3083 | t.true ( isMatch ( "*******?", "abc" ) ); 3084 | t.true ( isMatch ( "a*cd**?**??k", "abcdecdhjk" ) ); 3085 | t.true ( isMatch ( "a**?**cd**?**??k", "abcdecdhjk" ) ); 3086 | t.true ( isMatch ( "a**?**cd**?**??k***", "abcdecdhjk" ) ); 3087 | t.true ( isMatch ( "a**?**cd**?**??***k", "abcdecdhjk" ) ); 3088 | t.true ( isMatch ( "a**?**cd**?**??***k**", "abcdecdhjk" ) ); 3089 | t.true ( isMatch ( "a****c**?**??*****", "abcdecdhjk" ) ); 3090 | 3091 | t.true ( !isMatch ( "a/?/c/?/*/e.md", "a/b/c/d/e.md" ) ); 3092 | t.true ( isMatch ( "a/?/c/?/*/e.md", "a/b/c/d/e/e.md" ) ); 3093 | t.true ( isMatch ( "a/?/c/?/*/e.md", "a/b/c/d/efghijk/e.md" ) ); 3094 | t.true ( isMatch ( "a/?/**/e.md", "a/b/c/d/efghijk/e.md" ) ); 3095 | t.true ( !isMatch ( "a/?/e.md", "a/bb/e.md" ) ); 3096 | t.true ( isMatch ( "a/??/e.md", "a/bb/e.md" ) ); 3097 | t.true ( !isMatch ( "a/?/**/e.md", "a/bb/e.md" ) ); 3098 | t.true ( isMatch ( "a/?/**/e.md", "a/b/ccc/e.md" ) ); 3099 | t.true ( isMatch ( "a/*/?/**/e.md", "a/b/c/d/efghijk/e.md" ) ); 3100 | t.true ( isMatch ( "a/*/?/**/e.md", "a/b/c/d/efgh.ijk/e.md" ) ); 3101 | t.true ( isMatch ( "a/*/?/**/e.md", "a/b.bb/c/d/efgh.ijk/e.md" ) ); 3102 | t.true ( isMatch ( "a/*/?/**/e.md", "a/bbb/c/d/efgh.ijk/e.md" ) ); 3103 | 3104 | t.true ( isMatch ( "a/*/ab??.md", "a/bbb/abcd.md" ) ); 3105 | t.true ( isMatch ( "a/bbb/ab??.md", "a/bbb/abcd.md" ) ); 3106 | t.true ( isMatch ( "a/bbb/ab???md", "a/bbb/abcd.md" ) ); 3107 | 3108 | }); 3109 | 3110 | it ( 'fuzz_tests', t => { 3111 | 3112 | const problem1 = "{*{??*{??**,Uz*zz}w**{*{**a,z***b*[!}w??*azzzzzzzz*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!z[za,z&zz}w**z*z*}"; 3113 | t.true ( !isMatch ( problem1, problem1 ) ); 3114 | 3115 | const problem2 = "**** *{*{??*{??***\u{5} *{*{??*{??***\u{5},\0U\0}]*****\u{1},\0***\0,\0\0}w****,\0U\0}]*****\u{1},\0***\0,\0\0}w*****\u{1}***{}*.*\0\0*\0"; 3116 | t.true ( !isMatch ( problem2, problem2 ) ); 3117 | 3118 | }); 3119 | 3120 | }); 3121 | --------------------------------------------------------------------------------