ParameterOrder.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. // Test calling order of parameters:
  7. // 1. Ensure arguments get evaluated in the correct order
  8. // 2. Ensure arguments are passed in the correct order
  9. //
  10. function a()
  11. {
  12. //
  13. // By displaying the function, we'll validate the correct evaluation order.
  14. //
  15. WScript.Echo("a()");
  16. return 1;
  17. }
  18. function b()
  19. {
  20. WScript.Echo("b()");
  21. return 2;
  22. }
  23. function c(p1, p2)
  24. {
  25. //
  26. // By performing a subtract, we'll validate that p1 and p2 are not mixed.
  27. //
  28. WScript.Echo("c(p1, p2)");
  29. return p1 - p2;
  30. }
  31. function MyClass(p1, p2) {
  32. //
  33. // By performing a subtract, we'll validate that p1 and p2 are not mixed.
  34. //
  35. WScript.Echo("MyClass(p1, p2)");
  36. this.value = p1 - p2;
  37. }
  38. //
  39. // Test a regular function call.
  40. //
  41. WScript.Echo("Regular function call");
  42. var result = c(a(), b());
  43. WScript.Echo(result);
  44. //
  45. // Test a constructor function call.
  46. //
  47. WScript.Echo("Constructor function call");
  48. var result = new MyClass(a(), b());
  49. WScript.Echo(result.value);