CallStackTests.cs 1.2 KB

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