test29.spec.js 739 B

12345678910111213141516171819202122232425262728
  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 for loop', function () {
  6. let input = `programa {
  7. funcao inicio() {
  8. inteiro a = 0
  9. para(a = 0;a < 5; a = a + 1) {
  10. pare
  11. }
  12. }
  13. }`;
  14. const lexer = Lexers['pt_br'];
  15. it(`should terminate it`, function (done) {
  16. const parser = new IVProgParser(input, lexer);
  17. const exec = new IVProgProcessor(parser.parseTree());
  18. exec.interpretAST().then(sto => {
  19. expect(sto.applyStore('a').value).toEqual(0);
  20. done();
  21. }).catch( err => done(err));
  22. });
  23. });