test21.spec.js 825 B

123456789101112131415161718192021222324252627282930
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { IVProgProcessor} from './../js/processor/ivprogProcessor'
  3. import { LanguageService } from '../js/services/languageService';
  4. describe('A call to a function that returns a valid type', function () {
  5. const input = `programa {
  6. funcao inicio() {
  7. inteiro a = soma(1, 1)
  8. }
  9. funcao inteiro soma(inteiro a, inteiro b)
  10. {
  11. retorne a + b
  12. }
  13. }`;
  14. const lexer = LanguageService.getCurrentLexer();
  15. const result = 2;
  16. it(`should produce a valid state`, 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(result);
  21. done();
  22. }).catch(err => done(err));
  23. });
  24. });