mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Re-organize tests according to internal operations
By organizing files according to the structure of the specification, test coverage can be more methodically evaluated.
This commit is contained in:
parent
29cdc4543f
commit
5a8d1fdf77
32
test/built-ins/Promise/prototype/then/prfm-fulfilled.js
vendored
Normal file
32
test/built-ins/Promise/prototype/then/prfm-fulfilled.js
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 25.4.5.3
|
||||
description: PerformPromiseThen on a fulfilled promise
|
||||
info: >
|
||||
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||
resultCapability).
|
||||
|
||||
25.4.5.3.1 PerformPromiseThen
|
||||
|
||||
[...]
|
||||
8. Else if the value of promise's [[PromiseState]] internal slot is
|
||||
"fulfilled",
|
||||
a. Let value be the value of promise's [[PromiseResult]] internal slot.
|
||||
b. Perform EnqueueJob("PromiseJobs", PromiseReactionJob,
|
||||
«fulfillReaction, value»).
|
||||
[...]
|
||||
---*/
|
||||
|
||||
var value = {};
|
||||
var p = new Promise(function(resolve) { resolve(value); });
|
||||
|
||||
p.then(function(x) {
|
||||
if (x !== value) {
|
||||
$DONE('The `onFulfilled` handler should be invoked with the promise result.');
|
||||
return;
|
||||
}
|
||||
$DONE();
|
||||
}, function() {
|
||||
$DONE('The `onRejected` handler should not be invoked.');
|
||||
});
|
@ -2,7 +2,7 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 25.4.5.3
|
||||
description: The `onRejected` method throws an error
|
||||
description: PerformPromiseThen on a rejected promise
|
||||
info: >
|
||||
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||
resultCapability).
|
||||
@ -15,19 +15,18 @@ info: >
|
||||
a. Let reason be the value of promise's [[PromiseResult]] internal slot.
|
||||
b. Perform EnqueueJob("PromiseJobs", PromiseReactionJob,
|
||||
«rejectReaction, reason»).
|
||||
[...]
|
||||
---*/
|
||||
|
||||
var error = new Test262Error();
|
||||
var promise = new Promise(function(_, reject) {
|
||||
reject();
|
||||
});
|
||||
|
||||
promise.then(null, function() {
|
||||
throw error;
|
||||
}).then(function(result) {
|
||||
$DONE('This promise should not be fulfilled');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
var value = {};
|
||||
var p = new Promise(function(_, reject) { reject(value); });
|
||||
|
||||
p.then(function() {
|
||||
$DONE('The `onFulfilled` handler should not be invoked.');
|
||||
}, function(x) {
|
||||
if (x !== value) {
|
||||
$DONE('The `onRejected` handler should be invoked with the promise result.');
|
||||
return;
|
||||
}
|
||||
$DONE();
|
||||
});
|
@ -1,46 +0,0 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 25.4.5.3
|
||||
description: >
|
||||
Access error for the `then` property of the object returned from the "on fulfilled" handler
|
||||
info: >
|
||||
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||
resultCapability).
|
||||
|
||||
25.4.5.3.1 PerformPromiseThen
|
||||
|
||||
[...]
|
||||
8. Else if the value of promise's [[PromiseState]] internal slot is
|
||||
"fulfilled",
|
||||
a. Let value be the value of promise's [[PromiseResult]] internal slot.
|
||||
b. Perform EnqueueJob("PromiseJobs", PromiseReactionJob,
|
||||
«fulfillReaction, value»).
|
||||
|
||||
25.4.1.3.2 Promise Resolve Functions
|
||||
|
||||
[...]
|
||||
8. Let then be Get(resolution, "then").
|
||||
9. If then is an abrupt completion, then
|
||||
a. Return RejectPromise(promise, then.[[value]]).
|
||||
---*/
|
||||
|
||||
var poisonedThen = {};
|
||||
var error = new Test262Error();
|
||||
Object.defineProperty(poisonedThen, 'then', {
|
||||
get: function() {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
var p = new Promise(function(r) { r(); });
|
||||
|
||||
p.then(function() {
|
||||
return poisonedThen;
|
||||
}).then(function() {
|
||||
$DONE('The promise should not be fulfilled');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
|
||||
$DONE();
|
||||
});
|
@ -1,41 +0,0 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 25.4.5.3
|
||||
description: The return value of the `onFulfilled` method is a "thenable" object
|
||||
info: >
|
||||
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||
resultCapability).
|
||||
|
||||
25.4.5.3.1 PerformPromiseThen
|
||||
|
||||
[...]
|
||||
8. Else if the value of promise's [[PromiseState]] internal slot is
|
||||
"fulfilled",
|
||||
a. Let value be the value of promise's [[PromiseResult]] internal slot.
|
||||
b. Perform EnqueueJob("PromiseJobs", PromiseReactionJob,
|
||||
«fulfillReaction, value»).
|
||||
|
||||
25.4.1.3.2 Promise Resolve Functions
|
||||
|
||||
[...]
|
||||
6. If SameValue(resolution, promise) is true, then
|
||||
a. Let selfResolutionError be a newly created TypeError object.
|
||||
b. Return RejectPromise(promise, selfResolutionError).
|
||||
---*/
|
||||
|
||||
var promise1 = new Promise(function(resolve) {
|
||||
resolve();
|
||||
});
|
||||
|
||||
var promise2 = promise1.then(function() {
|
||||
return promise2;
|
||||
});
|
||||
|
||||
promise2.then(function() {
|
||||
$DONE('This promise should not be resolved');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason.constructor, TypeError);
|
||||
|
||||
$DONE();
|
||||
});
|
@ -1,57 +0,0 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 25.4.5.3
|
||||
description: The `onFulfilled` method throws an error
|
||||
info: >
|
||||
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||
resultCapability).
|
||||
|
||||
25.4.5.3.1 PerformPromiseThen
|
||||
|
||||
[...]
|
||||
8. Else if the value of promise's [[PromiseState]] internal slot is
|
||||
"fulfilled",
|
||||
a. Let value be the value of promise's [[PromiseResult]] internal slot.
|
||||
b. Perform EnqueueJob("PromiseJobs", PromiseReactionJob,
|
||||
«fulfillReaction, value»).
|
||||
|
||||
25.4.1.3.2 Promise Resolve Functions
|
||||
|
||||
[...]
|
||||
8. Let then be Get(resolution, "then").
|
||||
9. If then is an abrupt completion, then
|
||||
a. Return RejectPromise(promise, then.[[value]]).
|
||||
10. Let thenAction be then.[[value]].
|
||||
11. If IsCallable(thenAction) is false, then
|
||||
a. Return FulfillPromise(promise, resolution).
|
||||
12. Perform EnqueueJob ("PromiseJobs", PromiseResolveThenableJob, «promise,
|
||||
resolution, thenAction»)
|
||||
13. Return undefined.
|
||||
|
||||
25.4.2.2 PromiseResolveThenableJob
|
||||
|
||||
2. Let thenCallResult be Call(then, thenable,
|
||||
«resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
|
||||
3. If thenCallResult is an abrupt completion,
|
||||
a. Let status be Call(resolvingFunctions.[[Reject]], undefined,
|
||||
«thenCallResult.[[value]]»).
|
||||
b. NextJob Completion(status).
|
||||
---*/
|
||||
|
||||
var error = new Test262Error();
|
||||
var promiseFulfilled = false;
|
||||
var promiseRejected = false;
|
||||
var promise = new Promise(function(resolve) {
|
||||
resolve();
|
||||
});
|
||||
|
||||
promise.then(function() {
|
||||
throw error;
|
||||
}).then(function() {
|
||||
$DONE('This promise should not be fulfilled');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
|
||||
$DONE();
|
||||
});
|
@ -1,33 +0,0 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 25.4.5.3
|
||||
description: The return value of the `onRejected` method
|
||||
info: >
|
||||
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||
resultCapability).
|
||||
|
||||
25.4.5.3.1 PerformPromiseThen
|
||||
|
||||
[...]
|
||||
9. Else if the value of promise's [[PromiseState]] internal slot is
|
||||
"rejected",
|
||||
a. Let reason be the value of promise's [[PromiseResult]] internal slot.
|
||||
b. Perform EnqueueJob("PromiseJobs", PromiseReactionJob,
|
||||
«rejectReaction, reason»).
|
||||
---*/
|
||||
|
||||
var returnVal = {};
|
||||
var promise = new Promise(function(_, reject) {
|
||||
reject();
|
||||
});
|
||||
|
||||
promise.then(null, function() {
|
||||
return returnVal;
|
||||
}).then(function(result) {
|
||||
assert.sameValue(result, returnVal);
|
||||
|
||||
$DONE();
|
||||
}, function() {
|
||||
$DONE('The promise should not be rejected');
|
||||
});
|
49
test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-return-abrupt.js
vendored
Normal file
49
test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-return-abrupt.js
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: An abrupt completion should trigger promise rejection
|
||||
es6id: 25.4.5.3
|
||||
info: >
|
||||
[...]
|
||||
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||
resultCapability).
|
||||
|
||||
25.4.5.3.1 PerformPromiseThen
|
||||
[...]
|
||||
8. Else if the value of promise's [[PromiseState]] internal slot is
|
||||
"fulfilled",
|
||||
a. Let value be the value of promise's [[PromiseResult]] internal slot.
|
||||
b. EnqueueJob("PromiseJobs", PromiseReactionJob, «fulfillReaction,
|
||||
value»).
|
||||
|
||||
25.4.2.1 PromiseReactionJob
|
||||
[...]
|
||||
7. If handlerResult is an abrupt completion, then
|
||||
a. Let status be Call(promiseCapability.[[Reject]], undefined,
|
||||
«handlerResult.[[value]]»).
|
||||
b. NextJob Completion(status).
|
||||
8. Let status be Call(promiseCapability.[[Resolve]], undefined,
|
||||
«handlerResult.[[value]]»).
|
||||
9. NextJob Completion(status).
|
||||
---*/
|
||||
|
||||
var value = {};
|
||||
var p1 = new Promise(function(resolve) {
|
||||
resolve();
|
||||
});
|
||||
var p2;
|
||||
|
||||
p2 = p1.then(function() {
|
||||
throw value;
|
||||
}, function() {});
|
||||
|
||||
p2.then(function() {
|
||||
$DONE('The `onFulfilled` handler should not be invoked.');
|
||||
}, function(x) {
|
||||
if (x !== value) {
|
||||
$DONE('The `onRejected` handler should be invoked with the promise result.');
|
||||
return;
|
||||
}
|
||||
|
||||
$DONE();
|
||||
});
|
49
test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-return-normal.js
vendored
Normal file
49
test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-return-normal.js
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: A normal completion should trigger promise fulfillment
|
||||
es6id: 25.4.5.3
|
||||
info: >
|
||||
[...]
|
||||
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||
resultCapability).
|
||||
|
||||
25.4.5.3.1 PerformPromiseThen
|
||||
[...]
|
||||
8. Else if the value of promise's [[PromiseState]] internal slot is
|
||||
"fulfilled",
|
||||
a. Let value be the value of promise's [[PromiseResult]] internal slot.
|
||||
b. EnqueueJob("PromiseJobs", PromiseReactionJob, «fulfillReaction,
|
||||
value»).
|
||||
|
||||
25.4.2.1 PromiseReactionJob
|
||||
[...]
|
||||
7. If handlerResult is an abrupt completion, then
|
||||
a. Let status be Call(promiseCapability.[[Reject]], undefined,
|
||||
«handlerResult.[[value]]»).
|
||||
b. NextJob Completion(status).
|
||||
8. Let status be Call(promiseCapability.[[Resolve]], undefined,
|
||||
«handlerResult.[[value]]»).
|
||||
9. NextJob Completion(status).
|
||||
---*/
|
||||
|
||||
var value = {};
|
||||
var p1 = new Promise(function(resolve) {
|
||||
resolve();
|
||||
});
|
||||
var p2;
|
||||
|
||||
p2 = p1.then(function() {
|
||||
return value;
|
||||
}, function() {});
|
||||
|
||||
p2.then(function(x) {
|
||||
if (x !== value) {
|
||||
$DONE('The `onFulfilled` handler should be invoked with the promise result.');
|
||||
return;
|
||||
}
|
||||
|
||||
$DONE();
|
||||
}, function() {
|
||||
$DONE('The `onRejected` handler should not be invoked.');
|
||||
});
|
49
test/built-ins/Promise/prototype/then/rxn-handler-rejected-return-abrupt.js
vendored
Normal file
49
test/built-ins/Promise/prototype/then/rxn-handler-rejected-return-abrupt.js
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: An abrupt completion should trigger promise rejection
|
||||
es6id: 25.4.5.3
|
||||
info: >
|
||||
[...]
|
||||
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||
resultCapability).
|
||||
|
||||
25.4.5.3.1 PerformPromiseThen
|
||||
[...]
|
||||
9. Else if the value of promise's [[PromiseState]] internal slot is
|
||||
"rejected",
|
||||
a. Let reason be the value of promise's [[PromiseResult]] internal slot.
|
||||
b. Perform EnqueueJob("PromiseJobs", PromiseReactionJob,
|
||||
«rejectReaction, reason»).
|
||||
|
||||
25.4.2.1 PromiseReactionJob
|
||||
[...]
|
||||
7. If handlerResult is an abrupt completion, then
|
||||
a. Let status be Call(promiseCapability.[[Reject]], undefined,
|
||||
«handlerResult.[[value]]»).
|
||||
b. NextJob Completion(status).
|
||||
8. Let status be Call(promiseCapability.[[Resolve]], undefined,
|
||||
«handlerResult.[[value]]»).
|
||||
9. NextJob Completion(status).
|
||||
---*/
|
||||
|
||||
var value = {};
|
||||
var p1 = new Promise(function(_, reject) {
|
||||
reject();
|
||||
});
|
||||
var p2;
|
||||
|
||||
p2 = p1.then(function() {}, function() {
|
||||
throw value;
|
||||
});
|
||||
|
||||
p2.then(function() {
|
||||
$DONE('The `onFulfilled` handler should not be invoked.');
|
||||
}, function(x) {
|
||||
if (x !== value) {
|
||||
$DONE('The `onRejected` handler should be invoked with the promise result.');
|
||||
return;
|
||||
}
|
||||
|
||||
$DONE();
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user