mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 01:51:03 +09:00
LibJS: Add tests for exception if assignment LHS is invalid
This commit is contained in:
parent
56474bab15
commit
4f48fcdb94
Notes:
sideshowbarker
2024-07-19 07:45:20 +09:00
Author: https://github.com/DontBelieveMe
Commit: 4f48fcdb94
Pull-request: https://github.com/SerenityOS/serenity/pull/1722
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