test28.spec.js 837 B

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