emptyStringCases.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. /*
  6. *******************************UNIT TEST FOR SWITCH CASE OPTIMIZATION*******************************
  7. * Test with two switch statements containing empty case statements and repetition.
  8. */
  9. function f(x)
  10. {
  11. /* Empty cases*/
  12. switch(x)
  13. {
  14. case 'abc':
  15. case 'def':
  16. case 'ghi':
  17. WScript.Echo('empty Cases');
  18. break;
  19. case 'stu':
  20. WScript.Echo('stu');
  21. break;
  22. default:
  23. WScript.Echo('Default cases');
  24. break;
  25. }
  26. /*Repeated empty cases*/
  27. switch(x)
  28. {
  29. case 'abc':
  30. case 'abc':
  31. case 'abc':
  32. WScript.Echo('abc');
  33. break;
  34. case 'def':
  35. WScript.Echo('first def');
  36. break;
  37. case 'def':
  38. WScript.Echo('second def');
  39. break;
  40. default:
  41. WScript.Echo('default');
  42. break;
  43. }
  44. }
  45. f('stu');
  46. f('stu');
  47. f('vxy');
  48. f('z');
  49. f('x');
  50. f('abc');
  51. f('def');
  52. f('ghi');
  53. f('jkl');
  54. f('mno');
  55. f('pqr');
  56. f('saf');