mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 17:48:56 +01:00
add DiagnosticsCollection#has and #get
This commit is contained in:
@@ -10,7 +10,7 @@ import {languages, Uri, Diagnostic, Range} from 'vscode';
|
||||
|
||||
suite('languages namespace tests', () => {
|
||||
|
||||
test('diagnostic collection', function () {
|
||||
test('diagnostic collection, forEach, clear, has', function () {
|
||||
let collection = languages.createDiagnosticCollection('test');
|
||||
assert.equal(collection.name, 'test');
|
||||
collection.dispose();
|
||||
@@ -43,5 +43,33 @@ suite('languages namespace tests', () => {
|
||||
]);
|
||||
collection.forEach(() => c++);
|
||||
assert.equal(c, 2);
|
||||
|
||||
assert.ok(collection.has(Uri.parse('foo:bar1')));
|
||||
assert.ok(collection.has(Uri.parse('foo:bar2')));
|
||||
assert.ok(!collection.has(Uri.parse('foo:bar3')));
|
||||
collection.delete(Uri.parse('foo:bar1'));
|
||||
assert.ok(!collection.has(Uri.parse('foo:bar1')));
|
||||
});
|
||||
|
||||
test('diagnostic collection, immutable read', function () {
|
||||
let collection = languages.createDiagnosticCollection('test');
|
||||
collection.set(Uri.parse('foo:bar'), [
|
||||
new Diagnostic(new Range(0, 0, 1, 1), 'message-1'),
|
||||
new Diagnostic(new Range(0, 0, 1, 1), 'message-2')
|
||||
]);
|
||||
|
||||
let array = collection.get(Uri.parse('foo:bar'));
|
||||
assert.throws(() => array.length = 0);
|
||||
assert.throws(() => array.pop());
|
||||
assert.throws(() => array[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil'));
|
||||
|
||||
collection.forEach((uri, array) => {
|
||||
assert.throws(() => array.length = 0);
|
||||
assert.throws(() => array.pop());
|
||||
assert.throws(() => array[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil'));
|
||||
});
|
||||
|
||||
array = collection.get(Uri.parse('foo:bar'));
|
||||
assert.equal(array.length, 2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user