CallStackTests.cs 1.2 KB

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