test27.spec.js 747 B

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