2020-04-13 10:31:13 -07:00
|
|
|
load("test-common.js");
|
|
|
|
|
2020-04-12 15:50:49 -07:00
|
|
|
try {
|
|
|
|
|
2020-04-13 14:11:09 +01:00
|
|
|
const constantValue = 1;
|
2020-04-19 23:01:45 +01:00
|
|
|
assertThrowsError(() => {
|
2020-04-13 14:11:09 +01:00
|
|
|
constantValue = 2;
|
2020-04-19 23:01:45 +01:00
|
|
|
}, {
|
|
|
|
error: TypeError,
|
2020-06-09 22:48:01 -07:00
|
|
|
message: "Invalid assignment to const variable"
|
2020-04-19 23:01:45 +01:00
|
|
|
});
|
|
|
|
assert(constantValue === 1);
|
2020-04-12 15:50:49 -07:00
|
|
|
|
|
|
|
// Make sure we can define new constants in inner scopes.
|
2020-04-13 14:11:09 +01:00
|
|
|
const constantValue2 = 1;
|
|
|
|
do {
|
|
|
|
const constantValue2 = 2;
|
|
|
|
assert(constantValue2 === 2);
|
|
|
|
} while (false);
|
|
|
|
assert(constantValue2 === 1);
|
2020-04-12 15:50:49 -07:00
|
|
|
|
|
|
|
console.log("PASS");
|
|
|
|
} catch (e) {
|
|
|
|
console.log("FAIL: " + e);
|
|
|
|
}
|