test31.spec.js 969 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import Lexers from './../grammar/';
  2. import {Types} from './../js/ast/types';
  3. import { IVProgParser } from './../js/ast/ivprogParser';
  4. import { IVProgProcessor} from './../js/processor/ivprogProcessor'
  5. import { LanguageService } from '../js/services/languageService';
  6. describe('A case without return/break', function () {
  7. let input = `programa {
  8. funcao inicio() {
  9. inteiro a = 1
  10. escolha (a) {
  11. caso 0:
  12. a = a + 1
  13. pare
  14. caso 1:
  15. a = a + 2
  16. caso 2:
  17. a = a * 2
  18. pare
  19. caso contrario:
  20. a = 5 + 8
  21. }
  22. }
  23. }`;
  24. const lexer = LanguageService.getCurrentLexer();
  25. it(`should fall through`, function (done) {
  26. const parser = new IVProgParser(input, lexer);
  27. const exec = new IVProgProcessor(parser.parseTree());
  28. exec.interpretAST().then(sto => {
  29. expect(sto.applyStore('a').value).toEqual(6);
  30. done();
  31. }).catch( err => done(err));
  32. });
  33. });