test29.spec.js 823 B

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