loopAndRetarget.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 loop and retarget cases.
  8. */
  9. function f(x)
  10. {
  11. /* Retargetting*/
  12. switch(x)
  13. {
  14. case 'abc':
  15. break;
  16. case 'stu':
  17. break;
  18. default:
  19. WScript.Echo('Default cases');
  20. break;
  21. }
  22. /*Loop*/
  23. for(i = 0; i < 2; i++)
  24. {
  25. switch(x)
  26. {
  27. case 'abc':
  28. WScript.Echo('abc');
  29. break;
  30. case 'def':
  31. break;
  32. default:
  33. WScript.Echo('default');
  34. break;
  35. }
  36. }
  37. }
  38. f('stu');
  39. f('stu');
  40. f('vxy');
  41. f('z');
  42. f('x');
  43. f('abc');
  44. f('def');
  45. f('ghi');
  46. f('jkl');
  47. f('mno');
  48. f('pqr');
  49. f('saf');