Logical.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 = 0;
  6. var y = 1;
  7. var z = x && WScript.Echo("Should have short-circuited '&&' (1)");
  8. WScript.Echo("z == " + z + " (2)");
  9. z = y || WScript.Echo("Should have short-circuited '||' (3)");
  10. WScript.Echo("z == " + z + " (4)");
  11. z = y && WScript.Echo("z == " + z + " (5)");
  12. z = x || WScript.Echo("z == " + z + " (6)");
  13. z = 1;
  14. if (x || !(z = 0)) {
  15. WScript.Echo("z == " + z + " (7)");
  16. }
  17. z = 2;
  18. if (y && !(z = 0)) {
  19. WScript.Echo("z == " + z + " (8)");
  20. }
  21. z = 0;
  22. if (!y && (z = 3)) {
  23. WScript.Echo("Should not be here (9)");
  24. }
  25. WScript.Echo("z == " + z + " (10)");
  26. z = 0;
  27. if (!x || (z = 4)) {
  28. WScript.Echo("z == " + z + " (11)");
  29. }