test53.spec.js 1016 B

1234567891011121314151617181920212223242526272829303132
  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. real a = -1.0
  10. escreva(Matematica.modulo(a))
  11. }
  12. }`;
  13. localStorage.setItem('ivprog.lang', 'pt');
  14. const lexer = LanguageService.getCurrentLexer();
  15. const out = new OutputTest();
  16. it(`should be executed with no exception`, function (done) {
  17. const parser = new IVProgParser(code, lexer);
  18. const sem = new SemanticAnalyser(parser.parseTree());
  19. const exec = new IVProgProcessor(sem.analyseTree());
  20. exec.registerOutput(out);
  21. exec.interpretAST().then(_ => {
  22. expect(out.list).toEqual(['1.0']);
  23. done();
  24. }).catch(err => done(err));
  25. });
  26. });