1
0

test21.spec.js 901 B

1234567891011121314151617181920212223242526272829303132
  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 call to a function that returns a valid type', function () {
  7. const input = `programa {
  8. funcao inicio() {
  9. inteiro a = soma(1, 1)
  10. }
  11. funcao inteiro soma(inteiro a, inteiro b)
  12. {
  13. retorne a + b
  14. }
  15. }`;
  16. const lexer = LanguageService.getCurrentLexer();
  17. const result = 2;
  18. it(`should produce a valid state`, 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(result);
  23. done();
  24. }).catch(err => done(err));
  25. });
  26. });