getter_sideeffect.js 602 B

123456789101112131415161718
  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. function Ctor()
  6. {
  7. };
  8. Object.defineProperty(Ctor.prototype, "x", { get: function() { this.count = 0; return 1; } });
  9. function f(o)
  10. {
  11. return o.x;
  12. }
  13. if (f(new Ctor()) == f(new Ctor())) { WScript.Echo("PASS"); }