test43.spec.js 940 B

1234567891011121314151617181920212223242526272829303132
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { IVProgProcessor} from './../js/processor/ivprogProcessor'
  3. import { InputTest } from './../js/util/inputTest';
  4. import { LanguageService } from '../js/services/languageService';
  5. describe('The sum of a real and a integer', function () {
  6. const code = `programa {
  7. funcao inicio() {
  8. real a
  9. leia(a)
  10. a = a + 0xff
  11. }
  12. }`;
  13. localStorage.setItem('ivprog.lang', 'pt');
  14. const input = new InputTest(['5.8']);
  15. const lexer = LanguageService.getCurrentLexer();
  16. it(`should result in a real`, function (done) {
  17. const parser = new IVProgParser(code, lexer);
  18. const exec = new IVProgProcessor(parser.parseTree());
  19. exec.registerInput(input);
  20. exec.interpretAST().then(sto => {
  21. expect(sto.applyStore('a').value).toEqual(5.8 + 0xff);
  22. localStorage.removeItem('ivprog.lang');
  23. done();
  24. }).catch( err => done(err));
  25. });
  26. });