michael@0: // Define a test object michael@0: var test = {x:1,y:2}; michael@0: michael@0: // Put the object into dictionary mode by deleting michael@0: // a property that was not the last one added. michael@0: delete test.x; michael@0: michael@0: // Define a an accessor property with a setter that michael@0: // itself calls Object.defineProperty michael@0: Object.defineProperty(test, "foo", { michael@0: get: function() { return 1; }, michael@0: set: function(v) { michael@0: Object.defineProperty(this, "foo", { value: v }); michael@0: // Prints the correct object descriptor michael@0: assertEq(this.foo, 33); michael@0: }, michael@0: configurable: true michael@0: }); michael@0: michael@0: // Add another property, so generateOwnShape does not replace the foo property. michael@0: test.other = 0; michael@0: michael@0: // This line prints 1, as expected michael@0: assertEq(test.foo, 1); michael@0: michael@0: // Now set the property. This calls the setter method above. michael@0: // And the setter method prints the expected value and property descriptor. michael@0: test.foo = 33; michael@0: michael@0: // Finally read the newly set value. michael@0: assertEq(test.foo, 33); michael@0: michael@0: // Check that enumeration order is correct. michael@0: var arr = []; michael@0: for (var x in test) arr.push(x); michael@0: assertEq("" + arr, "y,other");