mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-12 09:56:45 +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.
33 lines
774 B
JavaScript
33 lines
774 B
JavaScript
// eval in the middle of a deep nesting chain.
|
|
// Functions ABOVE the eval should keep their locals.
|
|
// The function WITH eval loses locals.
|
|
// Functions BELOW don't directly lose locals, but references to
|
|
// variables in the eval-poisoned scope become [in-eval-scope].
|
|
function clean_outer() {
|
|
let a = 1;
|
|
function middle() {
|
|
let b = 2;
|
|
eval("");
|
|
function inner() {
|
|
let c = 3;
|
|
return a + b + c;
|
|
}
|
|
return inner();
|
|
}
|
|
return middle();
|
|
}
|
|
|
|
// eval at the top level of a nested chain.
|
|
function eval_at_top() {
|
|
let x = 1;
|
|
eval("");
|
|
function level1() {
|
|
let y = 2;
|
|
function level2() {
|
|
return x + y;
|
|
}
|
|
return level2();
|
|
}
|
|
return level1();
|
|
}
|