| 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.create; |
| 8 |
function create() { [native code for Object.create, arity=2] } |
| 9 |
|
| 10 |
js> expectTypeError(function() { Object.create() }); |
| 11 |
js> [undefined, true, 1, 'hello'].forEach(function(value) { |
| 12 |
> expectTypeError(function() { Object.create(value) }) |
| 13 |
> }) |
| 14 |
js> expectTypeError(function() { Object.create({}, null) }) |
| 15 |
|
| 16 |
js> var obj = Object.create({}); |
| 17 |
js> var obj = Object.create({}, {}); |
| 18 |
js> var obj = Object.create({}, undefined); |
| 19 |
|
| 20 |
js> var orig = {} |
| 21 |
js> var next = Object.create(orig); |
| 22 |
js> Object.getPrototypeOf(next) === orig; |
| 23 |
true |
| 24 |
|
| 25 |
js> var obj = Object.create({}, {a: {value:1}, b: {value:2}}); |
| 26 |
js> [obj.a, obj.b].toSource(); |
| 27 |
[1, 2] |
| 28 |
|
| 29 |
js> var orig = {a:1}; |
| 30 |
js> var obj = Object.create(orig, {a:{value:2}, b:{value:3}}); |
| 31 |
js> [obj.a, obj.b].toSource() |
| 32 |
[2, 3] |
| 33 |
|
| 34 |
js> expectTypeError(function() { Object.create({}, {b: {value:1}, c:1}) }); |
| 35 |
|
| 36 |
js> var obj = Object.create(null, {a: {value:1}}) |
| 37 |
js> Object.getPrototypeOf(obj) === null |
| 38 |
true |
| 39 |
|