test29.spec.js 747 B

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