LibJS: Add tests for exception if assignment LHS is invalid

This commit is contained in:
Barney Wilks 2020-04-10 00:39:33 +01:00 committed by Andreas Kling
parent 56474bab15
commit 4f48fcdb94
Notes: sideshowbarker 2024-07-19 07:45:20 +09:00

View file

@ -0,0 +1,26 @@
try {
try {
Math.abs(-20) = 40;
} catch (e) {
assert(e.name === "ReferenceError");
assert(e.message === "Invalid left-hand side in assignment");
}
try {
512 = 256;
} catch (e) {
assert(e.name === "ReferenceError");
assert(e.message === "Invalid left-hand side in assignment");
}
try {
"hello world" = "another thing?";
} catch (e) {
assert(e.name === "ReferenceError");
assert(e.message === "Invalid left-hand side in assignment");
}
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}