test40.spec.js 990 B

12345678910111213141516171819202122232425262728293031323334
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { IVProgProcessor} from './../js/processor/ivprogProcessor'
  3. import { OutputTest } from './../js/util/outputTest';
  4. import { LanguageService } from '../js/services/languageService';
  5. describe('The LanguageService', function () {
  6. beforeEach( () => {
  7. localStorage.setItem('ivprog.lang', 'en');
  8. });
  9. const code = `program {
  10. function start() {
  11. real a = 8.01
  12. write(a)
  13. }
  14. }`;
  15. const output = new OutputTest();
  16. localStorage.setItem('ivprog.lang', 'en');
  17. const lexer = LanguageService.getCurrentLexer();
  18. it(`should provide the appropriate lexer`, function (done) {
  19. const parser = new IVProgParser(code, lexer);
  20. const exec = new IVProgProcessor(parser.parseTree());
  21. exec.registerOutput(output);
  22. exec.interpretAST().then(sto => {
  23. expect(output.list).toEqual(['8.01']);
  24. localStorage.removeItem('ivprog.lang');
  25. done();
  26. }).catch( err => done(err));
  27. });
  28. });