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 0000000000000000000000000000000000000000..4be22b640613082b6296ca06245d948f059fbb54 --- /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 0000000000000000000000000000000000000000..c371a52c84675abaa9c81f68ce53e8e1ad026fc5 --- /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 0000000000000000000000000000000000000000..3091a5b423844dcde8ba6c9aa4dc015649087aae --- /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 0000000000000000000000000000000000000000..46bb6dde6a67cae8a7778449b1f74c72f67d8ca3 --- /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 0000000000000000000000000000000000000000..21904dc40b631990926f6587e43114acf0271b61 --- /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 0000000000000000000000000000000000000000..a650a162132c999470bd3d51cb739f39659ba5b0 --- /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 0000000000000000000000000000000000000000..4a504aff5e0602a95705600a04f989c4ee837b1f --- /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 0000000000000000000000000000000000000000..ea923ae77b8c5fb4736e8fb585d184eca163e0a2 --- /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 0000000000000000000000000000000000000000..a6e1a72009290cb6c58c43548fb38b9a990ff11a --- /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 0000000000000000000000000000000000000000..4fbd7ee57fb050613e11dc4e0c18ca0d3e3e4389 --- /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 0000000000000000000000000000000000000000..c640870a0acfe80fbb69d6b02020fe788614f0b9 --- /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 0000000000000000000000000000000000000000..bb27314c27e3908b74eff4d17fa39deae2f2a8af --- /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 0000000000000000000000000000000000000000..c26923e10975332d57261653c6f8cb9110d5726c --- /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 0000000000000000000000000000000000000000..ec71ce3053c78482da534c59be3d779f25d720ad --- /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 811b19923bee0f888e268ed4237e0d82af294180..49e1072ab0f360a7302ffb3cb3eeb018a2195d2d 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 0000000000000000000000000000000000000000..be85e1878d3081bcb1e8ce86478cba21093b2d0e --- /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 0000000000000000000000000000000000000000..bbfefe332614c7d9b3b8fb1e4e63b3ea858aab24 --- /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 0000000000000000000000000000000000000000..a880607a03cd70625c6aa66403503fd97160aada --- /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 0000000000000000000000000000000000000000..a65c45278119c79f9085b783edd4e3e2ce1f1c62 --- /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 0000000000000000000000000000000000000000..532b64b25ca4585dbc00632de32c8d98dfe0df3c --- /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 0000000000000000000000000000000000000000..f0c1c6ac9b16655456996e1bf8576969b6a82824 --- /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 0000000000000000000000000000000000000000..786402389bc62c6345fe025b6f197239a9a05868 --- /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 e288093ac1a6abf0b5ca278ae6defd604eec03af..4e9e04b339f0438213182b412e8417280ae56f95 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 a100ef0bbbc61dda8746925713028d9e2b175986..4396343bf4145fc2ee2dc4e55133fdb4c29cdf8c 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 0000000000000000000000000000000000000000..2d4576ea1e1471318da2bf31d81b73bd2c4d223a --- /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 0000000000000000000000000000000000000000..30f53d111e05ed2e1143a59be710df862bc8dbe1 --- /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 0000000000000000000000000000000000000000..902764ba8c1d038d669484255d2bf49243dbf1c4 --- /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 0000000000000000000000000000000000000000..02490594efa67d6b80f0acece3c417f7abc532f7 --- /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 0000000000000000000000000000000000000000..1e204c471d17c3bdda6c116201f2c7db7e273f5c --- /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 0000000000000000000000000000000000000000..2b173aba801e00385fd2b4d4a0542369143de537 --- /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 0000000000000000000000000000000000000000..b8a63f86a39121ee336a6cb41a7a49b8e2b93d56 --- /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 0000000000000000000000000000000000000000..13e508fbe297772071af741162338b066db443e6 --- /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 0000000000000000000000000000000000000000..ad701aac90bb3544fa98a372449b7972b246745b --- /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 0000000000000000000000000000000000000000..d91bed7a5163e1cfe4124b3d8f7e8d61edba8eaf --- /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 0000000000000000000000000000000000000000..463e281b9b277ed6cb1b440f546bdae38de0938a --- /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 0000000000000000000000000000000000000000..81ecb818049110b5ec3828cd2d5e81c8148b98ec --- /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 0000000000000000000000000000000000000000..1bdaeee31757dff40b216c3a3fa922421205046f --- /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 0000000000000000000000000000000000000000..b7002aa88bad283cf6bbe6239432caf875042446 --- /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 e5cdcdf7881b7e6294b7631c7c26dd866605f556..409d6598228d19cfabbf03a82e58dbda41a341f7 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 0000000000000000000000000000000000000000..c278a41f0534f1334d70e0cc892efb3451838a22 --- /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 0000000000000000000000000000000000000000..29500742b6ff013da3ade7eb0ddb24c2076aaf00 --- /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 0000000000000000000000000000000000000000..8144c82e1e7c0f3032baca8c3e1db6fa5e4b689d --- /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 0000000000000000000000000000000000000000..43c413a536da8b110f6c24d2f8951140eb317ce1 --- /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 0000000000000000000000000000000000000000..1634c295b2c416d803e8ba66c16842b7bc5b9bfa --- /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 0000000000000000000000000000000000000000..33d400c173351715bc36562403214159ec10c47e --- /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 0000000000000000000000000000000000000000..7d4eb492256e5a6984d9a01c21744cbd37631a68 --- /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 6f848b0862ae50b064f0e4e9c761bda520721554..dd51ebc17abf019a853fcf78319ad732593831ff 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);