defer4.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // Blue bug 241839
  6. function val() {
  7. return 1;
  8. }
  9. function testSwitch1() {
  10. switch (val()) {
  11. case 1:
  12. let z = 10; // No error
  13. z++;
  14. break;
  15. case 2:
  16. let y = 1; // No error
  17. y++;
  18. break;
  19. }
  20. }
  21. function testSwitch2() {
  22. switch (val()) {
  23. case 1:
  24. switch (val()) {
  25. default:
  26. let a = 1; // No error
  27. break;
  28. }
  29. }
  30. }
  31. function testSwitch3() {
  32. var a = 1;
  33. while (a)
  34. switch (val()) {
  35. default:
  36. let b = 2; // No error
  37. ++b;
  38. a = 0;
  39. break;
  40. }
  41. }
  42. testSwitch1();
  43. testSwitch2();
  44. testSwitch3();
  45. // Reduced hang found during development.
  46. (function () { try { eval(
  47. "switch (Math()) { \
  48. default: \
  49. function func4() { \
  50. switch (--e) { \
  51. } \
  52. } \
  53. }"
  54. ); } catch (e) { WScript.Echo(e) }})();
  55. WScript.Echo('Pass');