From 03f0f5696154fb0d477b445e9dbd755e93895cf0 Mon Sep 17 00:00:00 2001 From: Rick Waldron <waldron.rick@gmail.com> Date: Mon, 19 Mar 2018 14:01:36 -0400 Subject: [PATCH] Promise.all/race with non-iterable or invalid return from Symbol.iterator. (#1496) Fixes gh-1490 --- .../Promise/all/iter-arg-is-false-reject.js | 33 +++++++++++++++++ .../Promise/all/iter-arg-is-null-reject.js | 33 +++++++++++++++++ .../Promise/all/iter-arg-is-number-reject.js | 33 +++++++++++++++++ .../Promise/all/iter-arg-is-string-resolve.js | 33 +++++++++++++++++ .../Promise/all/iter-arg-is-symbol-reject.js | 33 +++++++++++++++++ .../Promise/all/iter-arg-is-true-reject.js | 33 +++++++++++++++++ .../all/iter-arg-is-undefined-reject.js | 33 +++++++++++++++++ .../Promise/all/iter-assigned-false-reject.js | 35 ++++++++++++++++++ .../Promise/all/iter-assigned-null-reject.js | 35 ++++++++++++++++++ .../all/iter-assigned-number-reject.js | 35 ++++++++++++++++++ .../all/iter-assigned-string-reject.js | 35 ++++++++++++++++++ .../all/iter-assigned-symbol-reject.js | 35 ++++++++++++++++++ .../Promise/all/iter-assigned-true-reject.js | 35 ++++++++++++++++++ .../all/iter-assigned-undefined-reject.js | 35 ++++++++++++++++++ .../Promise/all/iter-next-val-err-reject.js | 2 +- .../Promise/all/iter-returns-false-reject.js | 37 +++++++++++++++++++ .../Promise/all/iter-returns-null-reject.js | 37 +++++++++++++++++++ .../Promise/all/iter-returns-number-reject.js | 37 +++++++++++++++++++ .../Promise/all/iter-returns-string-reject.js | 37 +++++++++++++++++++ .../Promise/all/iter-returns-symbol-reject.js | 37 +++++++++++++++++++ .../Promise/all/iter-returns-true-reject.js | 37 +++++++++++++++++++ .../all/iter-returns-undefined-reject.js | 37 +++++++++++++++++++ .../Promise/all/iter-step-err-no-close.js | 2 +- .../Promise/all/iter-step-err-reject.js | 4 +- .../Promise/race/iter-arg-is-false-reject.js | 33 +++++++++++++++++ .../Promise/race/iter-arg-is-null-reject.js | 33 +++++++++++++++++ .../Promise/race/iter-arg-is-number-reject.js | 33 +++++++++++++++++ .../race/iter-arg-is-string-resolve.js | 33 +++++++++++++++++ .../Promise/race/iter-arg-is-symbol-reject.js | 33 +++++++++++++++++ .../Promise/race/iter-arg-is-true-reject.js | 33 +++++++++++++++++ .../race/iter-arg-is-undefined-reject.js | 33 +++++++++++++++++ .../race/iter-assigned-false-reject.js | 35 ++++++++++++++++++ .../Promise/race/iter-assigned-null-reject.js | 35 ++++++++++++++++++ .../race/iter-assigned-number-reject.js | 35 ++++++++++++++++++ .../race/iter-assigned-string-reject.js | 35 ++++++++++++++++++ .../race/iter-assigned-symbol-reject.js | 35 ++++++++++++++++++ .../Promise/race/iter-assigned-true-reject.js | 35 ++++++++++++++++++ .../race/iter-assigned-undefined-reject.js | 35 ++++++++++++++++++ .../Promise/race/iter-next-val-err-reject.js | 2 +- .../Promise/race/iter-returns-false-reject.js | 37 +++++++++++++++++++ .../Promise/race/iter-returns-null-reject.js | 37 +++++++++++++++++++ .../race/iter-returns-number-reject.js | 37 +++++++++++++++++++ .../race/iter-returns-string-reject.js | 37 +++++++++++++++++++ .../race/iter-returns-symbol-reject.js | 37 +++++++++++++++++++ .../Promise/race/iter-returns-true-reject.js | 37 +++++++++++++++++++ .../race/iter-returns-undefined-reject.js | 37 +++++++++++++++++++ .../Promise/race/iter-step-err-reject.js | 2 +- 47 files changed, 1476 insertions(+), 6 deletions(-) create mode 100644 test/built-ins/Promise/all/iter-arg-is-false-reject.js create mode 100644 test/built-ins/Promise/all/iter-arg-is-null-reject.js create mode 100644 test/built-ins/Promise/all/iter-arg-is-number-reject.js create mode 100644 test/built-ins/Promise/all/iter-arg-is-string-resolve.js create mode 100644 test/built-ins/Promise/all/iter-arg-is-symbol-reject.js create mode 100644 test/built-ins/Promise/all/iter-arg-is-true-reject.js create mode 100644 test/built-ins/Promise/all/iter-arg-is-undefined-reject.js create mode 100644 test/built-ins/Promise/all/iter-assigned-false-reject.js create mode 100644 test/built-ins/Promise/all/iter-assigned-null-reject.js create mode 100644 test/built-ins/Promise/all/iter-assigned-number-reject.js create mode 100644 test/built-ins/Promise/all/iter-assigned-string-reject.js create mode 100644 test/built-ins/Promise/all/iter-assigned-symbol-reject.js create mode 100644 test/built-ins/Promise/all/iter-assigned-true-reject.js create mode 100644 test/built-ins/Promise/all/iter-assigned-undefined-reject.js create mode 100644 test/built-ins/Promise/all/iter-returns-false-reject.js create mode 100644 test/built-ins/Promise/all/iter-returns-null-reject.js create mode 100644 test/built-ins/Promise/all/iter-returns-number-reject.js create mode 100644 test/built-ins/Promise/all/iter-returns-string-reject.js create mode 100644 test/built-ins/Promise/all/iter-returns-symbol-reject.js create mode 100644 test/built-ins/Promise/all/iter-returns-true-reject.js create mode 100644 test/built-ins/Promise/all/iter-returns-undefined-reject.js create mode 100644 test/built-ins/Promise/race/iter-arg-is-false-reject.js create mode 100644 test/built-ins/Promise/race/iter-arg-is-null-reject.js create mode 100644 test/built-ins/Promise/race/iter-arg-is-number-reject.js create mode 100644 test/built-ins/Promise/race/iter-arg-is-string-resolve.js create mode 100644 test/built-ins/Promise/race/iter-arg-is-symbol-reject.js create mode 100644 test/built-ins/Promise/race/iter-arg-is-true-reject.js create mode 100644 test/built-ins/Promise/race/iter-arg-is-undefined-reject.js create mode 100644 test/built-ins/Promise/race/iter-assigned-false-reject.js create mode 100644 test/built-ins/Promise/race/iter-assigned-null-reject.js create mode 100644 test/built-ins/Promise/race/iter-assigned-number-reject.js create mode 100644 test/built-ins/Promise/race/iter-assigned-string-reject.js create mode 100644 test/built-ins/Promise/race/iter-assigned-symbol-reject.js create mode 100644 test/built-ins/Promise/race/iter-assigned-true-reject.js create mode 100644 test/built-ins/Promise/race/iter-assigned-undefined-reject.js create mode 100644 test/built-ins/Promise/race/iter-returns-false-reject.js create mode 100644 test/built-ins/Promise/race/iter-returns-null-reject.js create mode 100644 test/built-ins/Promise/race/iter-returns-number-reject.js create mode 100644 test/built-ins/Promise/race/iter-returns-string-reject.js create mode 100644 test/built-ins/Promise/race/iter-returns-symbol-reject.js create mode 100644 test/built-ins/Promise/race/iter-returns-true-reject.js create mode 100644 test/built-ins/Promise/race/iter-returns-undefined-reject.js diff --git a/test/built-ins/Promise/all/iter-arg-is-false-reject.js b/test/built-ins/Promise/all/iter-arg-is-false-reject.js new file mode 100644 index 0000000000..4be22b6406 --- /dev/null +++ b/test/built-ins/Promise/all/iter-arg-is-false-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument is `false` +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all(false).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-arg-is-null-reject.js b/test/built-ins/Promise/all/iter-arg-is-null-reject.js new file mode 100644 index 0000000000..c371a52c84 --- /dev/null +++ b/test/built-ins/Promise/all/iter-arg-is-null-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument is `null` +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all(null).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-arg-is-number-reject.js b/test/built-ins/Promise/all/iter-arg-is-number-reject.js new file mode 100644 index 0000000000..3091a5b423 --- /dev/null +++ b/test/built-ins/Promise/all/iter-arg-is-number-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument is a number +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all(1).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-arg-is-string-resolve.js b/test/built-ins/Promise/all/iter-arg-is-string-resolve.js new file mode 100644 index 0000000000..46bb6dde6a --- /dev/null +++ b/test/built-ins/Promise/all/iter-arg-is-string-resolve.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument is a string +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all("").then(function() { + $DONE(); + }, function() { + $DONE('The promise should be resolved, but was rejected'); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-arg-is-symbol-reject.js b/test/built-ins/Promise/all/iter-arg-is-symbol-reject.js new file mode 100644 index 0000000000..21904dc40b --- /dev/null +++ b/test/built-ins/Promise/all/iter-arg-is-symbol-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument is a symbol +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all(Symbol()).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-arg-is-true-reject.js b/test/built-ins/Promise/all/iter-arg-is-true-reject.js new file mode 100644 index 0000000000..a650a16213 --- /dev/null +++ b/test/built-ins/Promise/all/iter-arg-is-true-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument is `true` +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all(true).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-arg-is-undefined-reject.js b/test/built-ins/Promise/all/iter-arg-is-undefined-reject.js new file mode 100644 index 0000000000..4a504aff5e --- /dev/null +++ b/test/built-ins/Promise/all/iter-arg-is-undefined-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument is `undefined` +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all(undefined).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-assigned-false-reject.js b/test/built-ins/Promise/all/iter-assigned-false-reject.js new file mode 100644 index 0000000000..ea923ae77b --- /dev/null +++ b/test/built-ins/Promise/all/iter-assigned-false-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator property has the value false +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]: false + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-assigned-null-reject.js b/test/built-ins/Promise/all/iter-assigned-null-reject.js new file mode 100644 index 0000000000..a6e1a72009 --- /dev/null +++ b/test/built-ins/Promise/all/iter-assigned-null-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator property has the value null +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]: null + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-assigned-number-reject.js b/test/built-ins/Promise/all/iter-assigned-number-reject.js new file mode 100644 index 0000000000..4fbd7ee57f --- /dev/null +++ b/test/built-ins/Promise/all/iter-assigned-number-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator property has the value 1 +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]: 1 + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-assigned-string-reject.js b/test/built-ins/Promise/all/iter-assigned-string-reject.js new file mode 100644 index 0000000000..c640870a0a --- /dev/null +++ b/test/built-ins/Promise/all/iter-assigned-string-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator property has the value "" +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]: "" + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-assigned-symbol-reject.js b/test/built-ins/Promise/all/iter-assigned-symbol-reject.js new file mode 100644 index 0000000000..bb27314c27 --- /dev/null +++ b/test/built-ins/Promise/all/iter-assigned-symbol-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator property has the value Symbol() +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]: Symbol() + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-assigned-true-reject.js b/test/built-ins/Promise/all/iter-assigned-true-reject.js new file mode 100644 index 0000000000..c26923e109 --- /dev/null +++ b/test/built-ins/Promise/all/iter-assigned-true-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator property has the value true +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]: true + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-assigned-undefined-reject.js b/test/built-ins/Promise/all/iter-assigned-undefined-reject.js new file mode 100644 index 0000000000..ec71ce3053 --- /dev/null +++ b/test/built-ins/Promise/all/iter-assigned-undefined-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator property has the value undefined +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]: undefined + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-next-val-err-reject.js b/test/built-ins/Promise/all/iter-next-val-err-reject.js index 811b19923b..49e1072ab0 100644 --- a/test/built-ins/Promise/all/iter-next-val-err-reject.js +++ b/test/built-ins/Promise/all/iter-next-val-err-reject.js @@ -48,7 +48,7 @@ iterNextValThrows[Symbol.iterator] = function() { }; Promise.all(iterNextValThrows).then(function() { - $ERROR('The promise should be rejected.'); + $DONE('The promise should be rejected.'); }, function(reason) { assert.sameValue(reason, error); }).then($DONE, $DONE); diff --git a/test/built-ins/Promise/all/iter-returns-false-reject.js b/test/built-ins/Promise/all/iter-returns-false-reject.js new file mode 100644 index 0000000000..be85e1878d --- /dev/null +++ b/test/built-ins/Promise/all/iter-returns-false-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator returns false +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]() { + return false; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-returns-null-reject.js b/test/built-ins/Promise/all/iter-returns-null-reject.js new file mode 100644 index 0000000000..bbfefe3326 --- /dev/null +++ b/test/built-ins/Promise/all/iter-returns-null-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator returns null +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]() { + return null; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-returns-number-reject.js b/test/built-ins/Promise/all/iter-returns-number-reject.js new file mode 100644 index 0000000000..a880607a03 --- /dev/null +++ b/test/built-ins/Promise/all/iter-returns-number-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator returns a number +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]() { + return 1; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-returns-string-reject.js b/test/built-ins/Promise/all/iter-returns-string-reject.js new file mode 100644 index 0000000000..a65c452781 --- /dev/null +++ b/test/built-ins/Promise/all/iter-returns-string-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator returns a string +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]() { + return ""; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-returns-symbol-reject.js b/test/built-ins/Promise/all/iter-returns-symbol-reject.js new file mode 100644 index 0000000000..532b64b25c --- /dev/null +++ b/test/built-ins/Promise/all/iter-returns-symbol-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator returns a symbol +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]() { + return Symbol(); + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-returns-true-reject.js b/test/built-ins/Promise/all/iter-returns-true-reject.js new file mode 100644 index 0000000000..f0c1c6ac9b --- /dev/null +++ b/test/built-ins/Promise/all/iter-returns-true-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator returns true +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]() { + return true; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-returns-undefined-reject.js b/test/built-ins/Promise/all/iter-returns-undefined-reject.js new file mode 100644 index 0000000000..786402389b --- /dev/null +++ b/test/built-ins/Promise/all/iter-returns-undefined-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.all +description: > + Reject when argument's Symbol.iterator returns undefined +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.all({ + [Symbol.iterator]() { + return undefined; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/all/iter-step-err-no-close.js b/test/built-ins/Promise/all/iter-step-err-no-close.js index e288093ac1..4e9e04b339 100644 --- a/test/built-ins/Promise/all/iter-step-err-no-close.js +++ b/test/built-ins/Promise/all/iter-step-err-no-close.js @@ -37,7 +37,7 @@ Object.defineProperty(poisonedDone, 'done', { }); Object.defineProperty(poisonedDone, 'value', { get: function() { - $ERROR('The `value` property should not be accessed.'); + $DONE('The `value` property should not be accessed.'); } }); diff --git a/test/built-ins/Promise/all/iter-step-err-reject.js b/test/built-ins/Promise/all/iter-step-err-reject.js index a100ef0bbb..4396343bf4 100644 --- a/test/built-ins/Promise/all/iter-step-err-reject.js +++ b/test/built-ins/Promise/all/iter-step-err-reject.js @@ -37,7 +37,7 @@ Object.defineProperty(poisonedDone, 'done', { }); Object.defineProperty(poisonedDone, 'value', { get: function() { - $ERROR('The `value` property should not be accessed.'); + $DONE('The `value` property should not be accessed.'); } }); @@ -50,7 +50,7 @@ iterStepThrows[Symbol.iterator] = function() { }; Promise.all(iterStepThrows).then(function() { - $ERROR('The promise should be rejected.'); + $DONE('The promise should be rejected.'); }, function(reason) { assert.sameValue(reason, error); }).then($DONE, $DONE); diff --git a/test/built-ins/Promise/race/iter-arg-is-false-reject.js b/test/built-ins/Promise/race/iter-arg-is-false-reject.js new file mode 100644 index 0000000000..2d4576ea1e --- /dev/null +++ b/test/built-ins/Promise/race/iter-arg-is-false-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument is `false` +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race(false).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-arg-is-null-reject.js b/test/built-ins/Promise/race/iter-arg-is-null-reject.js new file mode 100644 index 0000000000..30f53d111e --- /dev/null +++ b/test/built-ins/Promise/race/iter-arg-is-null-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument is `null` +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race(null).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-arg-is-number-reject.js b/test/built-ins/Promise/race/iter-arg-is-number-reject.js new file mode 100644 index 0000000000..902764ba8c --- /dev/null +++ b/test/built-ins/Promise/race/iter-arg-is-number-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument is a number +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race(1).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-arg-is-string-resolve.js b/test/built-ins/Promise/race/iter-arg-is-string-resolve.js new file mode 100644 index 0000000000..02490594ef --- /dev/null +++ b/test/built-ins/Promise/race/iter-arg-is-string-resolve.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument is a string +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race("").then(function() { + $DONE(); + }, function() { + $DONE('The promise should be resolved, but was rejected'); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-arg-is-symbol-reject.js b/test/built-ins/Promise/race/iter-arg-is-symbol-reject.js new file mode 100644 index 0000000000..1e204c471d --- /dev/null +++ b/test/built-ins/Promise/race/iter-arg-is-symbol-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument is a symbol +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race(Symbol()).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-arg-is-true-reject.js b/test/built-ins/Promise/race/iter-arg-is-true-reject.js new file mode 100644 index 0000000000..2b173aba80 --- /dev/null +++ b/test/built-ins/Promise/race/iter-arg-is-true-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument is `true` +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race(true).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-arg-is-undefined-reject.js b/test/built-ins/Promise/race/iter-arg-is-undefined-reject.js new file mode 100644 index 0000000000..b8a63f86a3 --- /dev/null +++ b/test/built-ins/Promise/race/iter-arg-is-undefined-reject.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument is `undefined` +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race(undefined).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-assigned-false-reject.js b/test/built-ins/Promise/race/iter-assigned-false-reject.js new file mode 100644 index 0000000000..13e508fbe2 --- /dev/null +++ b/test/built-ins/Promise/race/iter-assigned-false-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator property has the value false +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]: false + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-assigned-null-reject.js b/test/built-ins/Promise/race/iter-assigned-null-reject.js new file mode 100644 index 0000000000..ad701aac90 --- /dev/null +++ b/test/built-ins/Promise/race/iter-assigned-null-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator property has the value null +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]: null + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-assigned-number-reject.js b/test/built-ins/Promise/race/iter-assigned-number-reject.js new file mode 100644 index 0000000000..d91bed7a51 --- /dev/null +++ b/test/built-ins/Promise/race/iter-assigned-number-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator property has the value 1 +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]: 1 + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-assigned-string-reject.js b/test/built-ins/Promise/race/iter-assigned-string-reject.js new file mode 100644 index 0000000000..463e281b9b --- /dev/null +++ b/test/built-ins/Promise/race/iter-assigned-string-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator property has the value "" +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]: "" + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-assigned-symbol-reject.js b/test/built-ins/Promise/race/iter-assigned-symbol-reject.js new file mode 100644 index 0000000000..81ecb81804 --- /dev/null +++ b/test/built-ins/Promise/race/iter-assigned-symbol-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator property has the value Symbol() +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]: Symbol() + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-assigned-true-reject.js b/test/built-ins/Promise/race/iter-assigned-true-reject.js new file mode 100644 index 0000000000..1bdaeee317 --- /dev/null +++ b/test/built-ins/Promise/race/iter-assigned-true-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator property has the value true +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]: true + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-assigned-undefined-reject.js b/test/built-ins/Promise/race/iter-assigned-undefined-reject.js new file mode 100644 index 0000000000..b7002aa88b --- /dev/null +++ b/test/built-ins/Promise/race/iter-assigned-undefined-reject.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator property has the value undefined +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]: undefined + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-next-val-err-reject.js b/test/built-ins/Promise/race/iter-next-val-err-reject.js index e5cdcdf788..409d659822 100644 --- a/test/built-ins/Promise/race/iter-next-val-err-reject.js +++ b/test/built-ins/Promise/race/iter-next-val-err-reject.js @@ -47,7 +47,7 @@ iterNextValThrows[Symbol.iterator] = function() { }; Promise.race(iterNextValThrows).then(function() { - $ERROR('The promise should be rejected.'); + $DONE('The promise should be rejected.'); }, function(reason) { assert.sameValue(reason, error); }).then($DONE, $DONE); diff --git a/test/built-ins/Promise/race/iter-returns-false-reject.js b/test/built-ins/Promise/race/iter-returns-false-reject.js new file mode 100644 index 0000000000..c278a41f05 --- /dev/null +++ b/test/built-ins/Promise/race/iter-returns-false-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator returns false +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]() { + return false; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-returns-null-reject.js b/test/built-ins/Promise/race/iter-returns-null-reject.js new file mode 100644 index 0000000000..29500742b6 --- /dev/null +++ b/test/built-ins/Promise/race/iter-returns-null-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator returns null +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]() { + return null; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-returns-number-reject.js b/test/built-ins/Promise/race/iter-returns-number-reject.js new file mode 100644 index 0000000000..8144c82e1e --- /dev/null +++ b/test/built-ins/Promise/race/iter-returns-number-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator returns a number +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]() { + return 1; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-returns-string-reject.js b/test/built-ins/Promise/race/iter-returns-string-reject.js new file mode 100644 index 0000000000..43c413a536 --- /dev/null +++ b/test/built-ins/Promise/race/iter-returns-string-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator returns a string +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]() { + return ""; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-returns-symbol-reject.js b/test/built-ins/Promise/race/iter-returns-symbol-reject.js new file mode 100644 index 0000000000..1634c295b2 --- /dev/null +++ b/test/built-ins/Promise/race/iter-returns-symbol-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator returns a symbol +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]() { + return Symbol(); + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-returns-true-reject.js b/test/built-ins/Promise/race/iter-returns-true-reject.js new file mode 100644 index 0000000000..33d400c173 --- /dev/null +++ b/test/built-ins/Promise/race/iter-returns-true-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator returns true +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]() { + return true; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-returns-undefined-reject.js b/test/built-ins/Promise/race/iter-returns-undefined-reject.js new file mode 100644 index 0000000000..7d4eb49225 --- /dev/null +++ b/test/built-ins/Promise/race/iter-returns-undefined-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.race +description: > + Reject when argument's Symbol.iterator returns undefined +info: | + ... + Let iteratorRecord be GetIterator(iterable). + IfAbruptRejectPromise(iteratorRecord, promiseCapability). + ... + + #sec-getiterator + GetIterator ( obj [ , hint [ , method ] ] ) + + ... + Let iterator be ? Call(method, obj). + If Type(iterator) is not Object, throw a TypeError exception. + ... +features: [Symbol.iterator] +flags: [async] +---*/ + +try { + Promise.race({ + [Symbol.iterator]() { + return undefined; + } + }).then(function() { + $DONE('The promise should be rejected, but was resolved'); + }, function(error) { + assert(error instanceof TypeError); + }).then($DONE, $DONE); +} catch (error) { + $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); +} diff --git a/test/built-ins/Promise/race/iter-step-err-reject.js b/test/built-ins/Promise/race/iter-step-err-reject.js index 6f848b0862..dd51ebc17a 100644 --- a/test/built-ins/Promise/race/iter-step-err-reject.js +++ b/test/built-ins/Promise/race/iter-step-err-reject.js @@ -46,7 +46,7 @@ iterStepThrows[Symbol.iterator] = function() { }; Promise.race(iterStepThrows).then(function() { - $ERROR('The promise should be rejected.'); + $DONE('The promise should be rejected.'); }, function(reason) { assert.sameValue(reason, error); }).then($DONE, $DONE); -- GitLab