mirror of https://github.com/tc39/test262.git
Add tests for Reflect.getPrototypeOf
This commit is contained in:
parent
ec82bff120
commit
b2fd133f88
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 26.1.8
|
||||
description: >
|
||||
Reflect.getPrototypeOf is configurable, writable and not enumerable.
|
||||
info: >
|
||||
26.1.8 Reflect.getPrototypeOf ( target )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
verifyNotEnumerable(Reflect, 'getPrototypeOf');
|
||||
verifyWritable(Reflect, 'getPrototypeOf');
|
||||
verifyConfigurable(Reflect, 'getPrototypeOf');
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 26.1.8
|
||||
description: >
|
||||
Reflect.getPrototypeOf.length value and property descriptor
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.getPrototypeOf.length, 1,
|
||||
'The value of `Reflect.getPrototypeOf.length` is `1`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(Reflect.getPrototypeOf, 'length');
|
||||
verifyNotWritable(Reflect.getPrototypeOf, 'length');
|
||||
verifyConfigurable(Reflect.getPrototypeOf, 'length');
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 26.1.8
|
||||
description: >
|
||||
Reflect.getPrototypeOf.name value and property descriptor
|
||||
info: >
|
||||
26.1.8 Reflect.getPrototypeOf ( target )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.getPrototypeOf.name, 'getPrototypeOf',
|
||||
'The value of `Reflect.getPrototypeOf.name` is `"getPrototypeOf"`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(Reflect.getPrototypeOf, 'name');
|
||||
verifyNotWritable(Reflect.getPrototypeOf, 'name');
|
||||
verifyConfigurable(Reflect.getPrototypeOf, 'name');
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 26.1.8
|
||||
description: >
|
||||
Return null prototype.
|
||||
info: >
|
||||
26.1.8 Reflect.getPrototypeOf ( target )
|
||||
|
||||
...
|
||||
2. Return target.[[GetPrototypeOf]]().
|
||||
---*/
|
||||
|
||||
var o = Object.create(null);
|
||||
assert.sameValue(Reflect.getPrototypeOf(o), null);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 26.1.8
|
||||
description: >
|
||||
Return abrupt result from getting the prototype.
|
||||
info: >
|
||||
26.1.8 Reflect.getPrototypeOf ( target )
|
||||
|
||||
...
|
||||
2. Return target.[[GetPrototypeOf]]().
|
||||
...
|
||||
features: [Proxy]
|
||||
---*/
|
||||
|
||||
var o1 = {};
|
||||
var p = new Proxy(o1, {
|
||||
getPrototypeOf: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Reflect.getPrototypeOf(p);
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 26.1.8
|
||||
description: >
|
||||
Returns the internal [[Prototype]] object.
|
||||
info: >
|
||||
26.1.8 Reflect.getPrototypeOf ( target )
|
||||
|
||||
...
|
||||
2. Return target.[[GetPrototypeOf]]().
|
||||
---*/
|
||||
|
||||
var o = {};
|
||||
assert.sameValue(
|
||||
Reflect.getPrototypeOf(o), Object.prototype,
|
||||
'return default prototypes'
|
||||
);
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 26.1.8
|
||||
description: >
|
||||
Skip own properties to return the internal [[Prototype]] object.
|
||||
info: >
|
||||
26.1.8 Reflect.getPrototypeOf ( target )
|
||||
|
||||
...
|
||||
2. Return target.[[GetPrototypeOf]]().
|
||||
---*/
|
||||
|
||||
var valid = {};
|
||||
var o = Object.create(valid, {
|
||||
prototype: {value: 'invalid', enumerable: true}
|
||||
});
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.getPrototypeOf(o), valid,
|
||||
'skip own properties'
|
||||
);
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 26.1.8
|
||||
description: >
|
||||
Throws a TypeError if target is not an Object.
|
||||
info: >
|
||||
26.1.8 Reflect.getPrototypeOf ( target )
|
||||
|
||||
1. If Type(target) is not Object, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Reflect.getPrototypeOf(1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Reflect.getPrototypeOf(null);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Reflect.getPrototypeOf(undefined);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Reflect.getPrototypeOf('');
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 26.1.8
|
||||
description: >
|
||||
Throws a TypeError if target is a Symbol
|
||||
info: >
|
||||
26.1.8 Reflect.getPrototypeOf ( target )
|
||||
|
||||
1. If Type(target) is not Object, throw a TypeError exception.
|
||||
...
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Reflect.getPrototypeOf(Symbol(1));
|
||||
});
|
Loading…
Reference in New Issue