test57.spec.js 1.0 KB

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('Is_Real function ', function () {
  7. const code = `programa {
  8. funcao inicio() {
  9. cadeia a = "1.2"
  10. escreva(e_real(a))
  11. }
  12. }`;
  13. localStorage.setItem('ivprog.lang', 'pt');
  14. const lexer = LanguageService.getCurrentLexer();
  15. const out = new OutputTest();
  16. it(`should return true if the string is valid real representation`, 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(["verdadeiro"]);
  23. done();
  24. }).catch(err => done(err));
  25. });
  26. });