Skip to content
Snippets Groups Projects
Commit 23d56620 authored by Mike Pennisi's avatar Mike Pennisi
Browse files

Make asynchronous test configuration explicit

For asynchronous tests, the contract between test file and test runner
is implicit: runners are expected to inspect the source code for
references to a global `$DONE` identifier.

Promote a more explicit contract between test file and test runner by
introducing a new frontmatter "tag", `async`. This brings asynchronous
test configuration in-line with other configuration mechanisms and also
provides a more natural means of test filtering.

The modifications to test files was made programatically using the
`grep` and `sed` utilities:

    $ grep "\$DONE" test/ -r --files-with-match --null | \
        xargs -0 sed -i 's/^\(flags:\s*\)\[/\1[async, /g'
    $ grep "\$DONE" test/ -rl --null | \
        xargs -0 grep -E '^flags:' --files-without-match --null | \
        xargs -0 sed -i 's/^---\*\//flags: [async]\n---*\//'
parent 5cb97c29
No related branches found
No related tags found
No related merge requests found
Showing
with 22 additions and 3 deletions
...@@ -128,6 +128,8 @@ This tag is for boolean properties associated with the test. ...@@ -128,6 +128,8 @@ This tag is for boolean properties associated with the test.
- **`raw`** - execute the test without any modification (no helpers will be - **`raw`** - execute the test without any modification (no helpers will be
available); necessary to test the behavior of directive prologue; implies available); necessary to test the behavior of directive prologue; implies
`noStrict` `noStrict`
- **`async`** - defer interpretation of test results until after the invocation
of the global $DONE` function
#### features #### features
**features**: [list] **features**: [list]
...@@ -198,7 +200,7 @@ assert.throws(ReferenceError, function() { ...@@ -198,7 +200,7 @@ assert.throws(ReferenceError, function() {
## Writing Asynchronous Tests ## Writing Asynchronous Tests
An asynchronous test is any test that includes the string `$DONE` anywhere in the test file. The test runner checks for the presence of this string; if it is found, the runner expects that the `$DONE()` function will be called to signal test completion. An asynchronous test is any test that include the `async` frontmatter flag. When executing such tests, the runner expects that the global `$DONE()` function will be called to signal test completion.
* If the argument to `$DONE` is omitted, is `undefined`, or is any other falsy value, the test is considered to have passed. * If the argument to `$DONE` is omitted, is `undefined`, or is any other falsy value, the test is considered to have passed.
......
...@@ -7,6 +7,7 @@ info: > ...@@ -7,6 +7,7 @@ info: >
es6id: S25.4.3.1_A2.3_T1 es6id: S25.4.3.1_A2.3_T1
author: Sam Mikes author: Sam Mikes
description: Promise.call(resolved Promise) throws TypeError description: Promise.call(resolved Promise) throws TypeError
flags: [async]
---*/ ---*/
var p = new Promise(function(resolve) { resolve(1); }); var p = new Promise(function(resolve) { resolve(1); });
......
...@@ -7,6 +7,7 @@ info: > ...@@ -7,6 +7,7 @@ info: >
es6id: S25.4.3.1_A2.4_T1 es6id: S25.4.3.1_A2.4_T1
author: Sam Mikes author: Sam Mikes
description: Promise.call(rejected Promise) throws TypeError description: Promise.call(rejected Promise) throws TypeError
flags: [async]
---*/ ---*/
var p = new Promise(function(resolve, reject) { reject(1) }); var p = new Promise(function(resolve, reject) { reject(1) });
......
...@@ -8,6 +8,7 @@ info: > ...@@ -8,6 +8,7 @@ info: >
es6id: S25.4.3.1_A4.1_T1 es6id: S25.4.3.1_A4.1_T1
author: Sam Mikes author: Sam Mikes
description: new Promise(function () { throw }) should reject description: new Promise(function () { throw }) should reject
flags: [async]
---*/ ---*/
var errorObject = {}, var errorObject = {},
......
...@@ -9,7 +9,7 @@ info: > ...@@ -9,7 +9,7 @@ info: >
es6id: S25.4.3.1_A5.1_T1 es6id: S25.4.3.1_A5.1_T1
author: Sam Mikes author: Sam Mikes
description: Promise executor gets default handling for 'this' description: Promise executor gets default handling for 'this'
flags: [noStrict] flags: [async, noStrict]
includes: [fnGlobalObject.js] includes: [fnGlobalObject.js]
---*/ ---*/
......
...@@ -9,7 +9,7 @@ info: > ...@@ -9,7 +9,7 @@ info: >
es6id: S25.4.3.1_A5.1_T2 es6id: S25.4.3.1_A5.1_T2
author: Sam Mikes author: Sam Mikes
description: Promise executor gets default handling for 'this' description: Promise executor gets default handling for 'this'
flags: [onlyStrict] flags: [async, onlyStrict]
---*/ ---*/
var expectedThis = undefined; var expectedThis = undefined;
......
...@@ -7,6 +7,7 @@ es6id: 25.4.4.1_A2.2_T1 ...@@ -7,6 +7,7 @@ es6id: 25.4.4.1_A2.2_T1
author: Sam Mikes author: Sam Mikes
includes: [PromiseHelper.js] includes: [PromiseHelper.js]
description: Promise.all([]) returns immediately description: Promise.all([]) returns immediately
flags: [async]
---*/ ---*/
var sequence = []; var sequence = [];
......
...@@ -6,6 +6,7 @@ info: Promise.all([]) returns a promise for a new empty array ...@@ -6,6 +6,7 @@ info: Promise.all([]) returns a promise for a new empty array
es6id: 25.4.4.1_A2.3_T1 es6id: 25.4.4.1_A2.3_T1
author: Sam Mikes author: Sam Mikes
description: Promise.all([]) returns a promise for an array description: Promise.all([]) returns a promise for an array
flags: [async]
---*/ ---*/
var arg = []; var arg = [];
......
...@@ -6,6 +6,7 @@ info: Promise.all is resolved with a new empty array ...@@ -6,6 +6,7 @@ info: Promise.all is resolved with a new empty array
es6id: 25.4.4.1_A2.3_T2 es6id: 25.4.4.1_A2.3_T2
author: Sam Mikes author: Sam Mikes
description: Promise.all([]) returns a Promise for an empty array description: Promise.all([]) returns a Promise for an empty array
flags: [async]
---*/ ---*/
var arg = []; var arg = [];
......
...@@ -6,6 +6,7 @@ info: Promise.all([]) is resolved with Promise for a new empty array ...@@ -6,6 +6,7 @@ info: Promise.all([]) is resolved with Promise for a new empty array
es6id: 25.4.4.1_A2.3_T3 es6id: 25.4.4.1_A2.3_T3
author: Sam Mikes author: Sam Mikes
description: Promise.all([]) is resolved with a Promise for a new array description: Promise.all([]) is resolved with a Promise for a new array
flags: [async]
---*/ ---*/
var arg = []; var arg = [];
......
...@@ -9,6 +9,7 @@ info: > ...@@ -9,6 +9,7 @@ info: >
es6id: 25.4.4.1_A3.1_T1 es6id: 25.4.4.1_A3.1_T1
author: Sam Mikes author: Sam Mikes
description: Promise.all(3) returns Promise rejected with TypeError description: Promise.all(3) returns Promise rejected with TypeError
flags: [async]
---*/ ---*/
var nonIterable = 3; var nonIterable = 3;
......
...@@ -10,6 +10,7 @@ info: > ...@@ -10,6 +10,7 @@ info: >
es6id: S25.4.4.1_A3.1_T2 es6id: S25.4.4.1_A3.1_T2
author: Sam Mikes author: Sam Mikes
description: Promise.all(new Error()) returns Promise rejected with TypeError description: Promise.all(new Error()) returns Promise rejected with TypeError
flags: [async]
---*/ ---*/
Promise.all(new Error("abrupt")).then(function () { Promise.all(new Error("abrupt")).then(function () {
......
...@@ -9,6 +9,7 @@ es6id: S25.4.4.1_A3.1_T3 ...@@ -9,6 +9,7 @@ es6id: S25.4.4.1_A3.1_T3
author: Sam Mikes author: Sam Mikes
description: Promise.all((throw on GetIterator)) returns Promise rejected with TypeError description: Promise.all((throw on GetIterator)) returns Promise rejected with TypeError
features: [Symbol.iterator] features: [Symbol.iterator]
flags: [async]
---*/ ---*/
var iterThrows = {}; var iterThrows = {};
......
...@@ -9,6 +9,7 @@ es6id: S25.4.4.1_A5.1_T1 ...@@ -9,6 +9,7 @@ es6id: S25.4.4.1_A5.1_T1
author: Sam Mikes author: Sam Mikes
description: iterator.next throws, causing Promise.all to reject description: iterator.next throws, causing Promise.all to reject
features: [Symbol.iterator] features: [Symbol.iterator]
flags: [async]
---*/ ---*/
var iterThrows = {}; var iterThrows = {};
......
...@@ -8,6 +8,7 @@ info: > ...@@ -8,6 +8,7 @@ info: >
es6id: S25.4.4.1_A6.1_T2 es6id: S25.4.4.1_A6.1_T2
author: Sam Mikes author: Sam Mikes
description: Promise.all([]) returns a promise for an empty array description: Promise.all([]) returns a promise for an empty array
flags: [async]
---*/ ---*/
var p = Promise.all([]); var p = Promise.all([]);
......
...@@ -8,6 +8,7 @@ info: > ...@@ -8,6 +8,7 @@ info: >
es6id: S25.4.4.1_A6.1_T2 es6id: S25.4.4.1_A6.1_T2
author: Sam Mikes author: Sam Mikes
description: Promise.all([p1]) is resolved with a promise for a one-element array description: Promise.all([p1]) is resolved with a promise for a one-element array
flags: [async]
---*/ ---*/
var p1 = Promise.resolve(3); var p1 = Promise.resolve(3);
......
...@@ -9,6 +9,7 @@ es6id: S25.4.4.1_A7.2_T1 ...@@ -9,6 +9,7 @@ es6id: S25.4.4.1_A7.2_T1
author: Sam Mikes author: Sam Mikes
description: Promise.all() accepts a one-element array description: Promise.all() accepts a one-element array
includes: [PromiseHelper.js] includes: [PromiseHelper.js]
flags: [async]
---*/ ---*/
var sequence = []; var sequence = [];
......
...@@ -6,6 +6,7 @@ es6id: S25.4.4.1_A8.1_T1 ...@@ -6,6 +6,7 @@ es6id: S25.4.4.1_A8.1_T1
author: Sam Mikes author: Sam Mikes
description: Promise.all([p1, p2]) resolution functions are called in predictable sequence description: Promise.all([p1, p2]) resolution functions are called in predictable sequence
includes: [PromiseHelper.js] includes: [PromiseHelper.js]
flags: [async]
---*/ ---*/
var sequence = []; var sequence = [];
......
...@@ -8,6 +8,7 @@ es6id: S25.4.4.1_A8.1_T1 ...@@ -8,6 +8,7 @@ es6id: S25.4.4.1_A8.1_T1
author: Sam Mikes author: Sam Mikes
description: Promise.all() rejects when a promise in its array rejects description: Promise.all() rejects when a promise in its array rejects
includes: [PromiseHelper.js] includes: [PromiseHelper.js]
flags: [async]
---*/ ---*/
var rejectP1, var rejectP1,
......
...@@ -8,6 +8,7 @@ es6id: S25.4.4.1_A8.2_T2 ...@@ -8,6 +8,7 @@ es6id: S25.4.4.1_A8.2_T2
author: Sam Mikes author: Sam Mikes
description: Promise.all() rejects when second promise in array rejects description: Promise.all() rejects when second promise in array rejects
includes: [PromiseHelper.js] includes: [PromiseHelper.js]
flags: [async]
---*/ ---*/
var rejectP2, var rejectP2,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment