testMatrixGlobal.spec.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { IVProgProcessor} from './../js/processor/ivprogProcessor'
  3. import { SemanticAnalyser } from "./../js/processor/semantic/semanticAnalyser";
  4. import { LanguageService } from '../js/services/languageService';
  5. import { OutputTest } from '../js/util/outputTest';
  6. describe('A global matrix variable',function () {
  7. let input = `programa {
  8. inteiro nova_global_0 [4][4] = {{1,1,1,1},{1,1,1,1},{1,1,1,1},{1,1,1,1}}
  9. funcao vazio inicio ( ) {
  10. escreva ( nova_global_0 [ 0 ] [ 0 ] )
  11. }
  12. }`
  13. const lexer = LanguageService.getCurrentLexer();
  14. const out = new OutputTest();
  15. it(`should not throw an exception`, function (done) {
  16. const parser = new IVProgParser(input, lexer);
  17. const semantic = new SemanticAnalyser(parser.parseTree());
  18. const exec = new IVProgProcessor(semantic.analyseTree());
  19. exec.registerOutput(out);
  20. exec.interpretAST().then(_ => {
  21. expect(out.list.length).toEqual(1);
  22. done();
  23. }).catch(err => {
  24. done(err);
  25. });
  26. });
  27. });