mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 09:27:35 +00:00
LibJS: Add tests for exception if assignment LHS is invalid
This commit is contained in:
parent
56474bab15
commit
4f48fcdb94
1 changed files with 26 additions and 0 deletions
26
Libraries/LibJS/Tests/invalid-lhs-in-assignment.js
Normal file
26
Libraries/LibJS/Tests/invalid-lhs-in-assignment.js
Normal 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);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue