mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-12 01:46:46 +02:00
Add 39 test cases exercising AST dump output and scope analysis. Tests cover local/global identifier marking, eval/with poisoning, destructuring, closures, hoisting, classes, generators, and more.
40 lines
665 B
JavaScript
40 lines
665 B
JavaScript
// Assignment targets: the LHS of assignments should still resolve
|
|
// as local or global correctly.
|
|
var g = 1;
|
|
|
|
function assign_local() {
|
|
let x = 1;
|
|
x = 2;
|
|
x += 3;
|
|
return x;
|
|
}
|
|
|
|
function assign_global() {
|
|
g = 2;
|
|
g += 3;
|
|
return g;
|
|
}
|
|
|
|
// Destructuring assignment (not declaration).
|
|
function destruct_assign() {
|
|
let a, b;
|
|
[a, b] = [1, 2];
|
|
return a + b;
|
|
}
|
|
|
|
// Assignment to a variable not declared anywhere (implicit global).
|
|
function assign_undeclared() {
|
|
undeclared = 1;
|
|
return undeclared;
|
|
}
|
|
|
|
// Increment/decrement targets.
|
|
function update_targets() {
|
|
let x = 0;
|
|
x++;
|
|
++x;
|
|
x--;
|
|
--x;
|
|
return x;
|
|
}
|