Skip to content

Commit 4cbbc0b

Browse files
authored
Merge pull request microsoft#152212 from babakks/fix-snippet-parser-assertion
2 parents 626fd8a + b71f44b commit 4cbbc0b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/vs/editor/contrib/snippet/test/browser/snippetParser.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ suite('SnippetParser', () => {
9797
function assertMarker(input: TextmateSnippet | Marker[] | string, ...ctors: Function[]) {
9898
let marker: Marker[];
9999
if (input instanceof TextmateSnippet) {
100-
marker = input.children;
100+
marker = [...input.children];
101101
} else if (typeof input === 'string') {
102102
const p = new SnippetParser();
103103
marker = p.parse(input).children;
104104
} else {
105-
marker = input;
105+
marker = [...input];
106106
}
107107
while (marker.length > 0) {
108108
const m = marker.pop();
@@ -273,12 +273,13 @@ suite('SnippetParser', () => {
273273
assertTextAndMarker('${1|one,two,three,|}', '${1|one,two,three,|}', Text);
274274
assertTextAndMarker('${1|one,', '${1|one,', Text);
275275

276-
const p = new SnippetParser();
277-
const snippet = p.parse('${1|one,two,three|}');
278-
assertMarker(snippet, Placeholder);
279-
const expected = [Placeholder, Text, Text, Text];
276+
const snippet = new SnippetParser().parse('${1|one,two,three|}');
277+
const expected: ((m: Marker) => boolean)[] = [
278+
m => m instanceof Placeholder,
279+
m => m instanceof Choice && m.options.length === 3 && m.options.every(x => x instanceof Text),
280+
];
280281
snippet.walk(marker => {
281-
assert.strictEqual(marker, expected.shift());
282+
assert.ok(expected.shift()!(marker));
282283
return true;
283284
});
284285
});

0 commit comments

Comments
 (0)