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:
parent
c5730ed6a3
commit
0718f216af
10 changed files with 112 additions and 118 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue