test20.spec.js 761 B

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