1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/extensions/8.12.5-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* 1.6 + * Any copyright is dedicated to the Public Domain. 1.7 + * http://creativecommons.org/licenses/publicdomain/ 1.8 + * Contributor: 1.9 + * Jason Orendorff 1.10 + * Jeff Walden <jwalden+code@mit.edu> 1.11 + */ 1.12 + 1.13 +//----------------------------------------------------------------------------- 1.14 +var BUGNUMBER = 523846; 1.15 +var summary = 1.16 + "Assignments to a property that has a getter but not a setter should not " + 1.17 + "throw a TypeError per ES5 (at least not until strict mode is supported)"; 1.18 +var actual = "Early failure"; 1.19 +var expect = "No errors"; 1.20 + 1.21 + 1.22 +printBugNumber(BUGNUMBER); 1.23 +printStatus(summary); 1.24 + 1.25 +var o = { get p() { return "a"; } }; 1.26 + 1.27 +function test1() 1.28 +{ 1.29 + o.p = "b"; // strict-mode violation here 1.30 + assertEq(o.p, "a"); 1.31 +} 1.32 + 1.33 +function test2() 1.34 +{ 1.35 + function T() {} 1.36 + T.prototype = o; 1.37 + y = new T(); 1.38 + y.p = "b"; // strict-mode violation here 1.39 + assertEq(y.p, "a"); 1.40 +} 1.41 + 1.42 + 1.43 +var errors = []; 1.44 +try 1.45 +{ 1.46 + try 1.47 + { 1.48 + test1(); 1.49 + } 1.50 + catch (e) 1.51 + { 1.52 + errors.push(e); 1.53 + } 1.54 + 1.55 + try 1.56 + { 1.57 + test2(); 1.58 + } 1.59 + catch (e) 1.60 + { 1.61 + errors.push(e); 1.62 + } 1.63 + 1.64 + options("strict"); 1.65 + options("werror"); 1.66 + try 1.67 + { 1.68 + test1(); 1.69 + errors.push("strict+werror didn't make test1 fail"); 1.70 + } 1.71 + catch (e) 1.72 + { 1.73 + if (!(e instanceof TypeError)) 1.74 + errors.push("test1 with strict+werror failed without a TypeError: " + e); 1.75 + } 1.76 + 1.77 + try 1.78 + { 1.79 + test2(); 1.80 + errors.push("strict+werror didn't make test2 fail"); 1.81 + } 1.82 + catch (e) 1.83 + { 1.84 + if (!(e instanceof TypeError)) 1.85 + errors.push("test2 with strict+werror failed without a TypeError: " + e); 1.86 + } 1.87 + 1.88 + options("strict"); 1.89 + options("werror"); 1.90 +} 1.91 +catch (e) 1.92 +{ 1.93 + errors.push("Unexpected error: " + e); 1.94 +} 1.95 +finally 1.96 +{ 1.97 + actual = errors.length > 0 ? errors.join(", ") : "No errors"; 1.98 +} 1.99 + 1.100 +reportCompare(expect, actual, summary);