mirror of https://github.com/tc39/test262.git
add tests for Promise.withResolvers proposal
This commit is contained in:
parent
e04e1c1a39
commit
81ba258677
|
@ -108,6 +108,10 @@ json-parse-with-source
|
|||
# https://github.com/tc39/proposal-iterator-helpers
|
||||
iterator-helpers
|
||||
|
||||
# Promise.withResolvers
|
||||
# https://github.com/tc30/proposal-promise-with-resolvers
|
||||
promise-with-resolvers
|
||||
|
||||
## Standard language features
|
||||
#
|
||||
# Language features that have been included in a published version of the
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2023 Peter Klecha. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Promise.withResolvers produces instances of the reciever
|
||||
features: [promise-with-resolvers]
|
||||
---*/
|
||||
|
||||
class SubPromise extends Promise {}
|
||||
|
||||
var instance = Promise.withResolvers.call(SubPromise);
|
||||
|
||||
assert.sameValue(instance.promise.constructor, SubPromise);
|
||||
assert.sameValue(instance.promise instanceof SubPromise, true);
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (C) 2023 Peter Klecha. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Promise.withResolvers errors when the reciever is not a constructor
|
||||
features: [promise-with-resolvers]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Promise.withResolvers.call(eval);
|
||||
});
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2023 Peter Klecha. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Promise.withResolvers errors when the receiver is not an object
|
||||
features: [promise-with-resolvers]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Promise.withResolvers.call(undefined);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Promise.withResolvers.call(null);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Promise.withResolvers.call(86);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Promise.withResolvers.call('string');
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Promise.withResolvers.call(true);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Promise.withResolvers.call(Symbol());
|
||||
});
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2023 Peter Klecha. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Promise.withResolvers return value has a property called "promise" which is a Promise
|
||||
features: [promise-with-resolvers]
|
||||
---*/
|
||||
|
||||
|
||||
var instance = Promise.withResolvers();
|
||||
|
||||
assert.sameValue(instance.promise.constructor, Promise);
|
||||
assert.sameValue(instance.promise instanceof Promise, true);
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2023 Peter Klecha. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Promise.withResolvers return value has properties called "resolve" and "reject" which are unary functions
|
||||
features: [promise-with-resolvers]
|
||||
---*/
|
||||
|
||||
|
||||
var instance = Promise.withResolvers();
|
||||
|
||||
assert.sameValue(typeof instance.resolve, 'function', 'type of resolve property');
|
||||
assert.sameValue(instance.resolve.length, 1, 'length of resolve property');
|
||||
assert.sameValue(typeof instance.reject, 'function', 'type of reject property');
|
||||
assert.sameValue(instance.reject.length, 1, 'length of reject property');
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2023 Peter Klecha. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Promise.withResolvers result is an object with keys "promise", "reject", and "resolve"
|
||||
features: [promise-with-resolvers]
|
||||
---*/
|
||||
|
||||
|
||||
var instance = Promise.withResolvers();
|
||||
|
||||
assert.sameValue(typeof instance, "object");
|
||||
assert.notSameValue(instance, null);
|
||||
assert(Object.hasOwn(instance, "promise"));
|
||||
assert(Object.hasOwn(instance, "resolve"));
|
||||
assert(Object.hasOwn(instance, "reject"));
|
||||
|
Loading…
Reference in New Issue