Debian Codegraph @

rhino/testsrc/doctests/object.getprototypeof.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.getPrototypeOf;
8 function getPrototypeOf() { [native code for Object.getPrototypeOf, arity=1] }
9
10 js> expectTypeError(function() { Object.getPrototypeOf() })
11 js> [undefined, null, true, 1, 'hello'].forEach(function(value) {
12 > expectTypeError(function() { Object.getPrototypeOf(value) })
13 > })
14
15 js> [(function(){}), [], {}].every(function(obj) {
16 > return Object.getPrototypeOf(obj) === obj.__proto__;
17 > });
18 true
19
20 js> function UserDefined() {}
21 js> [Date, UserDefined].every(function(type) {
22 > var instance;
23 > eval('instance = new '+type.name);
24 > return Object.getPrototypeOf(instance) === type.prototype;
25 > });
26 true
27