mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00: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: https://github.com/SerenityOS/serenity/commit/4f48fcdb94d 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
Reference in a new issue