Formalize tests for built-in Promise methods

Uniformly and exhaustively test the generic aspects of the static- and
instance Promise methods, including:

- function `length` properties
- function `name` properties
- method property descriptors
This commit is contained in:
Mike Pennisi 2015-06-22 17:25:29 -04:00
parent a3081bd108
commit 4e2f350875
30 changed files with 467 additions and 92 deletions

View File

@ -1,14 +0,0 @@
// Copyright 2014 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: Promise.all expects 1 argument
es6id: 25.4.4.1_A1.2_T1
author: Sam Mikes
description: Promise.all expects 1 argument
---*/
// CHECK#1
if (Promise.all.length !== 1) {
$ERROR('Expected Promise.all to be a function of one argument.');
}

View File

@ -1,14 +0,0 @@
// Copyright 2015 Jordan Harband. All rights reserved.
// See LICENSE for details.
/*---
info: Promise.all is not enumerable
es6id: 25.4.4.1_A1.3_T1
author: Jordan Harband
description: Promise.all should be non-enumerable
includes:
- propertyHelper.js
---*/
// CHECK#1
verifyNotEnumerable(Promise, 'all');

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: 25.4.4.1
description: Promise.all `length` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this value
is equal to the largest number of named arguments shown in the subclause
headings for the function description, including optional parameters.
[...]
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.all.length, 1);
verifyNotEnumerable(Promise.all, 'length');
verifyNotWritable(Promise.all, 'length');
verifyConfigurable(Promise.all, 'length');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.4.1
description: Promise.all `name` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value is a
String. Unless otherwise specified, this value is the name that is given to
the function in this specification.
[...]
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.all.name, 'all');
verifyNotEnumerable(Promise.all, 'name');
verifyNotWritable(Promise.all, 'name');
verifyConfigurable(Promise.all, 'name');

View File

@ -0,0 +1,19 @@
// Copyright 2015 Jordan Harband. All rights reserved.
// See LICENSE for details.
/*---
es6id: 25.4.4.1_A1.3_T1
author: Jordan Harband
description: Promise.all property descriptor
info: >
ES6 Section 17
Every other data property described in clauses 18 through 26 and in Annex
B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
---*/
verifyNotEnumerable(Promise, 'all');
verifyWritable(Promise, 'all');
verifyConfigurable(Promise, 'all');

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: 25.4.3.1
description: Promise `length` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this value
is equal to the largest number of named arguments shown in the subclause
headings for the function description, including optional parameters.
[...]
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.length, 1);
verifyNotEnumerable(Promise, 'length');
verifyNotWritable(Promise, 'length');
verifyConfigurable(Promise, 'length');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.3.1
description: Promise `name` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value is a
String. Unless otherwise specified, this value is the name that is given to
the function in this specification.
[...]
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.name, 'Promise');
verifyNotEnumerable(Promise, 'name');
verifyNotWritable(Promise, 'name');
verifyConfigurable(Promise, 'name');

View File

@ -14,9 +14,3 @@ var p = Promise.resolve(3);
if (!(p.catch instanceof Function)) {
$ERROR("Expected p.catch to be a function");
}
if (p.catch.length !== 1) {
$ERROR("Expected p.catch to take one argument");
}

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: 25.4.5.1
description: Promise.prototype.catch `length` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this value
is equal to the largest number of named arguments shown in the subclause
headings for the function description, including optional parameters.
[...]
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.prototype.catch.length, 1);
verifyNotEnumerable(Promise.prototype.catch, 'length');
verifyNotWritable(Promise.prototype.catch, 'length');
verifyConfigurable(Promise.prototype.catch, 'length');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.5.1
description: Promise.prototype.catch `name` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value is a
String. Unless otherwise specified, this value is the name that is given to
the function in this specification.
[...]
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.prototype.catch.name, 'catch');
verifyNotEnumerable(Promise.prototype.catch, 'name');
verifyNotWritable(Promise.prototype.catch, 'name');
verifyConfigurable(Promise.prototype.catch, 'name');

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: 25.4.5.1
description: Promise.prototype.catch property descriptor
info: >
Every other data property described in clauses 18 through 26 and in Annex
B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
---*/
assert.sameValue(typeof Promise.prototype.catch, 'function');
verifyNotEnumerable(Promise.prototype, 'catch');
verifyWritable(Promise.prototype, 'catch');
verifyConfigurable(Promise.prototype, 'catch');

View File

@ -12,7 +12,3 @@ description: Promise.prototype.then is a function of two arguments
if (!(Promise.prototype.then instanceof Function)) {
$ERROR("Expected Promise.prototype.then to be a function");
}
if (Promise.prototype.then.length !== 2) {
$ERROR("Expected Promise.prototype.then to be a function of two arguments");
}

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: 25.4.5.3
description: Promise.prototype.then `length` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this value
is equal to the largest number of named arguments shown in the subclause
headings for the function description, including optional parameters.
[...]
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.prototype.then.length, 2);
verifyNotEnumerable(Promise.prototype.then, 'length');
verifyNotWritable(Promise.prototype.then, 'length');
verifyConfigurable(Promise.prototype.then, 'length');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.5.3
description: Promise.prototype.then `name` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value is a
String. Unless otherwise specified, this value is the name that is given to
the function in this specification.
[...]
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.prototype.then.name, 'then');
verifyNotEnumerable(Promise.prototype.then, 'name');
verifyNotWritable(Promise.prototype.then, 'name');
verifyConfigurable(Promise.prototype.then, 'name');

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: 25.4.5.1
description: Promise.prototype.then property descriptor
info: >
Every other data property described in clauses 18 through 26 and in Annex
B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
---*/
assert.sameValue(typeof Promise.prototype.then, 'function');
verifyNotEnumerable(Promise.prototype, 'then');
verifyWritable(Promise.prototype, 'then');
verifyConfigurable(Promise.prototype, 'then');

View File

@ -11,7 +11,3 @@ description: Promise.race is callable
if (typeof Promise.race !== "function") {
$ERROR("Expected Promise.race to be a function, actually " + typeof Promise.race);
}
if (Promise.race.length !== 1) {
$ERROR("Expected Promise.race to be a function of 1 argument.");
}

View File

@ -1,14 +0,0 @@
// Copyright 2015 Jordan Harband. All rights reserved.
// See LICENSE for details.
/*---
info: Promise.race is not enumerable
es6id: 25.4.4.3_A1.2_T1
author: Jordan Harband
description: Promise.race should be non-enumerable
includes:
- propertyHelper.js
---*/
// CHECK#1
verifyNotEnumerable(Promise, 'race');

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: 25.4.4.3
description: Promise.race `length` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this value
is equal to the largest number of named arguments shown in the subclause
headings for the function description, including optional parameters.
[...]
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.race.length, 1);
verifyNotEnumerable(Promise.race, 'length');
verifyNotWritable(Promise.race, 'length');
verifyConfigurable(Promise.race, 'length');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.4.3
description: Promise.race `name` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value is a
String. Unless otherwise specified, this value is the name that is given to
the function in this specification.
[...]
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.race.name, 'race');
verifyNotEnumerable(Promise.race, 'name');
verifyNotWritable(Promise.race, 'name');
verifyConfigurable(Promise.race, 'name');

View File

@ -0,0 +1,19 @@
// Copyright 2015 Jordan Harband. All rights reserved.
// See LICENSE for details.
/*---
es6id: 25.4.4.3_A1.2_T1
author: Jordan Harband
description: Promise.race property descriptor
info: >
ES6 Section 17
Every other data property described in clauses 18 through 26 and in Annex
B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
---*/
verifyNotEnumerable(Promise, 'race');
verifyWritable(Promise, 'race');
verifyConfigurable(Promise, 'race');

View File

@ -12,7 +12,3 @@ description: Promise.reject is a function
if ((typeof Promise.reject) !== "function") {
$ERROR("Expected Promise.reject to be a function");
}
if (Promise.reject.length !== 1) {
$ERROR("Expected Promise.reject to be a function of one argument");
}

View File

@ -1,14 +0,0 @@
// Copyright 2015 Jordan Harband. All rights reserved.
// See LICENSE for details.
/*---
info: Promise.reject is not enumerable
es6id: 25.4.4.4_A1.2_T1
author: Jordan Harband
description: Promise.reject should be non-enumerable
includes:
- propertyHelper.js
---*/
// CHECK#1
verifyNotEnumerable(Promise, 'reject');

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: 25.4.4.4
description: Promise.reject `length` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this value
is equal to the largest number of named arguments shown in the subclause
headings for the function description, including optional parameters.
[...]
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.reject.length, 1);
verifyNotEnumerable(Promise.reject, 'length');
verifyNotWritable(Promise.reject, 'length');
verifyConfigurable(Promise.reject, 'length');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.4.4
description: Promise.reject `name` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value is a
String. Unless otherwise specified, this value is the name that is given to
the function in this specification.
[...]
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.reject.name, 'reject');
verifyNotEnumerable(Promise.reject, 'name');
verifyNotWritable(Promise.reject, 'name');
verifyConfigurable(Promise.reject, 'name');

View File

@ -0,0 +1,19 @@
// Copyright 2015 Jordan Harband. All rights reserved.
// See LICENSE for details.
/*---
es6id: 25.4.4.4_A1.2_T1
author: Jordan Harband
description: Promise.reject property descriptor
info: >
ES6 Section 17
Every other data property described in clauses 18 through 26 and in Annex
B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
---*/
verifyNotEnumerable(Promise, 'reject');
verifyWritable(Promise, 'reject');
verifyConfigurable(Promise, 'reject');

View File

@ -12,7 +12,3 @@ description: Promise.resolve is a function
if ((typeof Promise.resolve) !== "function") {
$ERROR("Expected Promise.resolve to be a function");
}
if (Promise.resolve.length !== 1) {
$ERROR("Expected Promise.resolve to be a function of one argument");
}

View File

@ -1,14 +0,0 @@
// Copyright 2015 Jordan Harband. All rights reserved.
// See LICENSE for details.
/*---
info: Promise.resolve is not enumerable
es6id: 25.4.4.5_A1.2_T1
author: Jordan Harband
description: Promise.resolve should be non-enumerable
includes:
- propertyHelper.js
---*/
// CHECK#1
verifyNotEnumerable(Promise, 'resolve');

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: 25.4.4.5
description: Promise.resolve `length` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this value
is equal to the largest number of named arguments shown in the subclause
headings for the function description, including optional parameters.
[...]
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.resolve.length, 1);
verifyNotEnumerable(Promise.resolve, 'length');
verifyNotWritable(Promise.resolve, 'length');
verifyConfigurable(Promise.resolve, 'length');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.4.5
description: Promise.resolve `name` property
info: >
ES6 Section 17:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value is a
String. Unless otherwise specified, this value is the name that is given to
the function in this specification.
[...]
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Promise.resolve.name, 'resolve');
verifyNotEnumerable(Promise.resolve, 'name');
verifyNotWritable(Promise.resolve, 'name');
verifyConfigurable(Promise.resolve, 'name');

View File

@ -0,0 +1,19 @@
// Copyright 2015 Jordan Harband. All rights reserved.
// See LICENSE for details.
/*---
es6id: 25.4.4.5_A1.2_T1
author: Jordan Harband
description: Promise.resolve should be non-enumerable
info: >
ES6 Section 17
Every other data property described in clauses 18 through 26 and in Annex
B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
---*/
verifyNotEnumerable(Promise, 'resolve');
verifyWritable(Promise, 'resolve');
verifyConfigurable(Promise, 'resolve');