test40.spec.js 912 B

123456789101112131415161718192021222324252627282930
  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. const code = `program {
  7. function start() {
  8. real a = 8.01
  9. write(a)
  10. }
  11. }`;
  12. const output = new OutputTest();
  13. localStorage.setItem('ivprog.lang', 'en');
  14. const lexer = LanguageService.getCurrentLexer();
  15. it(`should provide the appropriate lexer`, function (done) {
  16. const parser = new IVProgParser(code, lexer);
  17. const exec = new IVProgProcessor(parser.parseTree());
  18. exec.registerOutput(output);
  19. exec.interpretAST().then(sto => {
  20. expect(output.list).toEqual(['8.01']);
  21. localStorage.removeItem('ivprog.lang');
  22. done();
  23. }).catch( err => done(err));
  24. });
  25. });