test53.spec.js 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { SemanticAnalyser } from './../js/processor/semantic/semanticAnalyser';
  3. import { LanguageService } from '../js/services/languageService';
  4. import { OutputTest } from '../js/util/outputTest';
  5. import { IVProgProcessor } from '../js/processor/ivprogProcessor';
  6. describe('Math lib modulo function ', function () {
  7. const code = `programa {
  8. funcao inicio() {
  9. inteiro a = -1
  10. inteiro b = Matematica.modulo(a)
  11. escreva(b)
  12. }
  13. }`;
  14. localStorage.setItem('ivprog.lang', 'pt');
  15. const lexer = LanguageService.getCurrentLexer();
  16. const out = new OutputTest();
  17. it(`should be executed with no exception`, function (done) {
  18. const parser = new IVProgParser(code, lexer);
  19. const sem = new SemanticAnalyser(parser.parseTree());
  20. const exec = new IVProgProcessor(sem.analyseTree());
  21. exec.registerOutput(out);
  22. exec.interpretAST().then(_ => {
  23. expect(out.list).toEqual(['1']);
  24. done();
  25. }).catch(err => done(err));
  26. });
  27. });