diff options
Diffstat (limited to 'src/vs/base/test/common/glob.test.ts')
-rw-r--r-- | src/vs/base/test/common/glob.test.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/vs/base/test/common/glob.test.ts b/src/vs/base/test/common/glob.test.ts index ba31ed0099c..7963c4c4139 100644 --- a/src/vs/base/test/common/glob.test.ts +++ b/src/vs/base/test/common/glob.test.ts @@ -1066,6 +1066,18 @@ suite('Glob', () => { } }); + test('relative pattern - single star alone', function () { + if (isWindows) { + let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo\\something\\Program.cs', pattern: '*' }; + assertGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\something\\Program.cs'); + assertNoGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\Program.cs'); + } else { + let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo/something/Program.cs', pattern: '*' }; + assertGlobMatch(p, '/DNXConsoleApp/foo/something/Program.cs'); + assertNoGlobMatch(p, '/DNXConsoleApp/foo/Program.cs'); + } + }); + test('relative pattern - ignores case on macOS/Windows', function () { if (isWindows) { let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: 'something/*.cs' }; @@ -1099,4 +1111,33 @@ suite('Glob', () => { let p = 'scheme:/**/*.md'; assertGlobMatch(p, URI.file('super/duper/long/some/file.md').with({ scheme: 'scheme' }).toString()); }); + + test('expression fails when siblings use promises (https://github.com/microsoft/vscode/issues/146294)', async function () { + let siblings = ['test.html', 'test.txt', 'test.ts']; + let hasSibling = (name: string) => Promise.resolve(siblings.indexOf(name) !== -1); + + // { "**/*.js": { "when": "$(basename).ts" } } + let expression: glob.IExpression = { + '**/test.js': { when: '$(basename).js' }, + '**/*.js': { when: '$(basename).ts' } + }; + + const parsedExpression = glob.parse(expression); + + assert.strictEqual('**/*.js', await parsedExpression('test.js', undefined, hasSibling)); + }); + + test('patternsEquals', () => { + assert.ok(glob.patternsEquals(['a'], ['a'])); + assert.ok(!glob.patternsEquals(['a'], ['b'])); + + assert.ok(glob.patternsEquals(['a', 'b', 'c'], ['a', 'b', 'c'])); + assert.ok(!glob.patternsEquals(['1', '2'], ['1', '3'])); + + assert.ok(glob.patternsEquals([{ base: 'a', pattern: '*' }, 'b', 'c'], [{ base: 'a', pattern: '*' }, 'b', 'c'])); + + assert.ok(glob.patternsEquals(undefined, undefined)); + assert.ok(!glob.patternsEquals(undefined, ['b'])); + assert.ok(!glob.patternsEquals(['a'], undefined)); + }); }); |