js/src/tests/ecma_5/extensions/8.12.5-01.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /*
michael@0 3 * Any copyright is dedicated to the Public Domain.
michael@0 4 * http://creativecommons.org/licenses/publicdomain/
michael@0 5 * Contributor:
michael@0 6 * Jason Orendorff
michael@0 7 * Jeff Walden <jwalden+code@mit.edu>
michael@0 8 */
michael@0 9
michael@0 10 //-----------------------------------------------------------------------------
michael@0 11 var BUGNUMBER = 523846;
michael@0 12 var summary =
michael@0 13 "Assignments to a property that has a getter but not a setter should not " +
michael@0 14 "throw a TypeError per ES5 (at least not until strict mode is supported)";
michael@0 15 var actual = "Early failure";
michael@0 16 var expect = "No errors";
michael@0 17
michael@0 18
michael@0 19 printBugNumber(BUGNUMBER);
michael@0 20 printStatus(summary);
michael@0 21
michael@0 22 var o = { get p() { return "a"; } };
michael@0 23
michael@0 24 function test1()
michael@0 25 {
michael@0 26 o.p = "b"; // strict-mode violation here
michael@0 27 assertEq(o.p, "a");
michael@0 28 }
michael@0 29
michael@0 30 function test2()
michael@0 31 {
michael@0 32 function T() {}
michael@0 33 T.prototype = o;
michael@0 34 y = new T();
michael@0 35 y.p = "b"; // strict-mode violation here
michael@0 36 assertEq(y.p, "a");
michael@0 37 }
michael@0 38
michael@0 39
michael@0 40 var errors = [];
michael@0 41 try
michael@0 42 {
michael@0 43 try
michael@0 44 {
michael@0 45 test1();
michael@0 46 }
michael@0 47 catch (e)
michael@0 48 {
michael@0 49 errors.push(e);
michael@0 50 }
michael@0 51
michael@0 52 try
michael@0 53 {
michael@0 54 test2();
michael@0 55 }
michael@0 56 catch (e)
michael@0 57 {
michael@0 58 errors.push(e);
michael@0 59 }
michael@0 60
michael@0 61 options("strict");
michael@0 62 options("werror");
michael@0 63 try
michael@0 64 {
michael@0 65 test1();
michael@0 66 errors.push("strict+werror didn't make test1 fail");
michael@0 67 }
michael@0 68 catch (e)
michael@0 69 {
michael@0 70 if (!(e instanceof TypeError))
michael@0 71 errors.push("test1 with strict+werror failed without a TypeError: " + e);
michael@0 72 }
michael@0 73
michael@0 74 try
michael@0 75 {
michael@0 76 test2();
michael@0 77 errors.push("strict+werror didn't make test2 fail");
michael@0 78 }
michael@0 79 catch (e)
michael@0 80 {
michael@0 81 if (!(e instanceof TypeError))
michael@0 82 errors.push("test2 with strict+werror failed without a TypeError: " + e);
michael@0 83 }
michael@0 84
michael@0 85 options("strict");
michael@0 86 options("werror");
michael@0 87 }
michael@0 88 catch (e)
michael@0 89 {
michael@0 90 errors.push("Unexpected error: " + e);
michael@0 91 }
michael@0 92 finally
michael@0 93 {
michael@0 94 actual = errors.length > 0 ? errors.join(", ") : "No errors";
michael@0 95 }
michael@0 96
michael@0 97 reportCompare(expect, actual, summary);

mercurial