Debian Codegraph @

rhino/testsrc/doctests/object.extensible.doctest

raw
1 // This Source Code Form is subject to the terms of the Mozilla Public
2 // License, v. 2.0. If a copy of the MPL was not distributed with this
3 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 js> load('testsrc/doctests/util.js');
6
7 js> Object.isExtensible;
8 function isExtensible() { [native code for Object.isExtensible, arity=1] }
9 js> expectTypeError(function() { Object.isExtensible() });
10 js> [undefined, null, true, 1, 'hello'].forEach(function(value) {
11 > expectTypeError(function() { Object.isExtensible(value) })
12 > })
13
14 js> Object.preventExtensions;
15 function preventExtensions() { [native code for Object.preventExtensions, arity=1] }
16 js> expectTypeError(function() { Object.preventExtensions() });
17 js> [undefined, null, true, 1, 'hello'].forEach(function(value) {
18 > expectTypeError(function() { Object.preventExtensions(value) })
19 > })
20
21 js> var x = {};
22 js> Object.isExtensible(x);
23 true
24 js> var y = Object.preventExtensions(x);
25 js> y === x;
26 true
27 js> Object.isExtensible(x);
28 false
29
30 js> x.a = 1; x.a
31 js>
32
33 js> x.__defineGetter__('b', function() { return 1 }); x.b
34 js>