提交 5874ba84 编写于 作者: K Kermit Xuan 提交者: Benjamin Pasero

Enable strict null checking for common/uri common/map node/pfs and node/glob test (#65488)

* Enable strict null checking for String test

* Enable strict null checking for Uri test

* Enable strict null checking for Map test

* Enable strict null checking for node/pfs test

* Enable strict null checking for node/glob test
上级 5305f993
......@@ -140,6 +140,7 @@
"./vs/base/test/common/labels.test.ts",
"./vs/base/test/common/lifecycle.test.ts",
"./vs/base/test/common/linkedList.test.ts",
"./vs/base/test/common/map.test.ts",
"./vs/base/test/common/marshalling.test.ts",
"./vs/base/test/common/mime.test.ts",
"./vs/base/test/common/objects.test.ts",
......@@ -150,13 +151,16 @@
"./vs/base/test/common/scrollable.test.ts",
"./vs/base/test/common/strings.test.ts",
"./vs/base/test/common/types.test.ts",
"./vs/base/test/common/uri.test.ts",
"./vs/base/test/common/utils.ts",
"./vs/base/test/common/uuid.test.ts",
"./vs/base/test/node/console.test.ts",
"./vs/base/test/node/decoder.test.ts",
"./vs/base/test/node/encoding/encoding.test.ts",
"./vs/base/test/node/id.test.ts",
"./vs/base/test/node/glob.test.ts",
"./vs/base/test/node/port.test.ts",
"./vs/base/test/node/pfs.test.ts",
"./vs/base/test/node/processes/fixtures/fork.ts",
"./vs/base/test/node/processes/fixtures/fork_large.ts",
"./vs/base/test/node/processes/processes.test.ts",
......
......@@ -140,7 +140,7 @@ suite('Map', () => {
assert.strictEqual(cache.size, 5);
assert.deepStrictEqual(cache.keys(), [3, 4, 5, 6, 7]);
let values: number[] = [];
[3, 4, 5, 6, 7].forEach(key => values.push(cache.get(key)));
[3, 4, 5, 6, 7].forEach(key => values.push(cache.get(key)!));
assert.deepStrictEqual(values, [3, 4, 5, 6, 7]);
});
......@@ -155,7 +155,7 @@ suite('Map', () => {
cache.peek(4);
assert.deepStrictEqual(cache.keys(), [1, 2, 4, 5, 3]);
let values: number[] = [];
[1, 2, 3, 4, 5].forEach(key => values.push(cache.get(key)));
[1, 2, 3, 4, 5].forEach(key => values.push(cache.get(key)!));
assert.deepStrictEqual(values, [1, 2, 3, 4, 5]);
});
......@@ -177,7 +177,7 @@ suite('Map', () => {
assert.deepEqual(cache.size, 15);
let values: number[] = [];
for (let i = 6; i <= 20; i++) {
values.push(cache.get(i));
values.push(cache.get(i)!);
assert.strictEqual(cache.get(i), i);
}
assert.deepStrictEqual(cache.values(), values);
......@@ -194,7 +194,7 @@ suite('Map', () => {
assert.strictEqual(cache.size, 5);
assert.deepStrictEqual(cache.keys(), [7, 8, 9, 10, 11]);
let values: number[] = [];
cache.keys().forEach(key => values.push(cache.get(key)));
cache.keys().forEach(key => values.push(cache.get(key)!));
assert.deepStrictEqual(values, [7, 8, 9, 10, 11]);
assert.deepStrictEqual(cache.values(), values);
});
......@@ -588,7 +588,7 @@ suite('Map', () => {
test('mapToSerializable / serializableToMap', function () {
const map = new Map<string, string>();
map.set('1', 'foo');
map.set('2', null);
map.set('2', null!);
map.set('3', 'bar');
const map2 = serializableToMap(mapToSerializable(map));
......
......@@ -91,9 +91,9 @@ suite('URI', () => {
test('with, identity', () => {
let uri = URI.parse('foo:bar/path');
let uri2 = uri.with(null);
let uri2 = uri.with(null!);
assert.ok(uri === uri2);
uri2 = uri.with(undefined);
uri2 = uri.with(undefined!);
assert.ok(uri === uri2);
uri2 = uri.with({});
assert.ok(uri === uri2);
......
......@@ -738,24 +738,24 @@ suite('Glob', () => {
});
test('falsy expression/pattern', function () {
assert.strictEqual(glob.match(null, 'foo'), false);
assert.strictEqual(glob.match(null!, 'foo'), false);
assert.strictEqual(glob.match('', 'foo'), false);
assert.strictEqual(glob.parse(null)('foo'), false);
assert.strictEqual(glob.parse(null!)('foo'), false);
assert.strictEqual(glob.parse('')('foo'), false);
});
test('falsy path', function () {
assert.strictEqual(glob.parse('foo')(null), false);
assert.strictEqual(glob.parse('foo')(null!), false);
assert.strictEqual(glob.parse('foo')(''), false);
assert.strictEqual(glob.parse('**/*.j?')(null), false);
assert.strictEqual(glob.parse('**/*.j?')(null!), false);
assert.strictEqual(glob.parse('**/*.j?')(''), false);
assert.strictEqual(glob.parse('**/*.foo')(null), false);
assert.strictEqual(glob.parse('**/*.foo')(null!), false);
assert.strictEqual(glob.parse('**/*.foo')(''), false);
assert.strictEqual(glob.parse('**/foo')(null), false);
assert.strictEqual(glob.parse('**/foo')(null!), false);
assert.strictEqual(glob.parse('**/foo')(''), false);
assert.strictEqual(glob.parse('{**/baz,**/foo}')(null), false);
assert.strictEqual(glob.parse('{**/baz,**/foo}')(null!), false);
assert.strictEqual(glob.parse('{**/baz,**/foo}')(''), false);
assert.strictEqual(glob.parse('{**/*.baz,**/*.foo}')(null), false);
assert.strictEqual(glob.parse('{**/*.baz,**/*.foo}')(null!), false);
assert.strictEqual(glob.parse('{**/*.baz,**/*.foo}')(''), false);
});
......@@ -808,7 +808,7 @@ suite('Glob', () => {
}, ['foo', 'bar', 'baz'], [
['bar/foo', '**/foo/**'],
['foo/bar', '{**/bar/**,**/baz/**}'],
['bar/nope', null]
['bar/nope', null!]
]);
const siblings = ['baz', 'baz.zip', 'nope'];
......@@ -817,12 +817,12 @@ suite('Glob', () => {
'**/foo/**': { when: '$(basename).zip' },
'**/bar/**': true
}, ['bar'], [
['bar/foo', null],
['bar/foo/baz', null],
['bar/foo/nope', null],
['bar/foo', null!],
['bar/foo/baz', null!],
['bar/foo/nope', null!],
['foo/bar', '**/bar/**'],
], [
null,
null!,
hasSibling,
hasSibling
]);
......@@ -832,7 +832,7 @@ suite('Glob', () => {
const parsed = glob.parse(<glob.IExpression>pattern, { trimForExclusions: true });
assert.deepStrictEqual(glob.getBasenameTerms(parsed), basenameTerms);
matches.forEach(([text, result], i) => {
assert.strictEqual(parsed(text, null, siblingsFns[i]), result);
assert.strictEqual(parsed(text, null!, siblingsFns[i]), result);
});
}
......@@ -914,7 +914,7 @@ suite('Glob', () => {
[nativeSep('bar/foo/bar'), '**/foo/bar/**'],
// Not supported
// [nativeSep('foo/bar/bar'), '{**/bar/bar/**,**/baz/bar/**}'],
[nativeSep('/foo/bar/nope'), null]
[nativeSep('/foo/bar/nope'), null!]
]);
const siblings = ['baz', 'baz.zip', 'nope'];
......@@ -923,12 +923,12 @@ suite('Glob', () => {
'**/foo/123/**': { when: '$(basename).zip' },
'**/bar/123/**': true
}, ['*/bar/123'], [
[nativeSep('bar/foo/123'), null],
[nativeSep('bar/foo/123/baz'), null],
[nativeSep('bar/foo/123/nope'), null],
[nativeSep('bar/foo/123'), null!],
[nativeSep('bar/foo/123/baz'), null!],
[nativeSep('bar/foo/123/nope'), null!],
[nativeSep('foo/bar/123'), '**/bar/123/**'],
], [
null,
null!,
hasSibling,
hasSibling
]);
......@@ -938,7 +938,7 @@ suite('Glob', () => {
const parsed = glob.parse(<glob.IExpression>pattern, { trimForExclusions: true });
assert.deepStrictEqual(glob.getPathTerms(parsed), pathTerms);
matches.forEach(([text, result], i) => {
assert.strictEqual(parsed(text, null, siblingsFns[i]), result);
assert.strictEqual(parsed(text, null!, siblingsFns[i]), result);
});
}
......
......@@ -24,7 +24,7 @@ suite('PFS', () => {
return pfs.mkdirp(newDir, 493).then(() => {
assert.ok(fs.existsSync(newDir));
return pfs.writeFile(testFile, 'Hello World', null).then(() => {
return pfs.writeFile(testFile, 'Hello World', null!).then(() => {
assert.equal(fs.readFileSync(testFile), 'Hello World');
return pfs.del(parentDir, os.tmpdir());
......@@ -46,11 +46,11 @@ suite('PFS', () => {
assert.ok(fs.existsSync(newDir));
return Promise.all([
pfs.writeFile(testFile1, 'Hello World 1', null),
pfs.writeFile(testFile2, 'Hello World 2', null),
pfs.writeFile(testFile3, 'Hello World 3', null),
pfs.writeFile(testFile4, 'Hello World 4', null),
pfs.writeFile(testFile5, 'Hello World 5', null)
pfs.writeFile(testFile1, 'Hello World 1', null!),
pfs.writeFile(testFile2, 'Hello World 2', null!),
pfs.writeFile(testFile3, 'Hello World 3', null!),
pfs.writeFile(testFile4, 'Hello World 4', null!),
pfs.writeFile(testFile5, 'Hello World 5', null!)
]).then(() => {
assert.equal(fs.readFileSync(testFile1), 'Hello World 1');
assert.equal(fs.readFileSync(testFile2), 'Hello World 2');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册