try.bug188541.v5.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. function foo() {
  6. try {
  7. throw "foo error";
  8. } catch (e) {
  9. WScript.Echo("Caught e=" + e);
  10. {
  11. let e = 10;
  12. WScript.Echo("Caught e=" + e);
  13. }
  14. WScript.Echo("Caught e=" + e);
  15. }
  16. }
  17. function foo2() {
  18. try {
  19. throw "foo error";
  20. } catch (e) {
  21. WScript.Echo("Caught e=" + e);
  22. var e = 10;
  23. WScript.Echo("Caught e=" + e);
  24. }
  25. }
  26. function foo3() {
  27. try {
  28. throw "foo error";
  29. } catch (e) {
  30. WScript.Echo("Caught e=" + e);
  31. var e = 10;
  32. {
  33. try {
  34. e = 0;
  35. }
  36. catch(err) {
  37. WScript.Echo("Caught expected err=" + err);
  38. }
  39. let e = 20;
  40. WScript.Echo("Caught e=" + e);
  41. }
  42. WScript.Echo("Caught e=" + e);
  43. }
  44. }
  45. function foo4() {
  46. try {
  47. throw "foo error";
  48. } catch (e) {
  49. WScript.Echo("Caught e=" + e);
  50. {
  51. let e = 20;
  52. WScript.Echo("Caught e=" + e);
  53. }
  54. WScript.Echo("Caught e=" + e);
  55. }
  56. }
  57. function foo5() {
  58. try {
  59. throw "foo error";
  60. } catch (e) {
  61. WScript.Echo("Caught e=" + e);
  62. e = 10;
  63. {
  64. try {
  65. e = 0;
  66. }
  67. catch(err) {
  68. WScript.Echo("Caught expected err=" + err);
  69. }
  70. let e = 20;
  71. WScript.Echo("Caught e=" + e);
  72. }
  73. WScript.Echo("Caught e=" + e);
  74. }
  75. }
  76. WScript.Echo("foo():");
  77. foo();
  78. WScript.Echo("");
  79. WScript.Echo("foo2():");
  80. foo2();
  81. WScript.Echo("");
  82. WScript.Echo("foo3():");
  83. foo3();
  84. WScript.Echo("");
  85. WScript.Echo("foo4():");
  86. foo4();
  87. WScript.Echo("");
  88. WScript.Echo("foo5():");
  89. foo5();
  90. WScript.Echo("");
  91. WScript.Echo("PASSED");