Skip to content

Commit 0488de3

Browse files
committed
fix vml/sasf/satf tests to use new parser format
1 parent 28070f9 commit 0488de3

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

src/languages/satf/grammar/sasf.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { testTree } from '@lezer/generator/test';
22
import { describe, expect, test } from 'vitest';
3-
import { SatfLanguage } from './satf-sasf.js';
3+
import { SatfSasfParser } from './satf-sasf.js';
44

55
const tests = [
66
[
@@ -101,6 +101,6 @@ describe.each([['parse tree structure', tests]])('grammar tests - %s', (_name: s
101101
102102
testTree will throw if there's a mismatch between the returned actual and expected trees, it returns
103103
undefined when they match. */
104-
expect(testTree(SatfLanguage.parser.parse(input), expected, undefined)).toBeUndefined();
104+
expect(testTree(SatfSasfParser.parse(input), expected, undefined)).toBeUndefined();
105105
});
106106
});

src/languages/satf/grammar/satf.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { testTree } from '@lezer/generator/dist/test';
22
import { describe, expect, test } from 'vitest';
3-
import { SatfLanguage } from './satf-sasf.js';
3+
import { SatfSasfParser } from './satf-sasf.js';
44

55
const tests = [
66
[
@@ -227,7 +227,7 @@ const tests = [
227227
RANGE, \\CLK_DUR:15:05:1 ...CLK_DUR:17:20:0\\
228228
RANGE, \\101T12:15:32.512 ...101T10:20:20.123\\
229229
RANGE, \\3.4, 0.9, 12.\\,
230-
),
230+
),
231231
Target (
232232
TYPE, STRING,
233233
RANGE, \\ "J", "I", "E" \\,
@@ -881,6 +881,6 @@ describe.each([['parse tree structure', tests]])('grammar tests - %s', (_name: s
881881
882882
testTree will throw if there's a mismatch between the returned actual and expected trees, it returns
883883
undefined when they match. */
884-
expect(testTree(SatfLanguage.parser.parse(input), expected, undefined)).toBeUndefined();
884+
expect(testTree(SatfSasfParser.parse(input), expected, undefined)).toBeUndefined();
885885
});
886886
});

src/languages/vml/vml-tree-utils.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { SyntaxNode } from '@lezer/common';
22
import { describe, expect, test } from 'vitest';
33
import { filterNodes, nodeContents } from '../../utils/tree-utils.js';
4-
import { VmlLanguage } from './vml.js';
4+
import { vmlParser } from './vml.js';
55
import { RULE_CALL_PARAMETERS, RULE_FUNCTION_NAME, RULE_TIME_TAGGED_STATEMENT } from './vml-constants.js';
66
import { getArgumentPosition, VmlCommandInfoMapper } from './vml-tree-utils.js';
77

@@ -22,7 +22,7 @@ R00:01:00 CALL pay_spawn "seis_pwr_on_r01_1"
2222
END_BODY
2323
END_MODULE
2424
`;
25-
const parsed = VmlLanguage.parser.parse(input);
25+
const parsed = vmlParser.parse(input);
2626
const vmlCommandInfoMapper = new VmlCommandInfoMapper();
2727
const timeTaggedNodes: SyntaxNode[] = Array.from(
2828
filterNodes(parsed.cursor(), (node: SyntaxNode) => node.name === RULE_TIME_TAGGED_STATEMENT),
@@ -122,7 +122,7 @@ END_MODULE
122122
`;
123123

124124
const moduleVariables = ['partial_product', 'file_base'];
125-
const parsed = VmlLanguage.parser.parse(input);
125+
const parsed = vmlParser.parse(input);
126126
const vmlCommandInfoMapper = new VmlCommandInfoMapper();
127127
const variableNames = vmlCommandInfoMapper.getVariables(input, parsed, input.indexOf('CMD_002'));
128128
expect(variableNames).toEqual([...moduleVariables, 'delay_time', 'mode', 'i', 'value', 'mask', 'file_name', 'str']);

src/languages/vml/vml.test.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { SyntaxNode } from '@lezer/common';
22
import type { FswCommandArgumentInteger } from '@nasa-jpl/aerie-ampcs';
33
import { assert, describe, expect, it } from 'vitest';
44
import { filterNodes, nodeContents } from '../../utils/tree-utils.js';
5-
import { VmlLanguage } from './vml.js';
5+
import { vmlParser } from './vml.js';
66
import { vmlBlockLibraryToCommandDictionary } from './vml-block-library.js';
77
import {
88
GROUP_STATEMENT_SUB as GROUP_STATEMENT_SUBTYPES,
@@ -79,7 +79,7 @@ END_MODULE
7979
`;
8080
assertNoErrorNodes(input);
8181

82-
const tree = VmlLanguage.parser.parse(input);
82+
const tree = vmlParser.parse(input);
8383
expect(tree.topNode.name).toBe(RULE_TEXT_FILE);
8484

8585
const functionsNode = tree.topNode.getChild(RULE_FUNCTIONS);
@@ -327,7 +327,7 @@ END_BODY
327327
328328
END_MODULE`;
329329
assertNoErrorNodes(input, true);
330-
const parsed = VmlLanguage.parser.parse(input);
330+
const parsed = vmlParser.parse(input);
331331
const functionNodes = parsed.topNode.getChild(RULE_FUNCTIONS)?.getChildren(RULE_FUNCTION);
332332
expect(functionNodes).toBeDefined();
333333
expect(functionNodes?.length).toEqual(2);
@@ -449,7 +449,7 @@ END_MODULE
449449

450450
describe('standalone statements', () => {
451451
const timeTaggedConfig = { top: RULE_TEST_TIME_TAGGED_STATEMENT };
452-
const timeTaggedParser = VmlLanguage.parser.configure(timeTaggedConfig);
452+
const timeTaggedParser = vmlParser.configure(timeTaggedConfig);
453453

454454
it('spacecraft command with assignment', () => {
455455
const input = `R00:00:01.00 END_TIME := spacecraft_time()\n`;
@@ -477,7 +477,7 @@ describe('standalone statements', () => {
477477
describe('partial documents', () => {
478478
it('module fragment', () => {
479479
const input = '\n\nMOD\n\n';
480-
const tree = VmlLanguage.parser.parse(input);
480+
const tree = vmlParser.parse(input);
481481
expect(tree.topNode.getChild(TOKEN_MODULE)).toBeNull();
482482
});
483483

@@ -491,7 +491,7 @@ R00:00:00.00 ISS
491491
END_BODY
492492
END_MODULE
493493
`;
494-
const tree = VmlLanguage.parser.parse(input);
494+
const tree = vmlParser.parse(input);
495495
const seqNode = tree.topNode.getChild(RULE_FUNCTIONS)?.getChild(RULE_FUNCTION)?.getChild(RULE_SEQUENCE);
496496
expect(seqNode).toBeTruthy();
497497
const bodyNode = seqNode?.getChild(RULE_COMMON_FUNCTION)?.getChild(RULE_BODY);
@@ -507,7 +507,7 @@ END_BODY
507507
A
508508
END_MODULE`;
509509
const aPosition = input.indexOf('A\n', input.lastIndexOf(TOKEN_END_BODY));
510-
const aToken = VmlLanguage.parser.parse(input).resolveInner(aPosition, 1);
510+
const aToken = vmlParser.parse(input).resolveInner(aPosition, 1);
511511
expect(aToken.name).toBe(TOKEN_SYMBOL_CONST);
512512
expect(aToken.parent?.name).toBe(TOKEN_ERROR);
513513
});
@@ -520,14 +520,14 @@ BODY
520520
R0
521521
END_BODY
522522
END_MODULE`;
523-
const r0Token = VmlLanguage.parser.parse(input).resolveInner(input.indexOf('R0'), 1);
523+
const r0Token = vmlParser.parse(input).resolveInner(input.indexOf('R0'), 1);
524524
expect(r0Token.name).toBe(TOKEN_SYMBOL_CONST);
525525
expect(r0Token.parent?.name).toBe(TOKEN_ERROR);
526526
});
527527
});
528528

529529
function printNodes(input: string): void {
530-
for (const node of filterNodes(VmlLanguage.parser.parse(input).cursor())) {
530+
for (const node of filterNodes(vmlParser.parse(input).cursor())) {
531531
printNode(input, node);
532532
}
533533
}
@@ -554,8 +554,7 @@ END_MODULE
554554
}
555555

556556
export function assertNoErrorNodes(input: string, printPrefix?: boolean): void {
557-
const parser = VmlLanguage.parser;
558-
const cursor = parser.parse(input).cursor();
557+
const cursor = vmlParser.parse(input).cursor();
559558
do {
560559
const { node } = cursor;
561560
if (printPrefix) {

0 commit comments

Comments
 (0)