Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137/** Equivalence tests for `firstGlobMetaIndex`. Capture the pre-refactor behavior of the glob metacharacter scanner so the linear-pass rewrite stays behavior-identical: empty input, a literal path with no metacharacter, each metacharacter in `*?{[`, the first of several metacharacters winning, path separators (`/` and `\`) treated as ordinary characters rather than metacharacters, and a long no-match run. @module */
import { describe, expect, it,} from '@monochromatic-dev/module-test/ts';
import { firstGlobMetaIndex, } from '../dist/final/node/testing.mjs';
/** Iteration count for the long no-match run; large enough to exercise the linear scan, fast to compare. */const LONG_RUN = 100_000;
await describe({ name: '', children: [ describe({ name: firstGlobMetaIndex.name, children: [ it({ name: 'returns -1 for empty input', fn: async () => { expect(firstGlobMetaIndex('',),).toBe(-1,); }, },),
it({ name: 'returns -1 for a literal path with no metacharacter', fn: async () => { expect(firstGlobMetaIndex('src/index.ts',),).toBe(-1,); }, },),
it({ name: 'returns -1 for an all-whitespace string', fn: async () => { expect(firstGlobMetaIndex(' ',),).toBe(-1,); }, },),
it({ name: 'finds a metacharacter at index 0', fn: async () => { expect(firstGlobMetaIndex('*.ts',),).toBe(0,); }, },),
it({ name: 'finds a star after a static prefix', fn: async () => { expect(firstGlobMetaIndex('src/*.ts',),).toBe(4,); }, },),
it({ name: 'finds a trailing star', fn: async () => { expect(firstGlobMetaIndex('src/**',),).toBe(4,); }, },),
it({ name: 'finds a question mark', fn: async () => { expect(firstGlobMetaIndex('a?b',),).toBe(1,); }, },),
it({ name: 'finds an opening brace', fn: async () => { expect(firstGlobMetaIndex('a{b,c}',),).toBe(1,); }, },),
it({ name: 'finds an opening bracket', fn: async () => { expect(firstGlobMetaIndex('a[bc]',),).toBe(1,); }, },),
it({ name: 'returns the first of several metacharacters', fn: async () => { expect(firstGlobMetaIndex('a*b?c',),).toBe(1,); }, },),
it({ name: 'finds a metacharacter after a leading separator', fn: async () => { expect(firstGlobMetaIndex('/abs/*.ts',),).toBe(5,); }, },),
it({ name: 'treats both path separators as ordinary characters', fn: async () => { expect(firstGlobMetaIndex( String.raw`src\sub/*.ts`, ),) .toBe(8,); }, },),
it({ name: 'returns -1 for a long no-metacharacter run', fn: async () => { expect( firstGlobMetaIndex('a'.repeat(LONG_RUN,),), ).toBe(-1,); }, },),
it({ name: 'finds a metacharacter after a long static prefix', fn: async () => { const prefix = 'a'.repeat(LONG_RUN,); expect(firstGlobMetaIndex(`${prefix}*`,),).toBe(LONG_RUN,); }, },), ], },), ],},);