mirror of https://github.com/tc39/test262.git
Add tests for try/finally in async functions
This commit is contained in:
parent
be0964c8ff
commit
098f9ca3de
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async() => {
|
||||
try {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("early-reject");
|
||||
});
|
||||
} finally {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("override");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Awaited rejection in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async() => {
|
||||
try {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("early-reject");
|
||||
});
|
||||
} finally {
|
||||
return "override";
|
||||
}
|
||||
};
|
||||
|
||||
f().then(function(value) {
|
||||
assert.sameValue(value, "override", "Return in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async() => {
|
||||
try {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("early-reject");
|
||||
});
|
||||
} finally {
|
||||
throw "override";
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Exception thrown in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer resolving an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async() => {
|
||||
try {
|
||||
return "early-return";
|
||||
} finally {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("override");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Awaited rejection in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer resolving an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async() => {
|
||||
try {
|
||||
return "early-return";
|
||||
} finally {
|
||||
return await new Promise(function(resolve, reject) {
|
||||
resolve("override");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
f().then(function(value) {
|
||||
assert.sameValue(value, "override", "Return in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer resolving an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async() => {
|
||||
try {
|
||||
return "early-return";
|
||||
} finally {
|
||||
throw "override";
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Exception thrown in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async() => {
|
||||
try {
|
||||
throw "early-throw";
|
||||
} finally {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("override");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Awaited rejection in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async() => {
|
||||
try {
|
||||
throw "early-throw";
|
||||
} finally {
|
||||
return await new Promise(function(resolve, reject) {
|
||||
resolve("override");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
f().then(function(value) {
|
||||
assert.sameValue(value, "override", "Return in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async() => {
|
||||
try {
|
||||
throw "early-throw";
|
||||
} finally {
|
||||
throw "override";
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Exception thrown in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async function() {
|
||||
try {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("early-reject");
|
||||
});
|
||||
} finally {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("override");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Awaited rejection in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async function() {
|
||||
try {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("early-reject");
|
||||
});
|
||||
} finally {
|
||||
return "override";
|
||||
}
|
||||
};
|
||||
|
||||
f().then(function(value) {
|
||||
assert.sameValue(value, "override", "Return in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async function() {
|
||||
try {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("early-reject");
|
||||
});
|
||||
} finally {
|
||||
throw "override";
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Exception thrown in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer resolving an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async function() {
|
||||
try {
|
||||
return "early-return";
|
||||
} finally {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("override");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Awaited rejection in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer resolving an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async function() {
|
||||
try {
|
||||
return "early-return";
|
||||
} finally {
|
||||
return await new Promise(function(resolve, reject) {
|
||||
resolve("override");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
f().then(function(value) {
|
||||
assert.sameValue(value, "override", "Return in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer resolving an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async function() {
|
||||
try {
|
||||
return "early-return";
|
||||
} finally {
|
||||
throw "override";
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Exception thrown in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async function() {
|
||||
try {
|
||||
throw "early-throw";
|
||||
} finally {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("override");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Awaited rejection in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async function() {
|
||||
try {
|
||||
throw "early-throw";
|
||||
} finally {
|
||||
return await new Promise(function(resolve, reject) {
|
||||
resolve("override");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
f().then(function(value) {
|
||||
assert.sameValue(value, "override", "Return in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var f = async function() {
|
||||
try {
|
||||
throw "early-throw";
|
||||
} finally {
|
||||
throw "override";
|
||||
}
|
||||
};
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Exception thrown in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
async function f() {
|
||||
try {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("early-reject");
|
||||
});
|
||||
} finally {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("override");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Awaited rejection in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
async function f() {
|
||||
try {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("early-reject");
|
||||
});
|
||||
} finally {
|
||||
return "override";
|
||||
}
|
||||
}
|
||||
|
||||
f().then(function(value) {
|
||||
assert.sameValue(value, "override", "Return in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
async function f() {
|
||||
try {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("early-reject");
|
||||
});
|
||||
} finally {
|
||||
throw "override";
|
||||
}
|
||||
}
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Exception thrown in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer resolving an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
async function f() {
|
||||
try {
|
||||
return "early-return";
|
||||
} finally {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("override");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Awaited rejection in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer resolving an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
async function f() {
|
||||
try {
|
||||
return "early-return";
|
||||
} finally {
|
||||
return await new Promise(function(resolve, reject) {
|
||||
resolve("override");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
f().then(function(value) {
|
||||
assert.sameValue(value, "override", "Return in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer resolving an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
async function f() {
|
||||
try {
|
||||
return "early-return";
|
||||
} finally {
|
||||
throw "override";
|
||||
}
|
||||
}
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Exception thrown in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
async function f() {
|
||||
try {
|
||||
throw "early-throw";
|
||||
} finally {
|
||||
await new Promise(function(resolve, reject) {
|
||||
reject("override");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Awaited rejection in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
async function f() {
|
||||
try {
|
||||
throw "early-throw";
|
||||
} finally {
|
||||
return await new Promise(function(resolve, reject) {
|
||||
resolve("override");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
f().then(function(value) {
|
||||
assert.sameValue(value, "override", "Return in finally block");
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2017 Caitlin Potter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Caitlin Potter <caitp@igalia.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Implementations must defer rejecting an async function's Promise until after
|
||||
all finally blocks have been evaluated.
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
async function f() {
|
||||
try {
|
||||
throw "early-throw";
|
||||
} finally {
|
||||
throw "override";
|
||||
}
|
||||
}
|
||||
|
||||
f().then($DONE, function(value) {
|
||||
assert.sameValue(value, "override", "Exception thrown in finally block");
|
||||
}).then($DONE, $DONE);
|
Loading…
Reference in New Issue