test20.spec.js 846 B

12345678910111213141516171819202122232425262728
  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('An Array initialization with expressions', function () {
  7. const input = `programa {
  8. funcao inicio() {
  9. inteiro a[2] = {2+2,3*5}
  10. }
  11. }`;
  12. const lexer = LanguageService.getCurrentLexer();
  13. const result = [4,15];
  14. it(`should produce a valid state`, function (done) {
  15. const parser = new IVProgParser(input, lexer);
  16. const exec = new IVProgProcessor(parser.parseTree());
  17. exec.interpretAST().then(sto => {
  18. expect([sto.applyStore('a').value[0].value,sto.applyStore('a').value[1].value]).toEqual(result);
  19. done();
  20. });
  21. });
  22. });