test64.spec.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { SemanticAnalyser } from './../js/processor/semantic/semanticAnalyser';
  3. import { LanguageService } from '../js/services/languageService';
  4. import { OutputTest } from '../js/util/outputTest';
  5. import { IVProgProcessor } from '../js/processor/ivprogProcessor';
  6. describe('Defining a return type as array', function () {
  7. const code = `programa {
  8. funcao inicio() {
  9. inteiro a[2] = retArr()
  10. escreva(a[0])
  11. }
  12. funcao inteiro[] retArr () {
  13. retorne {0,0}
  14. }
  15. }`;
  16. localStorage.setItem('ivprog.lang', 'pt');
  17. const lexer = LanguageService.getCurrentLexer();
  18. const out = new OutputTest();
  19. it(`should not throw an exception`, function (done) {
  20. const parser = new IVProgParser(code, lexer);
  21. const sem = new SemanticAnalyser(parser.parseTree());
  22. const exec = new IVProgProcessor(sem.analyseTree());
  23. exec.registerOutput(out);
  24. exec.interpretAST().then(_ => {
  25. expect(out.list).toEqual(['0']);
  26. done()
  27. }).catch( err => done(err));
  28. });
  29. });