test37.spec.js 863 B

1234567891011121314151617181920212223242526272829
  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 read function', function () {
  6. const code = `programa {
  7. funcao inicio() {
  8. inteiro a;
  9. leia(a);
  10. }
  11. }`;
  12. const input = new InputTest(['0xff']);
  13. const lexer = LanguageService.getCurrentLexer();
  14. it(`should read data from the input and convert it to the appropriate type`, function (done) {
  15. const parser = new IVProgParser(code, lexer);
  16. const exec = new IVProgProcessor(parser.parseTree());
  17. exec.registerInput(input);
  18. exec.interpretAST().then(sto => {
  19. expect(sto.applyStore('a').number).toEqual(255);
  20. done();
  21. }).catch( err => done(err));
  22. });
  23. });