提交 45bfc0a2 编写于 作者: J Johannes Rieken

enable more tests #10659

上级 1ae8202e
......@@ -373,55 +373,44 @@ suite('ExtHostTypes', function () {
edit.set(b, [types.TextEdit.insert(new types.Position(0, 0), 'ffff')]);
assert.equal(edit.get(b).length, 1);
});
// test('WorkspaceEdit should fail when editing deleted resource', () => {
// const resource = URI.parse('file:///a.ts');
// const edit = new types.WorkspaceEdit();
// edit.deleteResource(resource);
// try {
// edit.insert(resource, new types.Position(0, 0), '');
// assert.fail(false, 'Should disallow edit of deleted resource');
// } catch {
// // expected
// }
// });
// test('WorkspaceEdit - keep order of text and file changes', function () {
// const edit = new types.WorkspaceEdit();
// edit.replace(URI.parse('foo:a'), new types.Range(1, 1, 1, 1), 'foo');
// edit.renameResource(URI.parse('foo:a'), URI.parse('foo:b'));
// edit.replace(URI.parse('foo:a'), new types.Range(2, 1, 2, 1), 'bar');
// edit.replace(URI.parse('foo:b'), new types.Range(3, 1, 3, 1), 'bazz');
// const all = edit.allEntries();
// assert.equal(all.length, 3);
// function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, URI] {
// const [f, s] = thing;
// return URI.isUri(f) && URI.isUri(s);
// }
// function isTextChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, types.TextEdit[]] {
// const [f, s] = thing;
// return URI.isUri(f) && Array.isArray(s);
// }
// const [first, second, third] = all;
// assert.equal(first[0].toString(), 'foo:a');
// assert.ok(!isFileChange(first));
// assert.ok(isTextChange(first) && first[1].length === 2);
// assert.equal(second[0].toString(), 'foo:a');
// assert.ok(isFileChange(second));
// assert.equal(third[0].toString(), 'foo:b');
// assert.ok(!isFileChange(third));
// assert.ok(isTextChange(third) && third[1].length === 1);
// });
test('WorkspaceEdit - keep order of text and file changes', function () {
const edit = new types.WorkspaceEdit();
edit.replace(URI.parse('foo:a'), new types.Range(1, 1, 1, 1), 'foo');
edit.renameFile(URI.parse('foo:a'), URI.parse('foo:b'));
edit.replace(URI.parse('foo:a'), new types.Range(2, 1, 2, 1), 'bar');
edit.replace(URI.parse('foo:b'), new types.Range(3, 1, 3, 1), 'bazz');
const all = edit.allEntries();
assert.equal(all.length, 4);
function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, URI] {
const [f, s] = thing;
return URI.isUri(f) && URI.isUri(s);
}
function isTextChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, types.TextEdit[]] {
const [f, s] = thing;
return URI.isUri(f) && Array.isArray(s);
}
const [first, second, third, fourth] = all;
assert.equal(first[0].toString(), 'foo:a');
assert.ok(!isFileChange(first));
assert.ok(isTextChange(first) && first[1].length === 1);
assert.equal(second[0].toString(), 'foo:a');
assert.ok(isFileChange(second));
assert.equal(third[0].toString(), 'foo:a');
assert.ok(isTextChange(third) && third[1].length === 1);
assert.equal(fourth[0].toString(), 'foo:b');
assert.ok(!isFileChange(fourth));
assert.ok(isTextChange(fourth) && fourth[1].length === 1);
});
test('DocumentLink', function () {
assert.throws(() => new types.DocumentLink(null, null));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册