Update to VS Code 1.52.1
This commit is contained in:
@@ -197,7 +197,7 @@ suite('Comparers', () => {
|
||||
// name-only comparisons
|
||||
assert(compareFileNamesDefault('a', 'A') === compareLocale('a', 'A'), 'the same letter sorts by locale');
|
||||
assert(compareFileNamesDefault('â', 'Â') === compareLocale('â', 'Â'), 'the same accented letter sorts by locale');
|
||||
assert.deepEqual(['artichoke', 'Artichoke', 'art', 'Art'].sort(compareFileNamesDefault), ['artichoke', 'Artichoke', 'art', 'Art'].sort(compareLocale), 'words with the same root and different cases sort in locale order');
|
||||
// assert.deepEqual(['artichoke', 'Artichoke', 'art', 'Art'].sort(compareFileNamesDefault), ['artichoke', 'Artichoke', 'art', 'Art'].sort(compareLocale), 'words with the same root and different cases sort in locale order');
|
||||
assert.deepEqual(['email', 'Email', 'émail', 'Émail'].sort(compareFileNamesDefault), ['email', 'Email', 'émail', 'Émail'].sort(compareLocale), 'the same base characters with different case or accents sort in locale order');
|
||||
|
||||
// numeric comparisons
|
||||
@@ -259,7 +259,7 @@ suite('Comparers', () => {
|
||||
// name-only comparisons
|
||||
assert(compareFileExtensionsDefault('a', 'A') === compareLocale('a', 'A'), 'the same letter of different case sorts by locale');
|
||||
assert(compareFileExtensionsDefault('â', 'Â') === compareLocale('â', 'Â'), 'the same accented letter of different case sorts by locale');
|
||||
assert.deepEqual(['artichoke', 'Artichoke', 'art', 'Art'].sort(compareFileExtensionsDefault), ['artichoke', 'Artichoke', 'art', 'Art'].sort(compareLocale), 'words with the same root and different cases sort in locale order');
|
||||
// assert.deepEqual(['artichoke', 'Artichoke', 'art', 'Art'].sort(compareFileExtensionsDefault), ['artichoke', 'Artichoke', 'art', 'Art'].sort(compareLocale), 'words with the same root and different cases sort in locale order');
|
||||
assert.deepEqual(['email', 'Email', 'émail', 'Émail'].sort(compareFileExtensionsDefault), ['email', 'Email', 'émail', 'Émail'].sort((a, b) => a.localeCompare(b)), 'the same base characters with different case or accents sort in locale order');
|
||||
|
||||
// name plus extension comparisons
|
||||
|
||||
104
lib/vscode/src/vs/base/test/browser/hash.test.ts
Normal file
104
lib/vscode/src/vs/base/test/browser/hash.test.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { hash, StringSHA1 } from 'vs/base/common/hash';
|
||||
import { sha1Hex } from 'vs/base/browser/hash';
|
||||
|
||||
suite('Hash', () => {
|
||||
test('string', () => {
|
||||
assert.equal(hash('hello'), hash('hello'));
|
||||
assert.notEqual(hash('hello'), hash('world'));
|
||||
assert.notEqual(hash('hello'), hash('olleh'));
|
||||
assert.notEqual(hash('hello'), hash('Hello'));
|
||||
assert.notEqual(hash('hello'), hash('Hello '));
|
||||
assert.notEqual(hash('h'), hash('H'));
|
||||
assert.notEqual(hash('-'), hash('_'));
|
||||
});
|
||||
|
||||
test('number', () => {
|
||||
assert.equal(hash(1), hash(1));
|
||||
assert.notEqual(hash(0), hash(1));
|
||||
assert.notEqual(hash(1), hash(-1));
|
||||
assert.notEqual(hash(0x12345678), hash(0x123456789));
|
||||
});
|
||||
|
||||
test('boolean', () => {
|
||||
assert.equal(hash(true), hash(true));
|
||||
assert.notEqual(hash(true), hash(false));
|
||||
});
|
||||
|
||||
test('array', () => {
|
||||
assert.equal(hash([1, 2, 3]), hash([1, 2, 3]));
|
||||
assert.equal(hash(['foo', 'bar']), hash(['foo', 'bar']));
|
||||
assert.equal(hash([]), hash([]));
|
||||
assert.equal(hash([]), hash(new Array()));
|
||||
assert.notEqual(hash(['foo', 'bar']), hash(['bar', 'foo']));
|
||||
assert.notEqual(hash(['foo', 'bar']), hash(['bar', 'foo', null]));
|
||||
assert.notEqual(hash(['foo', 'bar', null]), hash(['bar', 'foo', null]));
|
||||
assert.notEqual(hash(['foo', 'bar']), hash(['bar', 'foo', undefined]));
|
||||
assert.notEqual(hash(['foo', 'bar', undefined]), hash(['bar', 'foo', undefined]));
|
||||
assert.notEqual(hash(['foo', 'bar', null]), hash(['foo', 'bar', undefined]));
|
||||
});
|
||||
|
||||
test('object', () => {
|
||||
assert.equal(hash({}), hash({}));
|
||||
assert.equal(hash({}), hash(Object.create(null)));
|
||||
assert.equal(hash({ 'foo': 'bar' }), hash({ 'foo': 'bar' }));
|
||||
assert.equal(hash({ 'foo': 'bar', 'foo2': undefined }), hash({ 'foo2': undefined, 'foo': 'bar' }));
|
||||
assert.notEqual(hash({ 'foo': 'bar' }), hash({ 'foo': 'bar2' }));
|
||||
assert.notEqual(hash({}), hash([]));
|
||||
});
|
||||
|
||||
test('array - unexpected collision', function () {
|
||||
const a = hash([undefined, undefined, undefined, undefined, undefined]);
|
||||
const b = hash([undefined, undefined, 'HHHHHH', [{ line: 0, character: 0 }, { line: 0, character: 0 }], undefined]);
|
||||
assert.notEqual(a, b);
|
||||
});
|
||||
|
||||
test('all different', () => {
|
||||
const candidates: any[] = [
|
||||
null, undefined, {}, [], 0, false, true, '', ' ', [null], [undefined], [undefined, undefined], { '': undefined }, { [' ']: undefined },
|
||||
'ab', 'ba', ['ab']
|
||||
];
|
||||
const hashes: number[] = candidates.map(hash);
|
||||
for (let i = 0; i < hashes.length; i++) {
|
||||
assert.equal(hashes[i], hash(candidates[i])); // verify that repeated invocation returns the same hash
|
||||
for (let k = i + 1; k < hashes.length; k++) {
|
||||
assert.notEqual(hashes[i], hashes[k], `Same hash ${hashes[i]} for ${JSON.stringify(candidates[i])} and ${JSON.stringify(candidates[k])}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
async function checkSHA1(str: string, expected: string) {
|
||||
|
||||
// Test with StringSHA1
|
||||
const hash = new StringSHA1();
|
||||
hash.update(str);
|
||||
let actual = hash.digest();
|
||||
assert.equal(actual, expected);
|
||||
|
||||
// Test with crypto.subtle
|
||||
actual = await sha1Hex(str);
|
||||
assert.equal(actual, expected);
|
||||
}
|
||||
|
||||
test('sha1-1', () => {
|
||||
return checkSHA1('\udd56', '9bdb77276c1852e1fb067820472812fcf6084024');
|
||||
});
|
||||
|
||||
test('sha1-2', () => {
|
||||
return checkSHA1('\udb52', '9bdb77276c1852e1fb067820472812fcf6084024');
|
||||
});
|
||||
|
||||
test('sha1-3', () => {
|
||||
return checkSHA1('\uda02ꑍ', '9b483a471f22fe7e09d83f221871a987244bbd3f');
|
||||
});
|
||||
|
||||
test('sha1-4', () => {
|
||||
return checkSHA1('hello', 'aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d');
|
||||
});
|
||||
});
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as marked from 'vs/base/common/marked/marked';
|
||||
import { renderMarkdown } from 'vs/base/browser/markdownRenderer';
|
||||
import { renderMarkdown, renderMarkdownAsPlaintext } from 'vs/base/browser/markdownRenderer';
|
||||
import { MarkdownString, IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { parse } from 'vs/base/common/marshalling';
|
||||
@@ -57,7 +57,7 @@ suite('MarkdownRenderer', () => {
|
||||
mds.appendText('$(zap) $(not a theme icon) $(add)');
|
||||
|
||||
let result: HTMLElement = renderMarkdown(mds);
|
||||
assert.strictEqual(result.innerHTML, `<p>$(zap) $(not a theme icon) $(add)</p>`);
|
||||
assert.strictEqual(result.innerHTML, `<p>$(zap) $(not a theme icon) $(add)</p>`);
|
||||
});
|
||||
|
||||
test('render appendMarkdown', () => {
|
||||
@@ -85,7 +85,7 @@ suite('MarkdownRenderer', () => {
|
||||
mds.appendText('$(zap) $(not a theme icon) $(add)');
|
||||
|
||||
let result: HTMLElement = renderMarkdown(mds);
|
||||
assert.strictEqual(result.innerHTML, `<p>$(zap) $(not a theme icon) $(add)</p>`);
|
||||
assert.strictEqual(result.innerHTML, `<p>$(zap) $(not a theme icon) $(add)</p>`);
|
||||
});
|
||||
|
||||
test('render appendMarkdown with escaped icon', () => {
|
||||
@@ -115,4 +115,20 @@ suite('MarkdownRenderer', () => {
|
||||
assert.ok(data.documentUri.toString().startsWith('file:///c%3A/'));
|
||||
});
|
||||
|
||||
suite('PlaintextMarkdownRender', () => {
|
||||
|
||||
test('test code, blockquote, heading, list, listitem, paragraph, table, tablerow, tablecell, strong, em, br, del, text are rendered plaintext', () => {
|
||||
const markdown = { value: '`code`\n>quote\n# heading\n- list\n\n\ntable | table2\n--- | --- \none | two\n\n\nbo**ld**\n_italic_\n~~del~~\nsome text' };
|
||||
const expected = 'code\nquote\nheading\nlist\ntable table2 one two \nbold\nitalic\ndel\nsome text\n';
|
||||
const result: string = renderMarkdownAsPlaintext(markdown);
|
||||
assert.strictEqual(result, expected);
|
||||
});
|
||||
|
||||
test('test html, hr, image, link are rendered plaintext', () => {
|
||||
const markdown = { value: '<div>html</div>\n\n---\n\n[text](textLink)' };
|
||||
const expected = '\ntext\n';
|
||||
const result: string = renderMarkdownAsPlaintext(markdown);
|
||||
assert.strictEqual(result, expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,8 +18,11 @@ suite('ScrollbarState', () => {
|
||||
assert.equal(actual.getSliderSize(), 20);
|
||||
assert.equal(actual.getSliderPosition(), 249);
|
||||
|
||||
|
||||
assert.equal(actual.getDesiredScrollPositionFromOffset(259), 32849);
|
||||
|
||||
// 259 is greater than 230 so page down, 32787 + 339 = 33126
|
||||
assert.equal(actual.getDesiredScrollPositionFromOffsetPaged(259), 33126);
|
||||
|
||||
actual.setScrollPosition(32849);
|
||||
assert.equal(actual.getArrowSize(), 0);
|
||||
assert.equal(actual.getScrollPosition(), 32849);
|
||||
@@ -41,8 +44,11 @@ suite('ScrollbarState', () => {
|
||||
assert.equal(actual.getSliderSize(), 20);
|
||||
assert.equal(actual.getSliderPosition(), 230);
|
||||
|
||||
|
||||
assert.equal(actual.getDesiredScrollPositionFromOffset(240 + 12), 32811);
|
||||
|
||||
// 240 + 12 = 252; greater than 230 so page down, 32787 + 339 = 33126
|
||||
assert.equal(actual.getDesiredScrollPositionFromOffsetPaged(240 + 12), 33126);
|
||||
|
||||
actual.setScrollPosition(32811);
|
||||
assert.equal(actual.getArrowSize(), 12);
|
||||
assert.equal(actual.getScrollPosition(), 32811);
|
||||
|
||||
@@ -91,7 +91,7 @@ suite('Splitview', () => {
|
||||
splitview.addView(view2, 20);
|
||||
splitview.addView(view3, 20);
|
||||
|
||||
let viewQuery = container.querySelectorAll('.monaco-split-view2 > .split-view-container > .split-view-view');
|
||||
let viewQuery = container.querySelectorAll('.monaco-split-view2 > .monaco-scrollable-element > .split-view-container > .split-view-view');
|
||||
assert.equal(viewQuery.length, 3, 'split view should have 3 views');
|
||||
|
||||
let sashQuery = container.querySelectorAll('.monaco-split-view2 > .sash-container > .monaco-sash');
|
||||
@@ -99,7 +99,7 @@ suite('Splitview', () => {
|
||||
|
||||
splitview.removeView(2);
|
||||
|
||||
viewQuery = container.querySelectorAll('.monaco-split-view2 > .split-view-container > .split-view-view');
|
||||
viewQuery = container.querySelectorAll('.monaco-split-view2 > .monaco-scrollable-element > .split-view-container > .split-view-view');
|
||||
assert.equal(viewQuery.length, 2, 'split view should have 2 views');
|
||||
|
||||
sashQuery = container.querySelectorAll('.monaco-split-view2 > .sash-container > .monaco-sash');
|
||||
@@ -107,7 +107,7 @@ suite('Splitview', () => {
|
||||
|
||||
splitview.removeView(0);
|
||||
|
||||
viewQuery = container.querySelectorAll('.monaco-split-view2 > .split-view-container > .split-view-view');
|
||||
viewQuery = container.querySelectorAll('.monaco-split-view2 > .monaco-scrollable-element > .split-view-container > .split-view-view');
|
||||
assert.equal(viewQuery.length, 1, 'split view should have 1 view');
|
||||
|
||||
sashQuery = container.querySelectorAll('.monaco-split-view2 > .sash-container > .monaco-sash');
|
||||
@@ -115,7 +115,7 @@ suite('Splitview', () => {
|
||||
|
||||
splitview.removeView(0);
|
||||
|
||||
viewQuery = container.querySelectorAll('.monaco-split-view2 > .split-view-container > .split-view-view');
|
||||
viewQuery = container.querySelectorAll('.monaco-split-view2 > .monaco-scrollable-element > .split-view-container > .split-view-view');
|
||||
assert.equal(viewQuery.length, 0, 'split view should have no views');
|
||||
|
||||
sashQuery = container.querySelectorAll('.monaco-split-view2 > .sash-container > .monaco-sash');
|
||||
|
||||
Reference in New Issue
Block a user