1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 08:35:09 +00:00

LibJS: Use assertNotReached() in tests

This commit is contained in:
Linus Groh 2020-04-13 14:11:09 +01:00 committed by Andreas Kling
parent 92a9fe0e49
commit b9415dc0e9
8 changed files with 36 additions and 27 deletions

View file

@ -1,23 +1,22 @@
try {
const ConstantValue = 1;
const constantValue = 1;
try {
ConstantValue = 2;
} catch (e) {
constantValue = 2;
assertNotReached();
} catch (e) {
assert(e.name === "TypeError");
assert(e.message === "Assignment to constant variable");
assert(ConstantValue === 1);
assert(constantValue === 1);
}
// Make sure we can define new constants in inner scopes.
//
const ConstantValue2 = 1;
do
{
const ConstantValue2 = 2;
}
while (false)
const constantValue2 = 1;
do {
const constantValue2 = 2;
assert(constantValue2 === 2);
} while (false);
assert(constantValue2 === 1);
console.log("PASS");
} catch (e) {