test13.spec.js 697 B

12345678910111213141516171819202122232425262728293031
  1. import Lexers from './../grammar/';
  2. import {
  3. IVProgParser
  4. } from './../js/ast/ivprogParser';
  5. import {
  6. SyntaxError
  7. } from './../js/ast/SyntaxError';
  8. describe('A complete program code', () => {
  9. let input = `programa {
  10. const real PI = 5.5
  11. inteiro V = -10*2
  12. funcao inteiro test(real i) {
  13. escolha (i) {
  14. caso 1:
  15. retorne 0
  16. casocontrario:
  17. retorne 4
  18. }
  19. }
  20. }`;
  21. const lexer = Lexers['pt_br'];
  22. it(`should not result in SyntaxError`, () => {
  23. const as = new IVProgParser(input, lexer);
  24. const fun = as.parseTree.bind(as);
  25. expect(fun).not.toThrow(SyntaxError);
  26. });
  27. });