test30.spec.js 915 B

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