DirectCall.js 1.0 KB

12345678910111213141516171819202122232425262728
  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 PI = Math.PI;
  6. var c = Math.ceil(PI);
  7. var f = Math.floor(PI);
  8. WScript.Echo(c, f);
  9. (function f()
  10. {
  11. // Test calls that modify the call target operands when the args are evaluated.
  12. // Do this locally, as that's the case that we're most likely to get wrong.
  13. var save;
  14. var O = { foo : function() { return "O.foo"; }, bar : function() { return "O.bar"; } };
  15. O.o = { foo : function() { return "O.o.foo"; }, bar : function() { return "O.o.bar"; } };
  16. WScript.Echo(O.foo(save = O, O = O.o));
  17. WScript.Echo(O.foo(O = save));
  18. var str = 'foo';
  19. WScript.Echo(O[str](O = O.o, str = 'bar'));
  20. WScript.Echo(O[str](O = save, str = 'foo'));
  21. })();