test00.spec.js 896 B

12345678910111213141516171819202122232425262728293031
  1. import Lexers from './../grammar/';
  2. import {
  3. IVProgParser
  4. } from './../js/ast/ivprogParser';
  5. import * as Expressions from './../js/ast/expressions/';
  6. import * as Commands from './../js/ast/commands/';
  7. import { Types } from './../js/ast/types';
  8. describe("Testing Syntax Analysis for default", () => {
  9. var lang = 'pt_br';
  10. var input;
  11. var asa;
  12. var lexer;
  13. it("it should produce a valid AST", () => {
  14. lexer = Lexers[lang];
  15. input = `programa {
  16. const real PI = 1
  17. const inteiro a[5][5]
  18. }`;
  19. asa = {
  20. global: [new Commands.Declaration('PI', Types.REAL, new Expressions.IntLiteral(1), true),
  21. new Commands.ArrayDeclaration('a', Types.INTEGER, new Expressions.IntLiteral(5), new Expressions.IntLiteral(5), null, true)],
  22. functions: []
  23. };
  24. const as = new IVProgParser(input, lexer);
  25. expect(as.parseTree()).toEqual(asa);
  26. });
  27. });