test34.spec.js 797 B

123456789101112131415161718192021222324252627282930
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { IVProgProcessor} from './../js/processor/ivprogProcessor'
  3. import { LanguageService } from '../js/services/languageService';
  4. describe('IfThenElse command ', function () {
  5. let input = `programa {
  6. funcao inicio() {
  7. inteiro a = 0
  8. se (a > 2) {
  9. a = 5
  10. } senao se (a < 2) {
  11. a = 10
  12. } senao {
  13. a = -1
  14. }
  15. }
  16. }`;
  17. const lexer = LanguageService.getCurrentLexer();
  18. it(`should produce a valid state`, function (done) {
  19. const parser = new IVProgParser(input, lexer);
  20. const exec = new IVProgProcessor(parser.parseTree());
  21. exec.interpretAST().then(sto => {
  22. expect(sto.applyStore('a').value).toEqual(10);
  23. done();
  24. }).catch( err => done(err));
  25. });
  26. });