Test built-in function requirements of Promise and Proxy helper functions

This commit is contained in:
André Bargull 2015-11-24 20:12:55 +01:00
parent fd44cd73df
commit 38c6700cbb
25 changed files with 555 additions and 0 deletions

View File

@ -0,0 +1,25 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.4.1.2
description: The [[Extensible]] slot of Promise.all Resolve Element functions
info: >
17 ECMAScript Standard Built-in Objects:
Unless specified otherwise, the [[Extensible]] internal slot
of a built-in object initially has the value true.
---*/
var resolveElementFunction;
var thenable = {
then: function(fulfill) {
resolveElementFunction = fulfill;
}
};
function NotPromise(executor) {
executor(function(){}, function(){});
}
NotPromise.resolve = function(v) { return v; };
Promise.all.call(NotPromise, [thenable]);
assert(Object.isExtensible(resolveElementFunction));

View File

@ -0,0 +1,33 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.4.1.2
description: The `length` property of Promise.all Resolve Element functions
info: >
The length property of a Promise.all resolve element function is 1.
17 ECMAScript Standard Built-in Objects:
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
var resolveElementFunction;
var thenable = {
then: function(fulfill) {
resolveElementFunction = fulfill;
}
};
function NotPromise(executor) {
executor(function(){}, function(){});
}
NotPromise.resolve = function(v) { return v; };
Promise.all.call(NotPromise, [thenable]);
assert.sameValue(resolveElementFunction.length, 1);
verifyNotEnumerable(resolveElementFunction, "length");
verifyNotWritable(resolveElementFunction, "length");
verifyConfigurable(resolveElementFunction, "length");

View File

@ -0,0 +1,28 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.4.1.2
description: The `name` property of Promise.all Resolve Element functions
info: >
A promise resolve function is an anonymous built-in function.
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value
is a String.
---*/
var resolveElementFunction;
var thenable = {
then: function(fulfill) {
resolveElementFunction = fulfill;
}
};
function NotPromise(executor) {
executor(function(){}, function(){});
}
NotPromise.resolve = function(v) { return v; };
Promise.all.call(NotPromise, [thenable]);
assert.sameValue(Object.prototype.hasOwnProperty.call(resolveElementFunction, "name"), false);

View File

@ -0,0 +1,27 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.4.1.2
description: Promise.all Resolve Element functions are not constructors
info: >
17 ECMAScript Standard Built-in Objects:
Built-in function objects that are not identified as constructors do not
implement the [[Construct]] internal method unless otherwise specified
in the description of a particular function.
---*/
var resolveElementFunction;
var thenable = {
then: function(fulfill) {
resolveElementFunction = fulfill;
}
};
function NotPromise(executor) {
executor(function(){}, function(){});
}
NotPromise.resolve = function(v) { return v; };
Promise.all.call(NotPromise, [thenable]);
assert.sameValue(Object.prototype.hasOwnProperty.call(resolveElementFunction, "prototype"), false);
assert.throws(TypeError, function() { new resolveElementFunction(); });

View File

@ -0,0 +1,27 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.4.1.2
description: The [[Prototype]] of Promise.all Resolve Element functions
info: >
17 ECMAScript Standard Built-in Objects:
Unless otherwise specified every built-in function and every built-in
constructor has the Function prototype object, which is the initial
value of the expression Function.prototype (19.2.3), as the value of
its [[Prototype]] internal slot.
---*/
var resolveElementFunction;
var thenable = {
then: function(fulfill) {
resolveElementFunction = fulfill;
}
};
function NotPromise(executor) {
executor(function(){}, function(){});
}
NotPromise.resolve = function(v) { return v; };
Promise.all.call(NotPromise, [thenable]);
assert.sameValue(Object.getPrototypeOf(resolveElementFunction), Function.prototype);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.5.1
description: The [[Extensible]] slot of GetCapabilitiesExecutor functions
info: >
17 ECMAScript Standard Built-in Objects:
Unless specified otherwise, the [[Extensible]] internal slot
of a built-in object initially has the value true.
---*/
var executorFunction;
function NotPromise(executor) {
executorFunction = executor;
executor(() => {}, () => {});
}
Promise.resolve.call(NotPromise);
assert(Object.isExtensible(executorFunction));

View File

@ -0,0 +1,28 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.5.1
description: The `length` property of GetCapabilitiesExecutor functions
info: >
The length property of a GetCapabilitiesExecutor function is 2.
17 ECMAScript Standard Built-in Objects:
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
var executorFunction;
function NotPromise(executor) {
executorFunction = executor;
executor(() => {}, () => {});
}
Promise.resolve.call(NotPromise);
assert.sameValue(executorFunction.length, 2);
verifyNotEnumerable(executorFunction, "length");
verifyNotWritable(executorFunction, "length");
verifyConfigurable(executorFunction, "length");

View File

@ -0,0 +1,23 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.5.1
description: The `name` property of GetCapabilitiesExecutor functions
info: >
A GetCapabilitiesExecutor function is an anonymous built-in function.
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value
is a String.
---*/
var executorFunction;
function NotPromise(executor) {
executorFunction = executor;
executor(() => {}, () => {});
}
Promise.resolve.call(NotPromise);
assert.sameValue(Object.prototype.hasOwnProperty.call(executorFunction, "name"), false);

View File

@ -0,0 +1,22 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.5.1
description: GetCapabilitiesExecutor functions are not constructors
info: >
17 ECMAScript Standard Built-in Objects:
Built-in function objects that are not identified as constructors do not
implement the [[Construct]] internal method unless otherwise specified
in the description of a particular function.
---*/
var executorFunction;
function NotPromise(executor) {
executorFunction = executor;
executor(() => {}, () => {});
}
Promise.resolve.call(NotPromise);
assert.sameValue(Object.prototype.hasOwnProperty.call(executorFunction, "prototype"), false);
assert.throws(TypeError, function() { new executorFunction(); });

View File

@ -0,0 +1,22 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.5.1
description: The [[Prototype]] of GetCapabilitiesExecutor functions
info: >
17 ECMAScript Standard Built-in Objects:
Unless otherwise specified every built-in function and every built-in
constructor has the Function prototype object, which is the initial
value of the expression Function.prototype (19.2.3), as the value of
its [[Prototype]] internal slot.
---*/
var executorFunction;
function NotPromise(executor) {
executorFunction = executor;
executor(() => {}, () => {});
}
Promise.resolve.call(NotPromise);
assert.sameValue(Object.getPrototypeOf(executorFunction), Function.prototype);

View File

@ -0,0 +1,18 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.3.1
description: The [[Extensible]] slot of Promise Reject functions
info: >
17 ECMAScript Standard Built-in Objects:
Unless specified otherwise, the [[Extensible]] internal slot
of a built-in object initially has the value true.
---*/
var rejectFunction;
new Promise(function(resolve, reject) {
rejectFunction = reject;
});
assert(Object.isExtensible(rejectFunction));

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.3.1
description: The `length` property of Promise Reject functions
info: >
The length property of a promise reject function is 1.
17 ECMAScript Standard Built-in Objects:
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
var rejectFunction;
new Promise(function(resolve, reject) {
rejectFunction = reject;
});
assert.sameValue(rejectFunction.length, 1);
verifyNotEnumerable(rejectFunction, "length");
verifyNotWritable(rejectFunction, "length");
verifyConfigurable(rejectFunction, "length");

View File

@ -0,0 +1,21 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.3.1
description: The `name` property of Promise Reject functions
info: >
A promise reject function is an anonymous built-in function.
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value
is a String.
---*/
var rejectFunction;
new Promise(function(resolve, reject) {
rejectFunction = reject;
});
assert.sameValue(Object.prototype.hasOwnProperty.call(rejectFunction, "name"), false);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.3.1
description: Promise Reject functions are not constructors
info: >
17 ECMAScript Standard Built-in Objects:
Built-in function objects that are not identified as constructors do not
implement the [[Construct]] internal method unless otherwise specified
in the description of a particular function.
---*/
var rejectFunction;
new Promise(function(resolve, reject) {
rejectFunction = reject;
});
assert.sameValue(Object.prototype.hasOwnProperty.call(rejectFunction, "prototype"), false);
assert.throws(TypeError, function() { new rejectFunction(); });

View File

@ -0,0 +1,20 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.3.1
description: The [[Prototype]] of Promise Reject functions
info: >
17 ECMAScript Standard Built-in Objects:
Unless otherwise specified every built-in function and every built-in
constructor has the Function prototype object, which is the initial
value of the expression Function.prototype (19.2.3), as the value of
its [[Prototype]] internal slot.
---*/
var rejectFunction;
new Promise(function(resolve, reject) {
rejectFunction = reject;
});
assert.sameValue(Object.getPrototypeOf(rejectFunction), Function.prototype);

View File

@ -0,0 +1,18 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.3.2
description: The [[Extensible]] slot of Promise Resolve functions
info: >
17 ECMAScript Standard Built-in Objects:
Unless specified otherwise, the [[Extensible]] internal slot
of a built-in object initially has the value true.
---*/
var resolveFunction;
new Promise(function(resolve, reject) {
resolveFunction = resolve;
});
assert(Object.isExtensible(resolveFunction));

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.3.2
description: The `length` property of Promise Resolve functions
info: >
The length property of a promise resolve function is 1.
17 ECMAScript Standard Built-in Objects:
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
var resolveFunction;
new Promise(function(resolve, reject) {
resolveFunction = resolve;
});
assert.sameValue(resolveFunction.length, 1);
verifyNotEnumerable(resolveFunction, "length");
verifyNotWritable(resolveFunction, "length");
verifyConfigurable(resolveFunction, "length");

View File

@ -0,0 +1,21 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.3.2
description: The `name` property of Promise Resolve functions
info: >
A promise resolve function is an anonymous built-in function.
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value
is a String.
---*/
var resolveFunction;
new Promise(function(resolve, reject) {
resolveFunction = resolve;
});
assert.sameValue(Object.prototype.hasOwnProperty.call(resolveFunction, "name"), false);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.3.2
description: Promise Resolve functions are not constructors
info: >
17 ECMAScript Standard Built-in Objects:
Built-in function objects that are not identified as constructors do not
implement the [[Construct]] internal method unless otherwise specified
in the description of a particular function.
---*/
var resolveFunction;
new Promise(function(resolve, reject) {
resolveFunction = resolve;
});
assert.sameValue(Object.prototype.hasOwnProperty.call(resolveFunction, "prototype"), false);
assert.throws(TypeError, function() { new resolveFunction(); });

View File

@ -0,0 +1,20 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.1.3.2
description: The [[Prototype]] of Promise Resolve functions
info: >
17 ECMAScript Standard Built-in Objects:
Unless otherwise specified every built-in function and every built-in
constructor has the Function prototype object, which is the initial
value of the expression Function.prototype (19.2.3), as the value of
its [[Prototype]] internal slot.
---*/
var resolveFunction;
new Promise(function(resolve, reject) {
resolveFunction = resolve;
});
assert.sameValue(Object.getPrototypeOf(resolveFunction), Function.prototype);

View File

@ -0,0 +1,15 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.2.2.1.1
description: The [[Extensible]] slot of Proxy Revocation functions
info: >
17 ECMAScript Standard Built-in Objects:
Unless specified otherwise, the [[Extensible]] internal slot
of a built-in object initially has the value true.
---*/
var revocationFunction = Proxy.revocable({}, {}).revoke;
assert(Object.isExtensible(revocationFunction));

View File

@ -0,0 +1,23 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.2.2.1.1
description: The `length` property of Proxy Revocation functions
info: >
The length property of a Proxy revocation function is 0.
17 ECMAScript Standard Built-in Objects:
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
var revocationFunction = Proxy.revocable({}, {}).revoke;
assert.sameValue(revocationFunction.length, 0);
verifyNotEnumerable(revocationFunction, "length");
verifyNotWritable(revocationFunction, "length");
verifyConfigurable(revocationFunction, "length");

View File

@ -0,0 +1,18 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.2.2.1.1
description: The `name` property of Proxy Revocation functions
info: >
A Proxy revocation function is an anonymous function.
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value
is a String.
---*/
var revocationFunction = Proxy.revocable({}, {}).revoke;
assert.sameValue(Object.prototype.hasOwnProperty.call(revocationFunction, "name"), false);

View File

@ -0,0 +1,17 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.2.2.1.1
description: Proxy Revocation functions are not constructors
info: >
17 ECMAScript Standard Built-in Objects:
Built-in function objects that are not identified as constructors do not
implement the [[Construct]] internal method unless otherwise specified
in the description of a particular function.
---*/
var revocationFunction = Proxy.revocable({}, {}).revoke;
assert.sameValue(Object.prototype.hasOwnProperty.call(revocationFunction, "prototype"), false);
assert.throws(TypeError, function() { new revocationFunction(); });

View File

@ -0,0 +1,17 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.2.2.1.1
description: The [[Prototype]] of Proxy Revocation functions
info: >
17 ECMAScript Standard Built-in Objects:
Unless otherwise specified every built-in function and every built-in
constructor has the Function prototype object, which is the initial
value of the expression Function.prototype (19.2.3), as the value of
its [[Prototype]] internal slot.
---*/
var revocationFunction = Proxy.revocable({}, {}).revoke;
assert.sameValue(Object.getPrototypeOf(revocationFunction), Function.prototype);