提交 25d37c7c 编写于 作者: J Johannes Rieken

slash, backslash fun

上级 a5357b27
......@@ -5,22 +5,31 @@
'use strict';
import { isWindows } from 'vs/base/common/platform';
import * as assert from 'assert';
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
import { TestThreadService } from './testThreadService';
suite('ExtHostWorkspace', function () {
function fsPath(path: string): string {
if (isWindows) {
return path.replace(/\//g, '\\');
} else {
return path;
}
}
test('asRelativePath', function () {
const ws = new ExtHostWorkspace(new TestThreadService(), '/Coding/Applications/NewsWoWBot');
assert.equal(ws.getRelativePath('/Coding/Applications/NewsWoWBot/bernd/das/brot'), 'bernd/das/brot');
assert.equal(ws.getRelativePath('/Coding/Applications/NewsWoWBot/bernd/das/brot'), fsPath('bernd/das/brot'));
assert.equal(ws.getRelativePath('/Apps/DartPubCache/hosted/pub.dartlang.org/convert-2.0.1/lib/src/hex.dart'),
'/Apps/DartPubCache/hosted/pub.dartlang.org/convert-2.0.1/lib/src/hex.dart');
fsPath('/Apps/DartPubCache/hosted/pub.dartlang.org/convert-2.0.1/lib/src/hex.dart'));
assert.equal(ws.getRelativePath(''), '');
assert.equal(ws.getRelativePath('/foo/bar'), '/foo/bar');
assert.equal(ws.getRelativePath('/foo/bar'), fsPath('/foo/bar'));
});
test('asRelativePath, same paths, #11402', function () {
......@@ -28,7 +37,7 @@ suite('ExtHostWorkspace', function () {
const input = '/home/aeschli/workspaces/samples/docker';
const ws = new ExtHostWorkspace(new TestThreadService(), root);
assert.equal(ws.getRelativePath(input), input);
assert.equal(ws.getRelativePath(input), fsPath(input));
const input2 = '/home/aeschli/workspaces/samples/docker/a.file';
assert.equal(ws.getRelativePath(input2), 'a.file');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册