test27.spec.js 831 B

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