exception-in-catch-block.js 816 B

12345678910111213141516171819202122232425
  1. test("Issue #1992, exception thrown in catch {} block", () => {
  2. var tryHasBeenExecuted = false;
  3. var catchHasBeenExecuted = false;
  4. var finallyHasBeenExecuted = false;
  5. expect(() => {
  6. try {
  7. tryHasBeenExecuted = true;
  8. foo();
  9. // execution must not reach this step
  10. expect().fail();
  11. } catch (e) {
  12. catchHasBeenExecuted = true;
  13. bar();
  14. // ...also not this step
  15. expect().fail();
  16. } finally {
  17. finallyHasBeenExecuted = true;
  18. }
  19. // ...or this step
  20. expect().fail();
  21. }).toThrow(ReferenceError, "'bar' is not defined");
  22. expect(tryHasBeenExecuted).toBeTrue();
  23. expect(catchHasBeenExecuted).toBeTrue();
  24. expect(finallyHasBeenExecuted).toBeTrue();
  25. });