test28.spec.js 914 B

123456789101112131415161718192021222324252627282930313233
  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 inner while loop', function () {
  7. let input = `programa {
  8. funcao inicio() {
  9. inteiro a = 0
  10. inteiro b = 0
  11. enquanto (a < 5) {
  12. a = a + 1
  13. enquanto (b < 1) {
  14. pare
  15. }
  16. }
  17. }
  18. }`;
  19. const lexer = LanguageService.getCurrentLexer();
  20. it(`should terminate the inner while only`, function (done) {
  21. const parser = new IVProgParser(input, lexer);
  22. const exec = new IVProgProcessor(parser.parseTree());
  23. exec.interpretAST().then(sto => {
  24. expect(sto.applyStore('a').value).toEqual(5);
  25. done();
  26. }).catch( err => done(err));
  27. });
  28. });