1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 15:44:57 +00:00

LibJS: Add assertThrowsError() test function

This commit is contained in:
Linus Groh 2020-04-19 23:01:45 +01:00 committed by Andreas Kling
parent c5730ed6a3
commit 0718f216af
10 changed files with 112 additions and 118 deletions

View file

@ -3,14 +3,13 @@ load("test-common.js");
try {
const constantValue = 1;
try {
assertThrowsError(() => {
constantValue = 2;
assertNotReached();
} catch (e) {
assert(e.name === "TypeError");
assert(e.message === "Assignment to constant variable");
assert(constantValue === 1);
}
}, {
error: TypeError,
message: "Assignment to constant variable"
});
assert(constantValue === 1);
// Make sure we can define new constants in inner scopes.
const constantValue2 = 1;