From d8c20b423bdf35c57f6df45a519362fcb77d6874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Mon, 22 Jul 2019 02:12:24 -0700 Subject: [PATCH] Call $DONE function exactly once per test Also make a note in CONTRIBUTING.md that `$DONE` shouldn't be called multiple times. --- CONTRIBUTING.md | 2 +- test/built-ins/Promise/allSettled/reject-deferred.js | 1 - test/built-ins/Promise/allSettled/reject-ignored-deferred.js | 1 - test/built-ins/Promise/allSettled/reject-ignored-immed.js | 1 - test/built-ins/Promise/allSettled/reject-immed.js | 3 +-- 5 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 572041a885..cc016a3129 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -298,7 +298,7 @@ Consumers that violate the spec by throwing exceptions for parsing errors at run ## Writing Asynchronous Tests -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. +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 **exactly once** 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. diff --git a/test/built-ins/Promise/allSettled/reject-deferred.js b/test/built-ins/Promise/allSettled/reject-deferred.js index 6b26b91e90..9b681a94d0 100644 --- a/test/built-ins/Promise/allSettled/reject-deferred.js +++ b/test/built-ins/Promise/allSettled/reject-deferred.js @@ -43,5 +43,4 @@ Promise.allSettled([thenable]) assert.sameValue(settleds.length, 1); assert.sameValue(settleds[0].status, 'rejected'); assert.sameValue(settleds[0].reason, simulation); - $DONE(); }).then($DONE, $DONE); diff --git a/test/built-ins/Promise/allSettled/reject-ignored-deferred.js b/test/built-ins/Promise/allSettled/reject-ignored-deferred.js index 72ed7dbf83..4f7fb24de4 100644 --- a/test/built-ins/Promise/allSettled/reject-ignored-deferred.js +++ b/test/built-ins/Promise/allSettled/reject-ignored-deferred.js @@ -49,5 +49,4 @@ Promise.allSettled([fulfiller, rejector]) assert.sameValue(settleds[0].value, 42); assert.sameValue(settleds[1].status, 'fulfilled'); assert.sameValue(settleds[1].value, simulation); - $DONE(); }).then($DONE, $DONE); diff --git a/test/built-ins/Promise/allSettled/reject-ignored-immed.js b/test/built-ins/Promise/allSettled/reject-ignored-immed.js index a060e69a94..add9fd31ff 100644 --- a/test/built-ins/Promise/allSettled/reject-ignored-immed.js +++ b/test/built-ins/Promise/allSettled/reject-ignored-immed.js @@ -40,5 +40,4 @@ Promise.allSettled([fulfiller, lateRejector]) assert.sameValue(settleds[0].value, 42); assert.sameValue(settleds[1].status, 'fulfilled'); assert.sameValue(settleds[1].value, simulation); - $DONE(); }).then($DONE, $DONE); diff --git a/test/built-ins/Promise/allSettled/reject-immed.js b/test/built-ins/Promise/allSettled/reject-immed.js index 2629aefaaf..ae2e93c916 100644 --- a/test/built-ins/Promise/allSettled/reject-immed.js +++ b/test/built-ins/Promise/allSettled/reject-immed.js @@ -27,5 +27,4 @@ var thenable = { Promise.allSettled([thenable]) .then((settleds) => { checkSettledPromises(settleds, [{ status: 'rejected', reason: simulation }]); - $DONE(); - }).then($DONE, $DONE); \ No newline at end of file + }).then($DONE, $DONE);