提交 7a89df95 编写于 作者: J Johannes Rieken

some more strict asserting tests

上级 3cb3624b
...@@ -11,13 +11,13 @@ suite('MarkdownString', () => { ...@@ -11,13 +11,13 @@ suite('MarkdownString', () => {
test('Escape leading whitespace', function () { test('Escape leading whitespace', function () {
const mds = new MarkdownString(); const mds = new MarkdownString();
mds.appendText('Hello\n Not a code block'); mds.appendText('Hello\n Not a code block');
assert.equal(mds.value, 'Hello\n\n    Not a code block'); assert.strictEqual(mds.value, 'Hello\n\n    Not a code block');
}); });
test('MarkdownString.appendText doesn\'t escape quote #109040', function () { test('MarkdownString.appendText doesn\'t escape quote #109040', function () {
const mds = new MarkdownString(); const mds = new MarkdownString();
mds.appendText('> Text\n>More'); mds.appendText('> Text\n>More');
assert.equal(mds.value, '\\> Text\n\n\\>More'); assert.strictEqual(mds.value, '\\> Text\n\n\\>More');
}); });
test('appendText', () => { test('appendText', () => {
...@@ -25,7 +25,7 @@ suite('MarkdownString', () => { ...@@ -25,7 +25,7 @@ suite('MarkdownString', () => {
const mds = new MarkdownString(); const mds = new MarkdownString();
mds.appendText('# foo\n*bar*'); mds.appendText('# foo\n*bar*');
assert.equal(mds.value, '\\# foo\n\n\\*bar\\*'); assert.strictEqual(mds.value, '\\# foo\n\n\\*bar\\*');
}); });
suite('ThemeIcons', () => { suite('ThemeIcons', () => {
...@@ -36,21 +36,21 @@ suite('MarkdownString', () => { ...@@ -36,21 +36,21 @@ suite('MarkdownString', () => {
const mds = new MarkdownString(undefined, { supportThemeIcons: true }); const mds = new MarkdownString(undefined, { supportThemeIcons: true });
mds.appendText('$(zap) $(not a theme icon) $(add)'); mds.appendText('$(zap) $(not a theme icon) $(add)');
assert.equal(mds.value, '\\\\$\\(zap\\) $\\(not a theme icon\\) \\\\$\\(add\\)'); assert.strictEqual(mds.value, '\\\\$\\(zap\\) $\\(not a theme icon\\) \\\\$\\(add\\)');
}); });
test('appendMarkdown', () => { test('appendMarkdown', () => {
const mds = new MarkdownString(undefined, { supportThemeIcons: true }); const mds = new MarkdownString(undefined, { supportThemeIcons: true });
mds.appendMarkdown('$(zap) $(not a theme icon) $(add)'); mds.appendMarkdown('$(zap) $(not a theme icon) $(add)');
assert.equal(mds.value, '$(zap) $(not a theme icon) $(add)'); assert.strictEqual(mds.value, '$(zap) $(not a theme icon) $(add)');
}); });
test('appendMarkdown with escaped icon', () => { test('appendMarkdown with escaped icon', () => {
const mds = new MarkdownString(undefined, { supportThemeIcons: true }); const mds = new MarkdownString(undefined, { supportThemeIcons: true });
mds.appendMarkdown('\\$(zap) $(not a theme icon) $(add)'); mds.appendMarkdown('\\$(zap) $(not a theme icon) $(add)');
assert.equal(mds.value, '\\$(zap) $(not a theme icon) $(add)'); assert.strictEqual(mds.value, '\\$(zap) $(not a theme icon) $(add)');
}); });
}); });
...@@ -61,21 +61,21 @@ suite('MarkdownString', () => { ...@@ -61,21 +61,21 @@ suite('MarkdownString', () => {
const mds = new MarkdownString(undefined, { supportThemeIcons: false }); const mds = new MarkdownString(undefined, { supportThemeIcons: false });
mds.appendText('$(zap) $(not a theme icon) $(add)'); mds.appendText('$(zap) $(not a theme icon) $(add)');
assert.equal(mds.value, '$\\(zap\\) $\\(not a theme icon\\) $\\(add\\)'); assert.strictEqual(mds.value, '$\\(zap\\) $\\(not a theme icon\\) $\\(add\\)');
}); });
test('appendMarkdown', () => { test('appendMarkdown', () => {
const mds = new MarkdownString(undefined, { supportThemeIcons: false }); const mds = new MarkdownString(undefined, { supportThemeIcons: false });
mds.appendMarkdown('$(zap) $(not a theme icon) $(add)'); mds.appendMarkdown('$(zap) $(not a theme icon) $(add)');
assert.equal(mds.value, '$(zap) $(not a theme icon) $(add)'); assert.strictEqual(mds.value, '$(zap) $(not a theme icon) $(add)');
}); });
test('appendMarkdown with escaped icon', () => { test('appendMarkdown with escaped icon', () => {
const mds = new MarkdownString(undefined, { supportThemeIcons: true }); const mds = new MarkdownString(undefined, { supportThemeIcons: true });
mds.appendMarkdown('\\$(zap) $(not a theme icon) $(add)'); mds.appendMarkdown('\\$(zap) $(not a theme icon) $(add)');
assert.equal(mds.value, '\\$(zap) $(not a theme icon) $(add)'); assert.strictEqual(mds.value, '\\$(zap) $(not a theme icon) $(add)');
}); });
}); });
......
...@@ -12,45 +12,45 @@ import { binarySearch } from 'vs/base/common/arrays'; ...@@ -12,45 +12,45 @@ import { binarySearch } from 'vs/base/common/arrays';
suite('SkipList', function () { suite('SkipList', function () {
function assertValues<V>(list: SkipList<any, V>, expected: V[]) { function assertValues<V>(list: SkipList<any, V>, expected: V[]) {
assert.equal(list.size, expected.length); assert.strictEqual(list.size, expected.length);
assert.deepEqual([...list.values()], expected); assert.deepStrictEqual([...list.values()], expected);
let valuesFromEntries = [...list.entries()].map(entry => entry[1]); let valuesFromEntries = [...list.entries()].map(entry => entry[1]);
assert.deepEqual(valuesFromEntries, expected); assert.deepStrictEqual(valuesFromEntries, expected);
let valuesFromIter = [...list].map(entry => entry[1]); let valuesFromIter = [...list].map(entry => entry[1]);
assert.deepEqual(valuesFromIter, expected); assert.deepStrictEqual(valuesFromIter, expected);
let i = 0; let i = 0;
list.forEach((value, _key, map) => { list.forEach((value, _key, map) => {
assert.ok(map === list); assert.ok(map === list);
assert.deepEqual(value, expected[i++]); assert.deepStrictEqual(value, expected[i++]);
}); });
} }
function assertKeys<K>(list: SkipList<K, any>, expected: K[]) { function assertKeys<K>(list: SkipList<K, any>, expected: K[]) {
assert.equal(list.size, expected.length); assert.strictEqual(list.size, expected.length);
assert.deepEqual([...list.keys()], expected); assert.deepStrictEqual([...list.keys()], expected);
let keysFromEntries = [...list.entries()].map(entry => entry[0]); let keysFromEntries = [...list.entries()].map(entry => entry[0]);
assert.deepEqual(keysFromEntries, expected); assert.deepStrictEqual(keysFromEntries, expected);
let keysFromIter = [...list].map(entry => entry[0]); let keysFromIter = [...list].map(entry => entry[0]);
assert.deepEqual(keysFromIter, expected); assert.deepStrictEqual(keysFromIter, expected);
let i = 0; let i = 0;
list.forEach((_value, key, map) => { list.forEach((_value, key, map) => {
assert.ok(map === list); assert.ok(map === list);
assert.deepEqual(key, expected[i++]); assert.deepStrictEqual(key, expected[i++]);
}); });
} }
test('set/get/delete', function () { test('set/get/delete', function () {
let list = new SkipList<number, number>((a, b) => a - b); let list = new SkipList<number, number>((a, b) => a - b);
assert.equal(list.get(3), undefined); assert.strictEqual(list.get(3), undefined);
list.set(3, 1); list.set(3, 1);
assert.equal(list.get(3), 1); assert.strictEqual(list.get(3), 1);
assertValues(list, [1]); assertValues(list, [1]);
list.set(3, 3); list.set(3, 3);
...@@ -58,17 +58,17 @@ suite('SkipList', function () { ...@@ -58,17 +58,17 @@ suite('SkipList', function () {
list.set(1, 1); list.set(1, 1);
list.set(4, 4); list.set(4, 4);
assert.equal(list.get(3), 3); assert.strictEqual(list.get(3), 3);
assert.equal(list.get(1), 1); assert.strictEqual(list.get(1), 1);
assert.equal(list.get(4), 4); assert.strictEqual(list.get(4), 4);
assertValues(list, [1, 3, 4]); assertValues(list, [1, 3, 4]);
assert.equal(list.delete(17), false); assert.strictEqual(list.delete(17), false);
assert.equal(list.delete(1), true); assert.strictEqual(list.delete(1), true);
assert.equal(list.get(1), undefined); assert.strictEqual(list.get(1), undefined);
assert.equal(list.get(3), 3); assert.strictEqual(list.get(3), 3);
assert.equal(list.get(4), 4); assert.strictEqual(list.get(4), 4);
assertValues(list, [3, 4]); assertValues(list, [3, 4]);
}); });
...@@ -87,7 +87,7 @@ suite('SkipList', function () { ...@@ -87,7 +87,7 @@ suite('SkipList', function () {
assertKeys(list, [3, 6, 7, 9, 12, 19, 21, 25]); assertKeys(list, [3, 6, 7, 9, 12, 19, 21, 25]);
list.set(17, true); list.set(17, true);
assert.deepEqual(list.size, 9); assert.deepStrictEqual(list.size, 9);
assertKeys(list, [3, 6, 7, 9, 12, 17, 19, 21, 25]); assertKeys(list, [3, 6, 7, 9, 12, 17, 19, 21, 25]);
}); });
......
此差异已折叠。
...@@ -8,8 +8,8 @@ import * as uuid from 'vs/base/common/uuid'; ...@@ -8,8 +8,8 @@ import * as uuid from 'vs/base/common/uuid';
suite('UUID', () => { suite('UUID', () => {
test('generation', () => { test('generation', () => {
const asHex = uuid.generateUuid(); const asHex = uuid.generateUuid();
assert.equal(asHex.length, 36); assert.strictEqual(asHex.length, 36);
assert.equal(asHex[14], '4'); assert.strictEqual(asHex[14], '4');
assert.ok(asHex[19] === '8' || asHex[19] === '9' || asHex[19] === 'a' || asHex[19] === 'b'); assert.ok(asHex[19] === '8' || asHex[19] === '9' || asHex[19] === 'a' || asHex[19] === 'b');
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册