Debian Codegraph @

rhino/testsrc/tests/ecma_3_1/extensions/regress-478047.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 var gTestfile = 'regress-478047.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 478047;
9 var summary = 'Assign to property with getter but no setter should throw ' +
10 'TypeError';
11 var actual = '';
12 var expect = '';
13
14
15 //-----------------------------------------------------------------------------
16 test();
17 //-----------------------------------------------------------------------------
18
19 function test()
20 {
21 enterFunc ('test');
22 printBugNumber(BUGNUMBER);
23 printStatus (summary);
24
25 expect = 'TypeError: setting a property that has only a getter';
26 try
27 {
28 var o = { get p() { return "a"; } };
29 o.p = "b";
30 }
31 catch(ex)
32 {
33 actual = ex + '';
34 }
35 reportCompare(expect, actual, summary);
36
37
38 actual = '';
39 try
40 {
41 o = { get p() { return "a"; } };
42 T = (function () {});
43 T.prototype = o;
44 y = new T();
45 y.p = "b";
46 }
47 catch(ex)
48 {
49 actual = ex + '';
50 }
51
52 reportCompare(expect, actual, summary);
53
54 exitFunc ('test');
55 }