test51.spec.js 771 B

1234567891011121314151617181920212223242526272829
  1. import { IVProgParser } from './../js/ast/ivprogParser';
  2. import { SemanticAnalyser } from './../js/processor/semantic/semanticAnalyser';
  3. import { LanguageService } from '../js/services/languageService';
  4. describe('A invalid relational operation inside an if', function () {
  5. const code = `programa {
  6. funcao inicio() {
  7. inteiro a = 5
  8. se ( a * 2.3 > 8) {
  9. a = 8
  10. } senao {
  11. a = -1
  12. }
  13. }
  14. }`;
  15. localStorage.setItem('ivprog.lang', 'pt');
  16. const lexer = LanguageService.getCurrentLexer();
  17. it(`should throw an exception`, function () {
  18. const parser = new IVProgParser(code, lexer);
  19. const sem = new SemanticAnalyser(parser.parseTree());
  20. const fun = sem.analyseTree.bind(sem);
  21. expect(fun).toThrow();
  22. });
  23. });