repeatIntCases.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. * Testing for normal execution with repeat integers and empty case statements
  8. */
  9. /*
  10. ************************************************** TEST 1******************************************************
  11. * Tests with all integer arguments
  12. */
  13. function f(x)
  14. {
  15. switch(x)
  16. {
  17. case 1:
  18. case 2:
  19. case 2:
  20. case 4:
  21. case 4:
  22. WScript.Echo(5);
  23. break;
  24. case 4:
  25. WScript.Echo(6);
  26. break;
  27. case 6:
  28. WScript.Echo(7);
  29. break;
  30. case 8:
  31. WScript.Echo(8);
  32. break;
  33. case 9:
  34. WScript.Echo(9);
  35. break;
  36. case 10:
  37. WScript.Echo(10);
  38. break;
  39. default:
  40. WScript.Echo('default');
  41. break;
  42. }
  43. }
  44. f(1);
  45. for(i=1; i <= 10; i++)
  46. {
  47. f(i);
  48. }