Add tests for Reflect.getPrototypeOf

This commit is contained in:
Leonardo Balter 2015-07-29 17:17:27 -04:00
parent ec82bff120
commit b2fd133f88
9 changed files with 181 additions and 0 deletions

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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);

View File

@ -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);
});

View File

@ -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'
);

View File

@ -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'
);

View File

@ -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('');
});

View File

@ -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));
});