test59.spec.js 1011 B

12345678910111213141516171819202122232425262728293031
  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('Assigning a single value to only a dimension of a matrix', function () {
  7. const code = `programa {
  8. funcao inicio() {
  9. inteiro a[2][2] = {{0,0},{0,0}}
  10. a[0] = 1
  11. }
  12. }`;
  13. localStorage.setItem('ivprog.lang', 'pt');
  14. const lexer = LanguageService.getCurrentLexer();
  15. const out = new OutputTest();
  16. it(`should throw an exception`, function (done) {
  17. const parser = new IVProgParser(code, lexer);
  18. const sem = new SemanticAnalyser(parser.parseTree());
  19. const exec = new IVProgProcessor(sem.analyseTree());
  20. exec.registerOutput(out);
  21. exec.interpretAST().then(_ => {
  22. done("No exception thrown.");
  23. }).catch(err => done());
  24. });
  25. });