CallStackTests.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. namespace Jint.Tests.Runtime;
  2. public class CallStackTests
  3. {
  4. [Fact]
  5. public void ShouldUnwindAfterCaughtException()
  6. {
  7. var engine = new Engine();
  8. engine.Execute(@"
  9. function thrower()
  10. {
  11. throw new Error('test');
  12. }
  13. try
  14. {
  15. thrower();
  16. }
  17. catch (error)
  18. {
  19. }
  20. "
  21. );
  22. Assert.Equal(0, engine.CallStack.Count);
  23. }
  24. [Fact]
  25. public void ShouldUnwindAfterCaughtExceptionNested()
  26. {
  27. var engine = new Engine();
  28. engine.Execute(@"
  29. function thrower2()
  30. {
  31. throw new Error('test');
  32. }
  33. function thrower1()
  34. {
  35. thrower2();
  36. }
  37. try
  38. {
  39. thrower1();
  40. }
  41. catch (error)
  42. {
  43. }
  44. ");
  45. Assert.Equal(0, engine.CallStack.Count);
  46. }
  47. }