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