mirror of https://github.com/tc39/test262.git
split "expectedThis" cases into strict/nonstrict branches
This commit is contained in:
parent
26787ab09b
commit
f544773583
|
@ -6,16 +6,16 @@ info: >
|
||||||
Promise reaction jobs have predictable environment
|
Promise reaction jobs have predictable environment
|
||||||
author: Sam Mikes
|
author: Sam Mikes
|
||||||
description: Promise.onFulfilled gets undefined as 'this'
|
description: Promise.onFulfilled gets undefined as 'this'
|
||||||
|
flags: [noStrict]
|
||||||
|
includes: [fnGlobalObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var expectedThis,
|
var expectedThis = fnGlobalObject(),
|
||||||
obj = {};
|
obj = {};
|
||||||
|
|
||||||
(function () { expectedThis = this; }());
|
|
||||||
|
|
||||||
var p = Promise.resolve(obj).then(function(arg) {
|
var p = Promise.resolve(obj).then(function(arg) {
|
||||||
if (this !== expectedThis) {
|
if (this !== expectedThis) {
|
||||||
$ERROR("'this' must be same as for function called without explicit this got " + this);
|
$ERROR("'this' must be global object, got " + this);
|
||||||
}
|
}
|
||||||
if (arg !== obj) {
|
if (arg !== obj) {
|
||||||
$ERROR("Expected promise to be fulfilled by obj, actually " + arg);
|
$ERROR("Expected promise to be fulfilled by obj, actually " + arg);
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2014 Cubane Canada, Inc. All rights reserved.
|
||||||
|
// See LICENSE for details.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
info: >
|
||||||
|
Promise reaction jobs have predictable environment
|
||||||
|
author: Sam Mikes
|
||||||
|
description: Promise.onFulfilled gets undefined as 'this'
|
||||||
|
flags: [onlyStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var expectedThis = undefined,
|
||||||
|
obj = {};
|
||||||
|
|
||||||
|
var p = Promise.resolve(obj).then(function(arg) {
|
||||||
|
if (this !== expectedThis) {
|
||||||
|
$ERROR("'this' must be undefined, got " + this);
|
||||||
|
}
|
||||||
|
if (arg !== obj) {
|
||||||
|
$ERROR("Expected promise to be fulfilled by obj, actually " + arg);
|
||||||
|
}
|
||||||
|
}).then($DONE, $DONE);
|
|
@ -8,18 +8,18 @@ info: >
|
||||||
undefined in strict mode
|
undefined in strict mode
|
||||||
author: Sam Mikes
|
author: Sam Mikes
|
||||||
description: onRejected gets default 'this'
|
description: onRejected gets default 'this'
|
||||||
|
flags: [noStrict]
|
||||||
|
includes: [fnGlobalObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var expectedThis,
|
var expectedThis = fnGlobalObject(),
|
||||||
obj = {};
|
obj = {};
|
||||||
|
|
||||||
(function () { expectedThis = this; }());
|
|
||||||
|
|
||||||
var p = Promise.reject(obj).then(function () {
|
var p = Promise.reject(obj).then(function () {
|
||||||
$ERROR("Unexpected fulfillment; expected rejection.");
|
$ERROR("Unexpected fulfillment; expected rejection.");
|
||||||
}, function(arg) {
|
}, function(arg) {
|
||||||
if (this !== expectedThis) {
|
if (this !== expectedThis) {
|
||||||
$ERROR("'this' must be same as for function called without explicit this, got " + this);
|
$ERROR("'this' must be global object, got " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg !== obj) {
|
if (arg !== obj) {
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright 2014 Cubane Canada, Inc. All rights reserved.
|
||||||
|
// See LICENSE for details.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
info: >
|
||||||
|
Promise reaction jobs have predictable environment
|
||||||
|
'this' is global object in sloppy mode,
|
||||||
|
undefined in strict mode
|
||||||
|
author: Sam Mikes
|
||||||
|
description: onRejected gets default 'this'
|
||||||
|
flags: [onlyStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var expectedThis = undefined,
|
||||||
|
obj = {};
|
||||||
|
|
||||||
|
var p = Promise.reject(obj).then(function () {
|
||||||
|
$ERROR("Unexpected fulfillment; expected rejection.");
|
||||||
|
}, function(arg) {
|
||||||
|
if (this !== expectedThis) {
|
||||||
|
$ERROR("'this' must be undefined, got " + this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg !== obj) {
|
||||||
|
$ERROR("Expected promise to be rejected with obj, actually " + arg);
|
||||||
|
}
|
||||||
|
}).then($DONE, $DONE);
|
|
@ -8,15 +8,15 @@ info: >
|
||||||
undefined in strict mode
|
undefined in strict mode
|
||||||
author: Sam Mikes
|
author: Sam Mikes
|
||||||
description: Promise executor gets default handling for 'this'
|
description: Promise executor gets default handling for 'this'
|
||||||
|
flags: [noStrict]
|
||||||
|
includes: [fnGlobalObject.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var expectedThis;
|
var expectedThis = fnGlobalObject();
|
||||||
|
|
||||||
(function () { expectedThis = this; }());
|
|
||||||
|
|
||||||
var p = new Promise(function (resolve) {
|
var p = new Promise(function (resolve) {
|
||||||
if (this !== expectedThis) {
|
if (this !== expectedThis) {
|
||||||
$ERROR("'this' must be same as for function called without explicit this, got " + this);
|
$ERROR("'this' must be global object, got " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2014 Cubane Canada, Inc. All rights reserved.
|
||||||
|
// See LICENSE for details.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
info: >
|
||||||
|
Promise executor has predictable environment
|
||||||
|
'this' should be global object in sloppy mode,
|
||||||
|
undefined in strict mode
|
||||||
|
author: Sam Mikes
|
||||||
|
description: Promise executor gets default handling for 'this'
|
||||||
|
flags: [onlyStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var expectedThis = undefined;
|
||||||
|
|
||||||
|
var p = new Promise(function (resolve) {
|
||||||
|
if (this !== expectedThis) {
|
||||||
|
$ERROR("'this' must be undefined, got " + this);
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
}).then($DONE, $DONE);
|
Loading…
Reference in New Issue