diff --git a/test/harness/assert-throws-same-realm.js b/test/harness/assert-throws-same-realm.js index 17f0443112..b21273900e 100644 --- a/test/harness/assert-throws-same-realm.js +++ b/test/harness/assert-throws-same-realm.js @@ -4,7 +4,7 @@ /*--- description: > Functions that throw instances of the realm specified constructor function - satisfy the assertion, without cross realms collisions. + do not satisfy the assertion with cross realms collisions. ---*/ var intrinsicTypeError = TypeError; diff --git a/test/harness/asyncHelpers-asyncTest-func-throws-sync.js b/test/harness/asyncHelpers-asyncTest-func-throws-sync.js index f24b59b1ec..b3bdd7c373 100644 --- a/test/harness/asyncHelpers-asyncTest-func-throws-sync.js +++ b/test/harness/asyncHelpers-asyncTest-func-throws-sync.js @@ -6,11 +6,13 @@ description: | includes: [asyncHelpers.js] ---*/ var called = false; +var msg = "Should not be rethrown"; function $DONE(error) { called = true; assert(error instanceof Test262Error); + assert.sameValue(error.message, msg, "Should report correct error"); } asyncTest(function () { - throw new Test262Error("Should not be rethrown"); + throw new Test262Error(msg); }); assert(called, "asyncTest called $DONE with a synchronously thrown error"); diff --git a/test/harness/asyncHelpers-asyncTest-return-not-thenable.js b/test/harness/asyncHelpers-asyncTest-return-not-thenable.js index 6a47de994e..e7a0a2c0b5 100644 --- a/test/harness/asyncHelpers-asyncTest-return-not-thenable.js +++ b/test/harness/asyncHelpers-asyncTest-return-not-thenable.js @@ -8,6 +8,7 @@ includes: [asyncHelpers.js, compareArray.js] const doneValues = []; function $DONE(error) { + // Will be a TypeError from trying to invoke .then() on non-thenable doneValues.push(error instanceof TypeError); } asyncTest(function () { diff --git a/test/harness/asyncHelpers-asyncTest-returns-undefined.js b/test/harness/asyncHelpers-asyncTest-returns-undefined.js index 78a6ebab76..b318be3823 100644 --- a/test/harness/asyncHelpers-asyncTest-returns-undefined.js +++ b/test/harness/asyncHelpers-asyncTest-returns-undefined.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- description: | - The 'asyncTest' helper when called with async flag always returns to undefined. + The 'asyncTest' helper when called with async flag always returns undefined. flags: [async] includes: [asyncHelpers.js] ---*/ diff --git a/test/harness/asyncHelpers-asyncTest-without-async-flag.js b/test/harness/asyncHelpers-asyncTest-without-async-flag.js index d3eb5a07d1..f620a7d10e 100644 --- a/test/harness/asyncHelpers-asyncTest-without-async-flag.js +++ b/test/harness/asyncHelpers-asyncTest-without-async-flag.js @@ -8,7 +8,8 @@ includes: [asyncHelpers.js] function makePromise() { return { then(res, rej) { - throw new Test262Error("Should not be evaluated"); + // Throw a different error than Test262Error to avoid confusion about what is rejecting + throw new Error("Should not be evaluated"); }, }; } diff --git a/test/harness/asyncHelpers-throwsAsync-custom-typeerror.js b/test/harness/asyncHelpers-throwsAsync-custom-typeerror.js index 0f5cf43354..e048c1d1f2 100644 --- a/test/harness/asyncHelpers-throwsAsync-custom-typeerror.js +++ b/test/harness/asyncHelpers-throwsAsync-custom-typeerror.js @@ -10,7 +10,7 @@ includes: [asyncHelpers.js] var intrinsicTypeError = TypeError; -(async function () { +asyncTest(async function () { function TypeError() {} var caught = false; @@ -69,4 +69,4 @@ var intrinsicTypeError = TypeError; "assert.throwsAsync did not reject a collision of constructor names" ); } -})().then($DONE, $DONE); +}) diff --git a/test/harness/asyncHelpers-throwsAsync-custom.js b/test/harness/asyncHelpers-throwsAsync-custom.js index 70a3f74a38..18c60f68bb 100644 --- a/test/harness/asyncHelpers-throwsAsync-custom.js +++ b/test/harness/asyncHelpers-throwsAsync-custom.js @@ -10,10 +10,10 @@ includes: [asyncHelpers.js] function MyError() {} -(async function () { +asyncTest(async function () { const p = assert.throwsAsync(MyError, function () { return Promise.reject(new MyError()); }); assert(p instanceof Promise); await p; -})().then($DONE, $DONE); +}); diff --git a/test/harness/asyncHelpers-throwsAsync-funcOrThenable-throws-sync.js b/test/harness/asyncHelpers-throwsAsync-func-throws-sync.js similarity index 58% rename from test/harness/asyncHelpers-throwsAsync-funcOrThenable-throws-sync.js rename to test/harness/asyncHelpers-throwsAsync-func-throws-sync.js index accad26ea6..379d6cc546 100644 --- a/test/harness/asyncHelpers-throwsAsync-funcOrThenable-throws-sync.js +++ b/test/harness/asyncHelpers-throwsAsync-func-throws-sync.js @@ -2,14 +2,14 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- description: | - assert.throwsAsync returns a promise that rejects if funcOrThenable or the inner thenable synchronously throws. + assert.throwsAsync returns a promise that rejects if func or the inner thenable synchronously throws. flags: [async] includes: [asyncHelpers.js] ---*/ -async function checkRejects(funcOrThenable) { +async function checkRejects(func) { var caught = false; - const p = assert.throwsAsync(Test262Error, funcOrThenable); + const p = assert.throwsAsync(Test262Error, func); assert(p instanceof Promise, "assert.throwsAsync should return a promise"); try { await p; @@ -18,34 +18,23 @@ async function checkRejects(funcOrThenable) { assert.sameValue( e.constructor, Test262Error, - "throwsAsync should reject improper funcOrThenable with a Test262Error" + "throwsAsync should reject improper function with a Test262Error" ); } finally { assert( caught, - "assert.throwsAsync did not reject improper funcOrThenable " + - funcOrThenable + "assert.throwsAsync did not reject improper function " + func ); } } -(async function () { +asyncTest(async function () { await checkRejects(function () { throw new Error(); }); await checkRejects(function () { throw new Test262Error(); }); - await checkRejects({ - then: function () { - throw new Error(); - }, - }); - await checkRejects({ - then: function () { - throw new Test262Error(); - }, - }); await checkRejects(function () { return { then: function () { @@ -60,4 +49,4 @@ async function checkRejects(funcOrThenable) { }, }; }); -})().then($DONE, $DONE); +}); diff --git a/test/harness/asyncHelpers-throwsAsync-incorrect-ctor.js b/test/harness/asyncHelpers-throwsAsync-incorrect-ctor.js index 62b30b138d..22eee7dfe6 100644 --- a/test/harness/asyncHelpers-throwsAsync-incorrect-ctor.js +++ b/test/harness/asyncHelpers-throwsAsync-incorrect-ctor.js @@ -8,7 +8,7 @@ flags: [async] includes: [asyncHelpers.js] ---*/ -(async function () { +asyncTest(async function () { var caught = false; const p = assert.throwsAsync(Error, function () { @@ -32,4 +32,4 @@ includes: [asyncHelpers.js] "assert.throwsAsync did not reject when a value with incorrect constructor was thrown" ); } -})().then($DONE, $DONE); +}); diff --git a/test/harness/asyncHelpers-throwsAsync-invalid-funcOrThenable.js b/test/harness/asyncHelpers-throwsAsync-invalid-func.js similarity index 65% rename from test/harness/asyncHelpers-throwsAsync-invalid-funcOrThenable.js rename to test/harness/asyncHelpers-throwsAsync-invalid-func.js index 6b5156807c..c7406df012 100644 --- a/test/harness/asyncHelpers-throwsAsync-invalid-funcOrThenable.js +++ b/test/harness/asyncHelpers-throwsAsync-invalid-func.js @@ -2,14 +2,14 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- description: | - assert.throwsAsync returns a promise that rejects if funcOrThenable is not a function returning a thenable or a thenable. + assert.throwsAsync calls $DONE with a rejecting value if func is not a function returning a thenable. flags: [async] includes: [asyncHelpers.js] ---*/ -async function checkRejects(funcOrThenable) { +async function checkRejects(func) { var caught = false; - const p = assert.throwsAsync(Test262Error, funcOrThenable); + const p = assert.throwsAsync(Test262Error, func); assert(p instanceof Promise, "assert.throwsAsync should return a promise"); try { await p; @@ -18,28 +18,27 @@ async function checkRejects(funcOrThenable) { assert.sameValue( e.constructor, Test262Error, - "throwsAsync should reject improper funcOrThenable with a Test262Error" + "throwsAsync should reject improper function with a Test262Error" ); } finally { assert( caught, - "assert.throwsAsync did not reject improper funcOrThenable " + - funcOrThenable + "assert.throwsAsync did not reject improper function " + func ); } } -(async function () { +asyncTest(async function () { await checkRejects(null); await checkRejects({}); await checkRejects("string"); await checkRejects(10); await checkRejects(); - await checkRejects({ then: null }); - await checkRejects({ then: {} }); - await checkRejects({ then: "string" }); - await checkRejects({ then: 10 }); - await checkRejects({ then: undefined }); + await checkRejects({ + then: function (res, rej) { + res(true); + }, + }); await checkRejects(function () { return null; }); @@ -68,4 +67,4 @@ async function checkRejects(funcOrThenable) { await checkRejects(function () { return { then: undefined }; }); -})().then($DONE, $DONE); +}); diff --git a/test/harness/asyncHelpers-throwsAsync-native.js b/test/harness/asyncHelpers-throwsAsync-native.js index 08e416a18c..843bd4ea2a 100644 --- a/test/harness/asyncHelpers-throwsAsync-native.js +++ b/test/harness/asyncHelpers-throwsAsync-native.js @@ -8,7 +8,7 @@ flags: [async] includes: [asyncHelpers.js] ---*/ -(async function () { +asyncTest(async function () { var p = assert.throwsAsync(Error, async function () { throw new Error(); }); @@ -44,4 +44,4 @@ includes: [asyncHelpers.js] }); assert(p instanceof Promise); await p; -})().then($DONE, $DONE); +}); diff --git a/test/harness/asyncHelpers-throwsAsync-no-arg.js b/test/harness/asyncHelpers-throwsAsync-no-arg.js index b51b94345d..378bf962fb 100644 --- a/test/harness/asyncHelpers-throwsAsync-no-arg.js +++ b/test/harness/asyncHelpers-throwsAsync-no-arg.js @@ -7,7 +7,7 @@ flags: [async] includes: [asyncHelpers.js] ---*/ -(async function () { +asyncTest(async function () { var caught = false; const p = assert.throwsAsync(); @@ -29,4 +29,4 @@ includes: [asyncHelpers.js] "assert.throwsAsync did not reject when invoked without arguments" ); } -})().then($DONE, $DONE); +}); diff --git a/test/harness/asyncHelpers-throwsAsync-no-error.js b/test/harness/asyncHelpers-throwsAsync-no-error.js index 97f9f3f3c1..cef530c25a 100644 --- a/test/harness/asyncHelpers-throwsAsync-no-error.js +++ b/test/harness/asyncHelpers-throwsAsync-no-error.js @@ -7,7 +7,7 @@ flags: [async] includes: [asyncHelpers.js] ---*/ -(async function () { +asyncTest(async function () { var caught = false; const p = assert.throwsAsync(Error, async function () {}); @@ -29,4 +29,4 @@ includes: [asyncHelpers.js] "assert.throwsAsync did not reject when the thenable did not reject" ); } -})().then($DONE, $DONE); +}); diff --git a/test/harness/asyncHelpers-throwsAsync-null.js b/test/harness/asyncHelpers-throwsAsync-null.js index 3ab1d36d51..118f80eef1 100644 --- a/test/harness/asyncHelpers-throwsAsync-null.js +++ b/test/harness/asyncHelpers-throwsAsync-null.js @@ -7,7 +7,7 @@ flags: [async] includes: [asyncHelpers.js] ---*/ -(async function () { +asyncTest(async function () { var caught = false; const p = assert.throwsAsync(Error, async function () { @@ -31,4 +31,4 @@ includes: [asyncHelpers.js] "assert.throwsAsync did not reject when null was thrown" ); } -})().then($DONE, $DONE); +}); diff --git a/test/harness/asyncHelpers-throwsAsync-primitive.js b/test/harness/asyncHelpers-throwsAsync-primitive.js index a54004e2fb..fe657d0cc9 100644 --- a/test/harness/asyncHelpers-throwsAsync-primitive.js +++ b/test/harness/asyncHelpers-throwsAsync-primitive.js @@ -7,7 +7,7 @@ flags: [async] includes: [asyncHelpers.js] ---*/ -(async function () { +asyncTest(async function () { var caught = false; const p = assert.throwsAsync(Error, async function () { @@ -31,4 +31,4 @@ includes: [asyncHelpers.js] "assert.throwsAsync did not reject when a primitive was thrown" ); } -})().then($DONE, $DONE); +}); diff --git a/test/harness/asyncHelpers-throwsAsync-resolved-error.js b/test/harness/asyncHelpers-throwsAsync-resolved-error.js index 94d8a3b065..d5ad3e7947 100644 --- a/test/harness/asyncHelpers-throwsAsync-resolved-error.js +++ b/test/harness/asyncHelpers-throwsAsync-resolved-error.js @@ -7,7 +7,7 @@ flags: [async] includes: [asyncHelpers.js] ---*/ -(async function () { +asyncTest(async function () { var caught = false; const p = assert.throwsAsync( @@ -32,4 +32,4 @@ includes: [asyncHelpers.js] "assert.throwsAsync did not reject when the thenable resolved with an error" ); } -})().then($DONE, $DONE); +}); diff --git a/test/harness/asyncHelpers-throwsAsync-same-realm.js b/test/harness/asyncHelpers-throwsAsync-same-realm.js index aa5ce1743e..5e3b2b171a 100644 --- a/test/harness/asyncHelpers-throwsAsync-same-realm.js +++ b/test/harness/asyncHelpers-throwsAsync-same-realm.js @@ -3,12 +3,12 @@ /*--- description: | Thenables that reject with instances of the realm specified constructor function - satisfy the assertion, without cross realms collisions. + do not satisfy the assertion with cross realms collisions. flags: [async] includes: [asyncHelpers.js] ---*/ -(async function () { +asyncTest(async function () { var intrinsicTypeError = TypeError; var caught = false; var realmGlobal = $262.createRealm().global; @@ -34,4 +34,4 @@ includes: [asyncHelpers.js] "assert.throwsAsync did not reject when a different realm's error was thrown" ); } -})().then($DONE, $DONE); +}); diff --git a/test/harness/asyncHelpers-throwsAsync-single-arg.js b/test/harness/asyncHelpers-throwsAsync-single-arg.js index 196558c5a1..472d09085c 100644 --- a/test/harness/asyncHelpers-throwsAsync-single-arg.js +++ b/test/harness/asyncHelpers-throwsAsync-single-arg.js @@ -7,7 +7,7 @@ flags: [async] includes: [asyncHelpers.js] ---*/ -(async function () { +asyncTest(async function () { var caught = false; const p = assert.throwsAsync(function () {}); assert(p instanceof Promise); @@ -28,4 +28,4 @@ includes: [asyncHelpers.js] "assert.throwsAsync did not reject when invoked with a single argumemnt" ); } -})().then($DONE, $DONE); +});