Split wasm tests for next parse state

This commit is contained in:
Daumantas Kavolis 2023-06-16 11:32:13 +03:00
parent ec90c215ae
commit ab788619ca

View file

@ -326,10 +326,10 @@ describe("Node", () => {
);
});
describe(".parseState", () => {
describe(".parseState, .nextParseState", () => {
const text = "10 / 5";
it(`returns node parse state ids`, async () => {
it("returns node parse state ids", async () => {
tree = await parser.parse(text)
const quotientNode = tree.rootNode.firstChild.firstChild;
const [numerator, slash, denominator] = quotientNode.children;
@ -338,11 +338,20 @@ describe("Node", () => {
// parse states will change on any change to the grammar so test that it
// returns something instead
assert.isAbove(numerator.parseState, 0);
assert.isAbove(numerator.nextParseState, 0);
assert.isAbove(slash.parseState, 0);
assert.isAbove(denominator.parseState, 0);
assert.isAbove(denominator.nextParseState, 0);
})
it("returns next parse state equal to the language", async () => {
tree = await parser.parse(text);
const quotientNode = tree.rootNode.firstChild.firstChild;
quotientNode.children.forEach(node => {
assert.equal(
node.nextParseState,
JavaScript.nextState(node.parseState, node.grammarId)
);
});
});
});
describe('.descendantsOfType(type, min, max)', () => {