testCallMainFunction.spec.js 944 B

123456789101112131415161718192021222324252627282930313233
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { IVProgProcessor} from './../js/processor/ivprogProcessor'
  3. import { SemanticAnalyser } from "./../js/processor/semantic/semanticAnalyser";
  4. import { LanguageService } from '../js/services/languageService';
  5. describe('A call to the main function', function () {
  6. let input = `programa {
  7. inteiro a = 0
  8. funcao inicio () {
  9. se (a > 5) {
  10. retorne
  11. } senao {
  12. a = a + 1
  13. inicio()
  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 semantic = new SemanticAnalyser(parser.parseTree());
  21. const exec = new IVProgProcessor(semantic.analyseTree());
  22. exec.interpretAST().then(sto => {
  23. expect(sto).toBeTruthy();
  24. done();
  25. }).catch(err => {
  26. done(err);
  27. });
  28. });
  29. });