Skip to content

Commit

Permalink
Add extra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuanjl committed Feb 4, 2018
1 parent f082b6a commit 3e050b8
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 20 deletions.
35 changes: 24 additions & 11 deletions test/es7/PromiseRejectionTracking.baseline
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
Executing test #1 - Reject promise with no reactions.
Uncaught promise rejection
1234
Rejection from test 1
Executing test #2 - Reject promise with a catch reaction only.
Executing test #3 - Reject promise with catch and then reactions.
Executing test #4 - Reject promise then add a catch afterwards.
Uncaught promise rejection
Should be seen
Rejection from test 4
Promise rejection handled
Should be seen
Rejection from test 4
Executing test #5 - Reject promise then add two catches afterwards.
Uncaught promise rejection
Should also be seen
Rejection from test 5
Promise rejection handled
Should also be seen
Rejection from test 5
Executing test #6 - Async function that throws.
Uncaught promise rejection
throwing
Rejection from test 6
Executing test #7 - Async function that throws but is caught.
Uncaught promise rejection
throwing again
Rejection from test 7
Promise rejection handled
throwing again
Rejection from test 7
Executing test #8 - Async function that awaits a function that throws.
Uncaught promise rejection
throwing once again
Rejection from test 8
Promise rejection handled
throwing once again
Rejection from test 8
Executing test #9 - Reject a handled promise then handle one of the handles but not the other.
Executing test #10 - Reject a handled promise and don't handle either path.
Begin async results:
Uncaught promise rejection
throwing once again
Rejection from test 8
Uncaught promise rejection
Rejection from test 9
Uncaught promise rejection
Rejection from test 10
Uncaught promise rejection
Rejection from test 10
Promise rejection handled
Rejection from test 9
Uncaught promise rejection
Rejection from test 9
53 changes: 44 additions & 9 deletions test/es7/PromiseRejectionTracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let tests = [
let promise = new Promise((resolve, reject)=>{
controller = {resolve, reject};
});
controller.reject(1234);//Should notify rejected
controller.reject("Rejection from test " + index);//Should notify rejected
}
},
{
Expand All @@ -25,7 +25,7 @@ let tests = [
let promise = new Promise((resolve, reject)=>{
controller = {resolve, reject};
}).catch(()=>{});
controller.reject("Should not be seen");//Should NOT notify
controller.reject("Rejection from test " + index);//Should NOT notify
}
},
{
Expand All @@ -36,7 +36,7 @@ let tests = [
let promise = new Promise((resolve, reject)=>{
controller = {resolve, reject};
}).then(()=>{}).catch(()=>{});
controller.reject("Should not be seen");//Should NOT notify
controller.reject("Rejection from test " + index);//Should NOT notify
}
},
{
Expand All @@ -47,7 +47,7 @@ let tests = [
let promise = new Promise((resolve, reject)=>{
controller = {resolve, reject};
});
controller.reject("Should be seen");//Should notify rejected
controller.reject("Rejection from test " + index);//Should notify rejected
promise.catch(()=>{});//Should notify handled
}
},
Expand All @@ -59,7 +59,7 @@ let tests = [
let promise = new Promise((resolve, reject)=>{
controller = {resolve, reject};
});
controller.reject("Should also be seen");//Should notify rejected
controller.reject("Rejection from test " + index);//Should notify rejected
promise.catch(()=>{});//Should notify handled
promise.catch(()=>{});//Should NOT notify
}
Expand All @@ -70,7 +70,7 @@ let tests = [
{
async function aFunction()
{
throw "throwing";
throw ("Rejection from test " + index);
}
aFunction();//Should notify rejected
}
Expand All @@ -81,7 +81,7 @@ let tests = [
{
async function aFunction()
{
throw "throwing again";
throw ("Rejection from test " + index);
}
aFunction().catch(()=>{});//Should notify rejected AND then handled
}
Expand All @@ -92,13 +92,47 @@ let tests = [
{
async function aFunction()
{
throw "throwing once again";//Should notify rejected
throw ("Rejection from test " + index);//Should notify rejected
}
async function bFunction()
{
await aFunction();//Should notify handled
}
bFunction();//Should notify rejected
bFunction();//Should notify rejected in the async section
},
},
{
name: "Reject a handled promise then handle one of the handles but not the other.",
body: function(index)
{
let controller;
let promise = new Promise((resolve, reject) => { controller = {resolve, reject};});
let a = promise.then(() => {});//a is not handled
let b = promise.then(() => {});//b is not handled
controller.reject("Rejection from test " + index);//no notification as handled

let c = a.then(() => {}); //handle a

c.catch(() => {b.then(()=>{})}); // handle c
//b is still not handled -> notify once in async section
//b has an async handler -> will notify handled in async section
//the .then() on b is not handled so will notify in async section
},
},
{
name: "Reject a handled promise and don't handle either path.",
body: function(index)
{
let controller;
let promise = new Promise((resolve, reject) => { controller = {resolve, reject};});
let a = promise.then(() => {});//a is not handled
let b = promise.then(() => {});//b is not handled
controller.reject("Rejection from test " + index);//no notification as handled

let c = a.then(() => {}); //handle a

//b is not handled -> will notify in async section
//c is not handled -> will notify in async section
}
}
];
Expand All @@ -108,3 +142,4 @@ for(let i = 0; i < tests.length; ++i)
WScript.Echo('Executing test #' + (i + 1) + ' - ' + tests[i].name);
tests[i].body(i+1);
}
WScript.Echo("Begin async results:");

0 comments on commit 3e050b8

Please sign in to comment.