test28.spec.js 830 B

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