mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-31 04:35:14 +01:00
debug test: get encoded debug data
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import * as assert from 'assert';
|
||||
import uri from 'vs/base/common/uri';
|
||||
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
|
||||
import { normalize } from 'vs/base/common/paths';
|
||||
|
||||
suite('Debug - Source', () => {
|
||||
|
||||
@@ -37,4 +38,22 @@ suite('Debug - Source', () => {
|
||||
assert.equal(source.reference, 11);
|
||||
assert.equal(source.uri.toString(), 'debug:internalModule.js?session%3DaDebugSessionId%26ref%3D11');
|
||||
});
|
||||
|
||||
test('get encoded debug data', () => {
|
||||
const checkData = (uri: uri, expectedName, expectedPath, expectedSourceReference, expectedProcessId) => {
|
||||
let { name, path, sourceReference, processId } = Source.getEncodedDebugData(uri);
|
||||
assert.equal(name, expectedName);
|
||||
assert.equal(path, expectedPath);
|
||||
assert.equal(sourceReference, expectedSourceReference);
|
||||
assert.equal(processId, expectedProcessId);
|
||||
};
|
||||
|
||||
checkData(uri.file('a/b/c/d'), 'd', normalize('/a/b/c/d', true), undefined, undefined);
|
||||
checkData(uri.from({ scheme: 'file', path: '/my/path/test.js', query: 'ref=1&session=2' }), 'test.js', normalize('/my/path/test.js', true), undefined, undefined);
|
||||
|
||||
checkData(uri.from({ scheme: 'http', authority: 'www.msft.com', path: '/my/path' }), 'path', 'http://www.msft.com/my/path', undefined, undefined);
|
||||
checkData(uri.from({ scheme: 'debug', authority: 'www.msft.com', path: '/my/path', query: 'ref=100' }), 'path', '/my/path', 100, undefined);
|
||||
checkData(uri.from({ scheme: 'debug', path: 'a/b/c/d.js', query: 'session=100' }), 'd.js', 'a/b/c/d.js', undefined, 100);
|
||||
checkData(uri.from({ scheme: 'debug', path: 'a/b/c/d/foo.txt', query: 'session=100&ref=10' }), 'foo.txt', 'a/b/c/d/foo.txt', 10, 100);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user