test16.spec.js 816 B

123456789101112131415161718192021222324252627282930313233343536
  1. import Lexers from './../grammar/';
  2. import {
  3. IVProgParser
  4. } from './../js/ast/ivprogParser';
  5. import { LanguageService } from '../js/services/languageService';
  6. describe('Variable declaration inside a function', () => {
  7. let input = `programa {
  8. const real PI = 5.5
  9. inteiro V = -10*2
  10. funcao inicio() {
  11. inteiro a = 6
  12. test(PI)
  13. retorne
  14. }
  15. funcao inteiro test(real i) {
  16. escolha (i) {
  17. caso 1:
  18. retorne 0
  19. caso contrario:
  20. retorne 4
  21. }
  22. }
  23. }`;
  24. const lexer = LanguageService.getCurrentLexer();
  25. it(`should not result in SyntaxError`, () => {
  26. const as = new IVProgParser(input, lexer);
  27. const fun = as.parseTree.bind(as);
  28. expect(fun).not.toThrow();
  29. });
  30. });