Debian Codegraph @

rhino/testsrc/tests/ecma_3/Object/8.6.1-01.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 = '8.6.1-01.js';
7 //-----------------------------------------------------------------------------
8
9 var BUGNUMBER = 315436;
10 var summary = 'In strict mode, setting a read-only property should generate a warning';
11
12 printBugNumber(BUGNUMBER);
13 printStatus (summary);
14
15 enterFunc (String (BUGNUMBER));
16
17 // should throw an error in strict mode
18 var actual = '';
19 var expect = 's.length is read-only';
20 var status = summary + ': Throw if STRICT and WERROR is enabled';
21
22 if (!options().match(/strict/))
23 {
24 options('strict');
25 }
26 if (!options().match(/werror/))
27 {
28 options('werror');
29 }
30
31 try
32 {
33 var s = new String ('abc');
34 s.length = 0;
35 }
36 catch (e)
37 {
38 actual = e.message;
39 }
40
41 reportCompare(expect, actual, status);
42
43 // should not throw an error if in strict mode and WERROR is false
44
45 actual = 'did not throw';
46 expect = 'did not throw';
47 var status = summary + ': Do not throw if STRICT is enabled and WERROR is disabled';
48
49 // toggle werror off
50 options('werror');
51
52 try
53 {
54 s.length = 0;
55 }
56 catch (e)
57 {
58 actual = e.message;
59 }
60
61 reportCompare(expect, actual, status);
62
63 // should not throw an error if not in strict mode
64
65 actual = 'did not throw';
66 expect = 'did not throw';
67 var status = summary + ': Do not throw if not in strict mode';
68
69 // toggle strict off
70 options('strict');
71
72 try
73 {
74 s.length = 0;
75 }
76 catch (e)
77 {
78 actual = e.message;
79 }
80
81 reportCompare(expect, actual, status);