test33.spec.js 911 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { IVProgProcessor} from './../js/processor/ivprogProcessor'
  3. import { LanguageService } from '../js/services/languageService';
  4. describe('A non-const global variable', function () {
  5. let input = `programa {
  6. inteiro a = 5
  7. funcao inicio() {
  8. escolha (a) {
  9. caso 0:
  10. a = a + 1
  11. pare
  12. caso 1:
  13. a = a + 2
  14. caso 2:
  15. a = a * 2
  16. pare
  17. caso contrario:
  18. a = 5 + 8
  19. }
  20. }
  21. }`;
  22. const lexer = LanguageService.getCurrentLexer();
  23. it(`should be modifiable inside a function`, function (done) {
  24. const parser = new IVProgParser(input, lexer);
  25. const exec = new IVProgProcessor(parser.parseTree());
  26. exec.interpretAST().then(sto => {
  27. expect(sto.applyStore('a').value).toEqual(13);
  28. done();
  29. }).catch( err => done(err));
  30. });
  31. });