test20.spec.js 811 B

12345678910111213141516171819202122232425262728
  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].number,
  17. sto.applyStore('a').value[1].number
  18. ]).toEqual(result);
  19. done();
  20. }).catch(err => done(err));
  21. });
  22. });