test27.spec.js 755 B

1234567891011121314151617181920212223242526272829
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { IVProgProcessor} from './../js/processor/ivprogProcessor'
  3. import { LanguageService } from '../js/services/languageService';
  4. describe('A finite 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. }
  12. b = 8
  13. }
  14. }`;
  15. const lexer = LanguageService.getCurrentLexer();
  16. it(`should terminate`, 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').number).toEqual(5);
  21. done();
  22. }).catch( err => done(err));
  23. });
  24. });