1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00
ladybird/Libraries/LibJS/Tests/variable-declaration.js
2020-07-06 23:40:35 +02:00

27 lines
530 B
JavaScript

load("test-common.js");
try {
const constantValue = 1;
assertThrowsError(
() => {
constantValue = 2;
},
{
error: TypeError,
message: "Invalid assignment to const variable",
}
);
assert(constantValue === 1);
// Make sure we can define new constants in inner scopes.
const constantValue2 = 1;
do {
const constantValue2 = 2;
assert(constantValue2 === 2);
} while (false);
assert(constantValue2 === 1);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}