From eded6b269b5b4e2f5d8bda8a4cd9eec58f67a2f1 Mon Sep 17 00:00:00 2001
From: Mike Pennisi <mike@mikepennisi.com>
Date: Mon, 28 Dec 2015 17:25:24 -0500
Subject: [PATCH] Extend tests to fully cover invocation concerns

Update test metadata to accurately describe the more complete set of
assertions.
---
 .../then/rxn-handler-fulfilled-invoke-nonstrict.js  | 11 +++++++++--
 .../then/rxn-handler-fulfilled-invoke-strict.js     | 11 +++++++++--
 .../then/rxn-handler-rejected-invoke-nonstrict.js   | 13 +++++++++----
 .../then/rxn-handler-rejected-invoke-strict.js      | 13 +++++++++----
 4 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-nonstrict.js b/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-nonstrict.js
index db9e7a11d8..c149da931a 100644
--- a/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-nonstrict.js
+++ b/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-nonstrict.js
@@ -3,10 +3,12 @@
 
 /*---
 info: >
-    Promise reaction jobs have predictable environment
+    [...]
+    6. Else, let handlerResult be Call(handler, undefined, «argument»).
 es6id: S25.4.2.1_A3.1_T1
 author: Sam Mikes
-description: Promise.onFulfilled gets undefined as 'this'
+description: >
+    "fulfilled" handler invoked correctly outside of strict mode
 flags: [noStrict]
 includes: [fnGlobalObject.js]
 ---*/
@@ -25,6 +27,11 @@ var p = Promise.resolve(obj).then(function(arg) {
         return;
     }
 
+    if (arguments.length !== 1) {
+        $DONE('Expected handler function to be called with exactly 1 argument.');
+        return;
+    }
+
     $DONE();
 }, function() {
   $DONE('The promise should not be rejected.');
diff --git a/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-strict.js b/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-strict.js
index f79ea81284..33068c06e4 100644
--- a/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-strict.js
+++ b/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-strict.js
@@ -3,10 +3,12 @@
 
 /*---
 info: >
-    Promise reaction jobs have predictable environment
+    [...]
+    6. Else, let handlerResult be Call(handler, undefined, «argument»).
 es6id: S25.4.2.1_A3.1_T2
 author: Sam Mikes
-description: Promise.onFulfilled gets undefined as 'this'
+description: >
+    "fulfilled" handler invoked correctly in strict mode
 flags: [onlyStrict]
 ---*/
 
@@ -24,6 +26,11 @@ var p = Promise.resolve(obj).then(function(arg) {
         return;
     }
 
+    if (arguments.length !== 1) {
+        $DONE('Expected handler function to be called with exactly 1 argument.');
+        return;
+    }
+
     $DONE();
 }, function() {
   $DONE('The promise should not be rejected.');
diff --git a/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-nonstrict.js b/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-nonstrict.js
index 078bbe2d5b..ee2bff3722 100644
--- a/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-nonstrict.js
+++ b/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-nonstrict.js
@@ -3,12 +3,12 @@
 
 /*---
 info: >
-    Promise reaction jobs have predictable environment
-    'this' is global object in sloppy mode,
-    undefined in strict mode
+    [...]
+    6. Else, let handlerResult be Call(handler, undefined, «argument»).
 es6id: S25.4.2.1_A3.2_T1
 author: Sam Mikes
-description: onRejected gets default 'this'
+description: >
+    "rejected" handler invoked correctly outside of strict mode
 flags: [noStrict]
 includes: [fnGlobalObject.js]
 ---*/
@@ -29,5 +29,10 @@ var p = Promise.reject(obj).then(function () {
         return;
     }
 
+    if (arguments.length !== 1) {
+        $DONE('Expected handler function to be called with exactly 1 argument.');
+        return;
+    }
+
     $DONE();
 });
diff --git a/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-strict.js b/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-strict.js
index 2736556e3a..c782ddb9d0 100644
--- a/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-strict.js
+++ b/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-strict.js
@@ -3,12 +3,12 @@
 
 /*---
 info: >
-    Promise reaction jobs have predictable environment
-    'this' is global object in sloppy mode,
-    undefined in strict mode
+    [...]
+    6. Else, let handlerResult be Call(handler, undefined, «argument»).
 es6id: S25.4.2.1_A3.2_T2
 author: Sam Mikes
-description: onRejected gets default 'this'
+description: >
+    "rejected" handler invoked correctly in strict mode
 flags: [onlyStrict]
 ---*/
 
@@ -28,5 +28,10 @@ var p = Promise.reject(obj).then(function () {
         return;
     }
 
+    if (arguments.length !== 1) {
+        $DONE('Expected handler function to be called with exactly 1 argument.');
+        return;
+    }
+
     $DONE();
 });
-- 
GitLab