test24.spec.js 740 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('Command Do...While', function () {
  5. let input = `programa {
  6. funcao inicio() {
  7. inteiro a = 0
  8. faca {
  9. a = a + 1
  10. } enquanto(a < 5)
  11. }
  12. }`;
  13. const lexer = LanguageService.getCurrentLexer();
  14. it(`should result in a valid state`, 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(5);
  19. done();
  20. }).catch( err => done(err));
  21. });
  22. });