test10.spec.js 655 B

12345678910111213141516171819202122232425262728
  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('IfThenElseIfThenElse command chain', () => {
  9. let input = `funcao inteiro test(real i) {
  10. inteiro a = 5 + i
  11. a = 5 + G[i][6]
  12. se (a > 5) {
  13. a = 5
  14. } senao se (a<5) {
  15. a = 0
  16. } senao {
  17. a = -1
  18. }
  19. }`;
  20. const lexer = Lexers['pt_br'];
  21. it(`should not result in SyntaxError`, () => {
  22. const as = new IVProgParser(input, lexer);
  23. const fun = as.parseFunction.bind(as);
  24. expect(fun).not.toThrow();
  25. });
  26. });