test20.spec.js 769 B

1234567891011121314151617181920212223242526
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { IVProgProcessor} from './../js/processor/ivprogProcessor'
  3. import { LanguageService } from '../js/services/languageService';
  4. describe('An Array initialization with expressions', function () {
  5. const input = `programa {
  6. funcao inicio() {
  7. inteiro a[2] = {2+2,3*5}
  8. }
  9. }`;
  10. const lexer = LanguageService.getCurrentLexer();
  11. const result = [4,15];
  12. it(`should produce a valid state`, function (done) {
  13. const parser = new IVProgParser(input, lexer);
  14. const exec = new IVProgProcessor(parser.parseTree());
  15. exec.interpretAST().then(sto => {
  16. expect([sto.applyStore('a').value[0].value,sto.applyStore('a').value[1].value]).toEqual(result);
  17. done();
  18. });
  19. });
  20. });