From f54477358316aba419a497cbb2bf755145e3c0f5 Mon Sep 17 00:00:00 2001 From: smikes Date: Mon, 10 Nov 2014 19:21:54 -0700 Subject: [PATCH] split "expectedThis" cases into strict/nonstrict branches --- .../25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T1.js | 8 +++--- .../25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T2.js | 22 +++++++++++++++ .../25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T1.js | 8 +++--- .../25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T2.js | 27 +++++++++++++++++++ .../25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T1.js | 8 +++--- .../25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T2.js | 22 +++++++++++++++ 6 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T2.js create mode 100644 test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T2.js create mode 100644 test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T2.js diff --git a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T1.js b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T1.js index 39ac61f1f1..18bb36f6f7 100644 --- a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T1.js +++ b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T1.js @@ -6,16 +6,16 @@ info: > Promise reaction jobs have predictable environment author: Sam Mikes description: Promise.onFulfilled gets undefined as 'this' +flags: [noStrict] +includes: [fnGlobalObject.js] ---*/ -var expectedThis, +var expectedThis = fnGlobalObject(), obj = {}; -(function () { expectedThis = this; }()); - var p = Promise.resolve(obj).then(function(arg) { 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) { $ERROR("Expected promise to be fulfilled by obj, actually " + arg); diff --git a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T2.js b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T2.js new file mode 100644 index 0000000000..7d5816f6fb --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T2.js @@ -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); diff --git a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T1.js b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T1.js index 2a0f5fdddc..9c2346bf8d 100644 --- a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T1.js +++ b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T1.js @@ -8,18 +8,18 @@ info: > undefined in strict mode author: Sam Mikes description: onRejected gets default 'this' +flags: [noStrict] +includes: [fnGlobalObject.js] ---*/ -var expectedThis, +var expectedThis = fnGlobalObject(), obj = {}; -(function () { expectedThis = this; }()); - var p = Promise.reject(obj).then(function () { $ERROR("Unexpected fulfillment; expected rejection."); }, function(arg) { 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) { diff --git a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T2.js b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T2.js new file mode 100644 index 0000000000..09bab4763c --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T2.js @@ -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); diff --git a/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T1.js b/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T1.js index d4d2dbb4fc..91833104fc 100644 --- a/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T1.js +++ b/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T1.js @@ -8,15 +8,15 @@ info: > undefined in strict mode author: Sam Mikes description: Promise executor gets default handling for 'this' +flags: [noStrict] +includes: [fnGlobalObject.js] ---*/ -var expectedThis; - -(function () { expectedThis = this; }()); +var expectedThis = fnGlobalObject(); var p = new Promise(function (resolve) { 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(); diff --git a/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T2.js b/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T2.js new file mode 100644 index 0000000000..2a63183513 --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T2.js @@ -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);