michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: * Contributor: michael@0: * Jason Orendorff michael@0: * Jeff Walden michael@0: */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 523846; michael@0: var summary = michael@0: "Assignments to a property that has a getter but not a setter should not " + michael@0: "throw a TypeError per ES5 (at least not until strict mode is supported)"; michael@0: var actual = "Early failure"; michael@0: var expect = "No errors"; michael@0: michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus(summary); michael@0: michael@0: var o = { get p() { return "a"; } }; michael@0: michael@0: function test1() michael@0: { michael@0: o.p = "b"; // strict-mode violation here michael@0: assertEq(o.p, "a"); michael@0: } michael@0: michael@0: function test2() michael@0: { michael@0: function T() {} michael@0: T.prototype = o; michael@0: y = new T(); michael@0: y.p = "b"; // strict-mode violation here michael@0: assertEq(y.p, "a"); michael@0: } michael@0: michael@0: michael@0: var errors = []; michael@0: try michael@0: { michael@0: try michael@0: { michael@0: test1(); michael@0: } michael@0: catch (e) michael@0: { michael@0: errors.push(e); michael@0: } michael@0: michael@0: try michael@0: { michael@0: test2(); michael@0: } michael@0: catch (e) michael@0: { michael@0: errors.push(e); michael@0: } michael@0: michael@0: options("strict"); michael@0: options("werror"); michael@0: try michael@0: { michael@0: test1(); michael@0: errors.push("strict+werror didn't make test1 fail"); michael@0: } michael@0: catch (e) michael@0: { michael@0: if (!(e instanceof TypeError)) michael@0: errors.push("test1 with strict+werror failed without a TypeError: " + e); michael@0: } michael@0: michael@0: try michael@0: { michael@0: test2(); michael@0: errors.push("strict+werror didn't make test2 fail"); michael@0: } michael@0: catch (e) michael@0: { michael@0: if (!(e instanceof TypeError)) michael@0: errors.push("test2 with strict+werror failed without a TypeError: " + e); michael@0: } michael@0: michael@0: options("strict"); michael@0: options("werror"); michael@0: } michael@0: catch (e) michael@0: { michael@0: errors.push("Unexpected error: " + e); michael@0: } michael@0: finally michael@0: { michael@0: actual = errors.length > 0 ? errors.join(", ") : "No errors"; michael@0: } michael@0: michael@0: reportCompare(expect, actual, summary);