test30.spec.js 992 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 break command inside a switch..case', function () {
  7. let input = `programa {
  8. funcao inicio() {
  9. inteiro a = 0
  10. escolha (a) {
  11. caso 2:
  12. a = a + 1
  13. pare
  14. caso 1:
  15. a = a + 2
  16. pare
  17. caso 0:
  18. a = -5
  19. pare
  20. caso contrario:
  21. a = 5 + 8
  22. }
  23. }
  24. }`;
  25. const lexer = LanguageService.getCurrentLexer();
  26. it(`should terminate it`, function (done) {
  27. const parser = new IVProgParser(input, lexer);
  28. const exec = new IVProgProcessor(parser.parseTree());
  29. exec.interpretAST().then(sto => {
  30. expect(sto.applyStore('a').value).toEqual(-5);
  31. done();
  32. }).catch( err => done(err));
  33. });
  34. });