michael@0: // Any copyright is dedicated to the Public Domain. michael@0: // http://creativecommons.org/licenses/publicdomain/ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 732669; michael@0: var summary = "Primitive values don't box correctly"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: var t; michael@0: function returnThis() { return this; } michael@0: michael@0: // Boolean michael@0: michael@0: Boolean.prototype.method = returnThis; michael@0: t = true.method(); michael@0: assertEq(t !== Boolean.prototype, true); michael@0: assertEq(t.toString(), "true"); michael@0: michael@0: Object.defineProperty(Boolean.prototype, "property", { get: returnThis, configurable: true }); michael@0: t = false.property; michael@0: assertEq(t !== Boolean.prototype, true); michael@0: assertEq(t.toString(), "false"); michael@0: michael@0: delete Boolean.prototype.method; michael@0: delete Boolean.prototype.property; michael@0: michael@0: michael@0: // Number michael@0: michael@0: Number.prototype.method = returnThis; michael@0: t = 5..method(); michael@0: assertEq(t !== Number.prototype, true); michael@0: assertEq(t.toString(), "5"); michael@0: michael@0: Object.defineProperty(Number.prototype, "property", { get: returnThis, configurable: true }); michael@0: t = 17..property; michael@0: assertEq(t !== Number.prototype, true); michael@0: assertEq(t.toString(), "17"); michael@0: michael@0: delete Number.prototype.method; michael@0: delete Number.prototype.property; michael@0: michael@0: michael@0: // String michael@0: michael@0: String.prototype.method = returnThis; michael@0: t = "foo".method(); michael@0: assertEq(t !== String.prototype, true); michael@0: assertEq(t.toString(), "foo"); michael@0: michael@0: Object.defineProperty(String.prototype, "property", { get: returnThis, configurable: true }); michael@0: t = "bar".property; michael@0: assertEq(t !== String.prototype, true); michael@0: assertEq(t.toString(), "bar"); michael@0: michael@0: delete String.prototype.method; michael@0: delete String.prototype.property; michael@0: michael@0: michael@0: // Object michael@0: michael@0: Object.prototype.method = returnThis; michael@0: michael@0: t = true.method(); michael@0: assertEq(t !== Object.prototype, true); michael@0: assertEq(t !== Boolean.prototype, true); michael@0: assertEq(t.toString(), "true"); michael@0: michael@0: t = 42..method(); michael@0: assertEq(t !== Object.prototype, true); michael@0: assertEq(t !== Number.prototype, true); michael@0: assertEq(t.toString(), "42"); michael@0: michael@0: t = "foo".method(); michael@0: assertEq(t !== Object.prototype, true); michael@0: assertEq(t !== String.prototype, true); michael@0: assertEq(t.toString(), "foo"); michael@0: michael@0: Object.defineProperty(Object.prototype, "property", { get: returnThis, configurable: true }); michael@0: michael@0: t = false.property; michael@0: assertEq(t !== Object.prototype, true); michael@0: assertEq(t !== Boolean.prototype, true); michael@0: assertEq(t.toString(), "false"); michael@0: michael@0: t = 8675309..property; michael@0: assertEq(t !== Object.prototype, true); michael@0: assertEq(t !== Number.prototype, true); michael@0: assertEq(t.toString(), "8675309"); michael@0: michael@0: t = "bar".property; michael@0: assertEq(t !== Object.prototype, true); michael@0: assertEq(t !== String.prototype, true); michael@0: assertEq(t.toString(), "bar"); michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("Tests complete");