try5-ES3.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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 write(args)
  6. {
  7. WScript.Echo(args);
  8. }
  9. var scenario= 1;
  10. function InitScenario()
  11. {
  12. write("Scenario " + scenario++);
  13. }
  14. var e = "I am alive";
  15. InitScenario(); //1
  16. try
  17. {
  18. throw "abc";
  19. }
  20. catch(e)
  21. {
  22. write(e);
  23. }
  24. write(e);
  25. InitScenario();//2
  26. try
  27. {
  28. throw "abc";
  29. }
  30. catch(e)
  31. {
  32. e = 20;
  33. write(e);
  34. }
  35. write(e);
  36. InitScenario();//3
  37. var a = new Object();
  38. a.e = "I am inside with";
  39. with(a)
  40. {
  41. try
  42. {
  43. throw "abc";
  44. }
  45. catch(e)
  46. {
  47. e = 20;
  48. write(e);
  49. }
  50. write(e);
  51. }
  52. write(e);
  53. InitScenario();//4
  54. try
  55. {
  56. throw "abc";
  57. }
  58. catch(e)
  59. {
  60. var a = new Object();
  61. a.e = "I am inside with";
  62. with(a)
  63. {
  64. write(e);
  65. }
  66. write(e);
  67. }
  68. write(e);
  69. InitScenario();//5
  70. try
  71. {
  72. throw "abc";
  73. }
  74. catch(e)
  75. {
  76. var a = 10;
  77. }
  78. write(a);
  79. InitScenario();//6
  80. try
  81. {
  82. throw "abc";
  83. }
  84. catch(e)
  85. {
  86. var a = function () { return "hello world";};
  87. }
  88. write(a());
  89. InitScenario();//7
  90. try
  91. {
  92. throw "abc";
  93. }
  94. catch(e)
  95. {
  96. eval("a = function () { return 'hello world';};");
  97. }
  98. write(a());
  99. InitScenario();//8
  100. try
  101. {
  102. throw "abc";
  103. }
  104. catch(e)
  105. {
  106. c = 30;
  107. }
  108. write(c);
  109. InitScenario();//9
  110. var foo = function ()
  111. {
  112. try
  113. {
  114. throw "abc";
  115. }
  116. catch(e)
  117. {
  118. write(e);
  119. }
  120. write(e);
  121. }
  122. foo();
  123. InitScenario();//10
  124. foo = function ()
  125. {
  126. try
  127. {
  128. throw "abc";
  129. }
  130. catch(e)
  131. {
  132. e = 20;
  133. write(e);
  134. }
  135. write(e);
  136. }
  137. foo();
  138. InitScenario();//11
  139. foo = function ()
  140. {
  141. var a = new Object();
  142. a.e = "I am inside with";
  143. with(a)
  144. {
  145. try
  146. {
  147. throw "abc";
  148. }
  149. catch(e)
  150. {
  151. e = 20;
  152. write(e);
  153. }
  154. write(e);
  155. }
  156. write(e);
  157. }
  158. foo();
  159. InitScenario();//12
  160. foo = function ()
  161. {
  162. try
  163. {
  164. throw "abc";
  165. }
  166. catch(e)
  167. {
  168. var a = new Object();
  169. a.e = "I am inside with";
  170. with(a)
  171. {
  172. write(e);
  173. }
  174. write(e);
  175. }
  176. write(e);
  177. }
  178. InitScenario();//13
  179. foo = function ()
  180. {
  181. try
  182. {
  183. throw "abc";
  184. }
  185. catch(e)
  186. {
  187. var a = 10;
  188. }
  189. write(a);
  190. }
  191. foo();
  192. InitScenario();//14
  193. foo = function ()
  194. {
  195. try
  196. {
  197. throw "abc";
  198. }
  199. catch(e)
  200. {
  201. var a = function () { return "hello world";};
  202. }
  203. write(a());
  204. }
  205. foo();
  206. InitScenario();//15
  207. foo = function ()
  208. {
  209. try
  210. {
  211. throw "abc";
  212. }
  213. catch(e)
  214. {
  215. eval("a = function () { return 'hello world';};");
  216. }
  217. write(a());
  218. }
  219. foo();
  220. InitScenario();//16
  221. foo = function ()
  222. {
  223. try
  224. {
  225. throw "abc";
  226. }
  227. catch(e)
  228. {
  229. c = 30;
  230. }
  231. write(c);
  232. }
  233. foo();
  234. InitScenario();//17
  235. foo = function ()
  236. {
  237. var test = 'pass';
  238. try {
  239. throw 'fail';
  240. } catch (test) {
  241. test += 'ing';
  242. }
  243. write(test);
  244. }
  245. foo();
  246. //raise bug for this eval scenario
  247. InitScenario();
  248. try
  249. {
  250. throw "abc";
  251. }
  252. catch(e)
  253. {
  254. eval("a = 10;");
  255. }
  256. write(a);
  257. InitScenario();
  258. foo = function ()
  259. {
  260. try
  261. {
  262. throw "abc";
  263. }
  264. catch(e)
  265. {
  266. eval("a = 19;");
  267. }
  268. write(a);
  269. }
  270. foo();