Debian Codegraph @

rhino/testsrc/doctests/object.isfrozen.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.isFrozen
8 function isFrozen() { [native code for Object.isFrozen, arity=1] }
9
10 js> expectTypeError(function() { Object.isFrozen() });
11 js> [undefined, null, true, 1, 'hello'].forEach(function(value) {
12 > expectTypeError(function() { Object.isFrozen(value) })
13 > })
14
15 js> Object.isFrozen({})
16 false
17
18 js> var obj = Object.preventExtensions({});
19 js> Object.isFrozen(obj);
20 true
21
22 js> var obj = Object.defineProperty({}, 'a', {configurable:true, writable:false})
23 js> var _ = Object.preventExtensions(obj);
24 js> Object.isFrozen(obj);
25 false
26
27 js> var obj = Object.defineProperty({}, 'a', {configurable:false, writable:true})
28 js> var _ = Object.preventExtensions(obj);
29 js> Object.isFrozen(obj);
30 false
31
32 js> var obj = Object.defineProperty({}, 'a', {configurable:false, writable:false})
33 js> var _ = Object.preventExtensions(obj);
34 js> Object.isFrozen(obj);
35 true
36
37 js> var obj = Object.defineProperty({}, 'a', {configurable:false, set: function(){} })
38 js> var _ = Object.preventExtensions(obj);
39 js> Object.isFrozen(obj);
40 true
41