@lcap/nasl-parser
Version:
Take Nasl text to Nasl AST with the help of generalized parsing.
22 lines (17 loc) • 599 B
text/typescript
import { Parser, Grammar } from "nearley";
import grammar from "../../ts/nasl";
const testAssign = `
logic testAssign() {
x = true && 10
{ y.a = true; y.b = 11 }
}
`
describe('Test Assignment', () => {
test('Single and batch assignment', async () => {
const parser = new Parser(Grammar.fromCompiled(grammar));
parser.feed(testAssign);
expect(parser.results.length).toBe(1);
expect(parser.results[0].cst[0].body.stmts[0]['__type']).toBe("SingleAssign");
expect(parser.results[0].cst[0].body.stmts[1]['__type']).toBe('BatchAssign');
});
});