Skip to content

Commit

Permalink
Update Promise.all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shvaikalesh authored and rwaldron committed Jun 3, 2020
1 parent 081afde commit cf37b03
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 104 deletions.
57 changes: 0 additions & 57 deletions test/built-ins/Promise/all/invoke-resolve-get-error-close.js

This file was deleted.

40 changes: 40 additions & 0 deletions test/built-ins/Promise/all/invoke-resolve-get-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-promise.all
description: >
Promise.resolve is retrieved before GetIterator call (abrupt lookup).
info: |
Promise.all ( iterable )
[...]
3. Let promiseResolve be GetPromiseResolve(C).
4. IfAbruptRejectPromise(promiseResolve, promiseCapability).
GetPromiseResolve ( promiseConstructor )
[...]
2. Let promiseResolve be ? Get(promiseConstructor, "resolve").
flags: [async]
features: [Symbol.iterator]
---*/

const iter = {
get [Symbol.iterator]() {
throw new Test262Error('unreachable');
},
};

const resolveError = { name: 'MyError' };
Object.defineProperty(Promise, 'resolve', {
get() {
throw resolveError;
},
});

Promise.all(iter).then(() => {
throw new Test262Error('The promise should be rejected, but it was resolved');
}, (reason) => {
assert.sameValue(reason, resolveError);
}).then($DONE, $DONE);
36 changes: 36 additions & 0 deletions test/built-ins/Promise/all/resolve-non-callable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (C) 2020 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-promise.all
description: >
Promise.resolve is retrieved before GetIterator call (non-callable).
info: |
Promise.all ( iterable )
[...]
3. Let promiseResolve be GetPromiseResolve(C).
4. IfAbruptRejectPromise(promiseResolve, promiseCapability).
GetPromiseResolve ( promiseConstructor )
[...]
2. Let promiseResolve be ? Get(promiseConstructor, "resolve").
3. If IsCallable(promiseResolve) is false, throw a TypeError exception.
flags: [async]
features: [Symbol.iterator]
---*/

const iter = { 
get [Symbol.iterator]() {
throw new Test262Error("unreachable");
},
};

Promise.resolve = "certainly not callable";

Promise.all(iter).then(() => {
throw new Test262Error("The promise should be rejected, but it was resolved");
}, (reason) => {
assert(reason instanceof TypeError);
}).then($DONE, $DONE);
47 changes: 0 additions & 47 deletions test/built-ins/Promise/all/resolve-not-callable-close.js

This file was deleted.

0 comments on commit cf37b03

Please sign in to comment.