Mozilla/mozilla/js/rhino/testsrc/doctests/object.create.doctest
nboyd%atg.com dde158ec11 Allow Object.create to accept null as a first argument
git-svn-id: svn://10.0.0.236/trunk@257740 18797224-902f-48f8-a5cc-f745e15eee43
2009-07-21 00:35:28 +00:00

36 lines
980 B
Plaintext

js> load('testsrc/doctests/util.js');
js> Object.create;
function create() { [native code for Object.create, arity=2] }
js> expectTypeError(function() { Object.create() });
js> [undefined, true, 1, 'hello'].forEach(function(value) {
> expectTypeError(function() { Object.create(value) })
> })
js> expectTypeError(function() { Object.create({}, null) })
js> var obj = Object.create({});
js> var obj = Object.create({}, {});
js> var obj = Object.create({}, undefined);
js> var orig = {}
js> var next = Object.create(orig);
js> Object.getPrototypeOf(next) === orig;
true
js> var obj = Object.create({}, {a: {value:1}, b: {value:2}});
js> [obj.a, obj.b].toSource();
[1, 2]
js> var orig = {a:1};
js> var obj = Object.create(orig, {a:{value:2}, b:{value:3}});
js> [obj.a, obj.b].toSource()
[2, 3]
js> expectTypeError(function() { Object.create({}, {b: {value:1}, c:1}) });
js> var obj = Object.create(null, {a: {value:1}})
js> Object.getPrototypeOf(obj) === null
true