mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Add iter-arg tests
This commit is contained in:
parent
094ddc7f75
commit
9567abd85a
36
test/built-ins/Promise/any/iter-arg-is-false-reject.js
Normal file
36
test/built-ins/Promise/any/iter-arg-is-false-reject.js
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2019 Sergey Rubanov. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-promise.any
|
||||
description: >
|
||||
Reject when argument is `false`
|
||||
info: |
|
||||
Promise.any ( iterable )
|
||||
|
||||
...
|
||||
4. Let iteratorRecord be GetIterator(iterable).
|
||||
5. 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: [Promise.any, Symbol.iterator]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
try {
|
||||
Promise.any(false).then(function() {
|
||||
$DONE('The promise should be rejected, but was resolved');
|
||||
}, function(error) {
|
||||
assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
|
||||
assert(error instanceof TypeError);
|
||||
}).then($DONE, $DONE);
|
||||
} catch (error) {
|
||||
$DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
|
||||
}
|
36
test/built-ins/Promise/any/iter-arg-is-null-reject.js
Normal file
36
test/built-ins/Promise/any/iter-arg-is-null-reject.js
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2019 Sergey Rubanov. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-promise.any
|
||||
description: >
|
||||
Reject when argument is `null`
|
||||
info: |
|
||||
Promise.any ( iterable )
|
||||
|
||||
...
|
||||
4. Let iteratorRecord be GetIterator(iterable).
|
||||
5. 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: [Promise.any, Symbol.iterator]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
try {
|
||||
Promise.any(null).then(function() {
|
||||
$DONE('The promise should be rejected, but was resolved');
|
||||
}, function(error) {
|
||||
assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
|
||||
assert(error instanceof TypeError);
|
||||
}).then($DONE, $DONE);
|
||||
} catch (error) {
|
||||
$DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
|
||||
}
|
36
test/built-ins/Promise/any/iter-arg-is-number-reject.js
Normal file
36
test/built-ins/Promise/any/iter-arg-is-number-reject.js
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2019 Sergey Rubanov. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-promise.any
|
||||
description: >
|
||||
Reject when argument is a number
|
||||
info: |
|
||||
Promise.any ( iterable )
|
||||
|
||||
...
|
||||
4. Let iteratorRecord be GetIterator(iterable).
|
||||
5. 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: [Promise.any, Symbol.iterator]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
try {
|
||||
Promise.any(1).then(function() {
|
||||
$DONE('The promise should be rejected, but was resolved');
|
||||
}, function(error) {
|
||||
assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
|
||||
assert(error instanceof TypeError);
|
||||
}).then($DONE, $DONE);
|
||||
} catch (error) {
|
||||
$DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
|
||||
}
|
42
test/built-ins/Promise/any/iter-arg-is-poisoned.js
Normal file
42
test/built-ins/Promise/any/iter-arg-is-poisoned.js
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2019 Sergey Rubanov. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-promise.any
|
||||
description: >
|
||||
Reject with abrupt completion from GetIterator
|
||||
info: |
|
||||
Promise.any ( iterable )
|
||||
|
||||
...
|
||||
4. Let iteratorRecord be GetIterator(iterable).
|
||||
5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
|
||||
...
|
||||
|
||||
#sec-getiterator
|
||||
GetIterator ( obj [ , hint [ , method ] ] )
|
||||
|
||||
...
|
||||
Let iterator be ? Call(method, obj).
|
||||
...
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var poison = [];
|
||||
var error = new Test262Error();
|
||||
Object.defineProperty(poison, Symbol.iterator, {
|
||||
get() {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
Promise.any(poison).then(function() {
|
||||
$DONE('The promise should be rejected, but was resolved');
|
||||
}, function(err) {
|
||||
assert.sameValue(err, error);
|
||||
}).then($DONE, $DONE);
|
||||
} catch (error) {
|
||||
$DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
|
||||
}
|
35
test/built-ins/Promise/any/iter-arg-is-string-resolve.js
Normal file
35
test/built-ins/Promise/any/iter-arg-is-string-resolve.js
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2019 Sergey Rubanov. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-promise.any
|
||||
description: >
|
||||
Resolve when argument is a string
|
||||
info: |
|
||||
Promise.any ( iterable )
|
||||
|
||||
...
|
||||
4. Let iteratorRecord be GetIterator(iterable).
|
||||
5. 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: [Promise.any, Symbol.iterator]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
try {
|
||||
Promise.any('').then(function(v) {
|
||||
assert.sameValue(v.length, 0);
|
||||
}, function() {
|
||||
$DONE('The promise should be resolved, but was rejected');
|
||||
}).then($DONE, $DONE);
|
||||
} catch (error) {
|
||||
$DONE(`The promise should be resolved, but threw an exception: ${error.message}`);
|
||||
}
|
49
test/built-ins/Promise/any/iter-arg-is-symbol-reject.js
Normal file
49
test/built-ins/Promise/any/iter-arg-is-symbol-reject.js
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2019 Sergey Rubanov. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-promise.any
|
||||
description: >
|
||||
Reject when argument is a symbol
|
||||
info: |
|
||||
Promise.any ( iterable )
|
||||
|
||||
...
|
||||
4. Let iteratorRecord be GetIterator(iterable).
|
||||
5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
|
||||
...
|
||||
|
||||
GetIterator ( obj [ , hint [ , method ] ] )
|
||||
|
||||
...
|
||||
3. If method is not present, then
|
||||
a. If hint is async, then
|
||||
...
|
||||
b. Otherwise, set method to ? GetMethod(obj, @@iterator).
|
||||
4. Let iterator be ? Call(method, obj).
|
||||
5. If Type(iterator) is not Object, throw a TypeError exception.
|
||||
...
|
||||
|
||||
GetMethod
|
||||
|
||||
2. Let func be ? GetV(V, P).
|
||||
3. If func is either undefined or null, return undefined.
|
||||
4. If IsCallable(func) is false, throw a TypeError exception.
|
||||
|
||||
Call ( F, V [ , argumentsList ] )
|
||||
|
||||
2. If IsCallable(F) is false, throw a TypeError exception.
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
try {
|
||||
Promise.any(Symbol()).then(function() {
|
||||
$DONE('The promise should be rejected, but was resolved');
|
||||
}, function(error) {
|
||||
assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
|
||||
assert(error instanceof TypeError);
|
||||
}).then($DONE, $DONE);
|
||||
} catch (error) {
|
||||
$DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
|
||||
}
|
49
test/built-ins/Promise/any/iter-arg-is-true-reject.js
Normal file
49
test/built-ins/Promise/any/iter-arg-is-true-reject.js
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2019 Sergey Rubanov. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-promise.any
|
||||
description: >
|
||||
Reject when argument is `true`
|
||||
info: |
|
||||
Promise.any ( iterable )
|
||||
|
||||
...
|
||||
4. Let iteratorRecord be GetIterator(iterable).
|
||||
5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
|
||||
...
|
||||
|
||||
GetIterator ( obj [ , hint [ , method ] ] )
|
||||
|
||||
...
|
||||
3. If method is not present, then
|
||||
a. If hint is async, then
|
||||
...
|
||||
b. Otherwise, set method to ? GetMethod(obj, @@iterator).
|
||||
4. Let iterator be ? Call(method, obj).
|
||||
5. If Type(iterator) is not Object, throw a TypeError exception.
|
||||
...
|
||||
|
||||
GetMethod
|
||||
|
||||
2. Let func be ? GetV(V, P).
|
||||
3. If func is either undefined or null, return undefined.
|
||||
4. If IsCallable(func) is false, throw a TypeError exception.
|
||||
|
||||
Call ( F, V [ , argumentsList ] )
|
||||
|
||||
2. If IsCallable(F) is false, throw a TypeError exception.
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
try {
|
||||
Promise.any(true).then(function() {
|
||||
$DONE('The promise should be rejected, but was resolved');
|
||||
}, function(error) {
|
||||
assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
|
||||
assert(error instanceof TypeError);
|
||||
}).then($DONE, $DONE);
|
||||
} catch (error) {
|
||||
$DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
|
||||
}
|
49
test/built-ins/Promise/any/iter-arg-is-undefined-reject.js
Normal file
49
test/built-ins/Promise/any/iter-arg-is-undefined-reject.js
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2019 Sergey Rubanov. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-promise.any
|
||||
description: >
|
||||
Reject when argument is `undefined`
|
||||
info: |
|
||||
Promise.any ( iterable )
|
||||
|
||||
...
|
||||
4. Let iteratorRecord be GetIterator(iterable).
|
||||
5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
|
||||
...
|
||||
|
||||
GetIterator ( obj [ , hint [ , method ] ] )
|
||||
|
||||
...
|
||||
3. If method is not present, then
|
||||
a. If hint is async, then
|
||||
...
|
||||
b. Otherwise, set method to ? GetMethod(obj, @@iterator).
|
||||
4. Let iterator be ? Call(method, obj).
|
||||
5. If Type(iterator) is not Object, throw a TypeError exception.
|
||||
...
|
||||
|
||||
GetMethod
|
||||
|
||||
2. Let func be ? GetV(V, P).
|
||||
3. If func is either undefined or null, return undefined.
|
||||
4. If IsCallable(func) is false, throw a TypeError exception.
|
||||
|
||||
Call ( F, V [ , argumentsList ] )
|
||||
|
||||
2. If IsCallable(F) is false, throw a TypeError exception.
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
try {
|
||||
Promise.any(undefined).then(function() {
|
||||
$DONE('The promise should be rejected, but was resolved');
|
||||
}, function(error) {
|
||||
assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
|
||||
assert(error instanceof TypeError);
|
||||
}).then($DONE, $DONE);
|
||||
} catch (error) {
|
||||
$DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user