Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/base/test/common/marshalling.test.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
import assert from 'assert';
6
import { parse, stringify } from '../../common/marshalling.js';
7
import { URI } from '../../common/uri.js';
8
import { ensureNoDisposablesAreLeakedInTestSuite } from './utils.js';
9
10
suite('Marshalling', () => {
11
12
ensureNoDisposablesAreLeakedInTestSuite();
13
14
test('RegExp', () => {
15
const value = /foo/img;
16
const raw = stringify(value);
17
const clone = <RegExp>parse(raw);
18
19
assert.strictEqual(value.source, clone.source);
20
assert.strictEqual(value.global, clone.global);
21
assert.strictEqual(value.ignoreCase, clone.ignoreCase);
22
assert.strictEqual(value.multiline, clone.multiline);
23
});
24
25
test('URI', () => {
26
const value = URI.from({ scheme: 'file', authority: 'server', path: '/shares/c#files', query: 'q', fragment: 'f' });
27
const raw = stringify(value);
28
const clone = <URI>parse(raw);
29
30
assert.strictEqual(value.scheme, clone.scheme);
31
assert.strictEqual(value.authority, clone.authority);
32
assert.strictEqual(value.path, clone.path);
33
assert.strictEqual(value.query, clone.query);
34
assert.strictEqual(value.fragment, clone.fragment);
35
});
36
37
test('Bug 16793:# in folder name => mirror models get out of sync', () => {
38
const uri1 = URI.file('C:\\C#\\file.txt');
39
assert.strictEqual(parse(stringify(uri1)).toString(), uri1.toString());
40
});
41
});
42
43