test37.spec.js 898 B

123456789101112131415161718192021222324252627282930
  1. import Lexers from './../grammar/';
  2. import { IVProgParser } from './../js/ast/ivprogParser';
  3. import { IVProgProcessor} from './../js/processor/ivprogProcessor'
  4. import { InputTest } from './../js/util/inputTest';
  5. import { LanguageService } from '../js/services/languageService';
  6. describe('The read function', function () {
  7. const code = `programa {
  8. funcao inicio() {
  9. inteiro a;
  10. leia(a);
  11. }
  12. }`;
  13. const input = new InputTest(['0xff']);
  14. const lexer = LanguageService.getCurrentLexer();
  15. it(`should read data from the input and convert it to the appropriate type`, function (done) {
  16. const parser = new IVProgParser(code, lexer);
  17. const exec = new IVProgProcessor(parser.parseTree());
  18. exec.registerInput(input);
  19. exec.interpretAST().then(sto => {
  20. expect(sto.applyStore('a').value).toEqual(255);
  21. done();
  22. }).catch( err => done(err));
  23. });
  24. });