switch.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. var x = { i : 0, j : 1 };
  6. x.f = function(q) {
  7. WScript.Echo("x.f(" + q + ")");
  8. this.j++;
  9. return q;
  10. }
  11. switch (x.i) {
  12. default:
  13. WScript.Echo("default");
  14. break;
  15. case x.f(1.0):
  16. WScript.Echo(1.0);
  17. break;
  18. case x.f(x.i):
  19. case x.f(j):
  20. WScript.Echo(x.i);
  21. break;
  22. }
  23. switch (x.j) {
  24. default:
  25. case "melon":
  26. WScript.Echo("melon?");
  27. break;
  28. case x.f(0):
  29. WScript.Echo("0");
  30. break;
  31. }
  32. WScript.Echo("x.i = " + x.i);
  33. WScript.Echo("x.j = " + x.j);
  34. switch(Math.sqrt(x.i)) {
  35. case Math.cos(x.j):
  36. break;
  37. case 1 ? 2 : 3:
  38. break;
  39. case "melon":
  40. break;
  41. default:
  42. WScript.Echo('here we are');
  43. }
  44. (function()
  45. {
  46. var f = 0;
  47. switch (f)
  48. {
  49. case ((f = 1)? 0 : 0):
  50. WScript.Echo("pass");
  51. break;
  52. default:
  53. WScript.Echo("fail");
  54. break;
  55. };
  56. })();