mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-11 09:27:00 +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.
28 lines
593 B
JavaScript
28 lines
593 B
JavaScript
// Named function expression: the name is local to the function body,
|
|
// not visible outside.
|
|
var f = function myFunc() {
|
|
return myFunc;
|
|
};
|
|
|
|
// The name binding is immutable and doesn't leak.
|
|
var g = function gName(x) {
|
|
return gName(x - 1);
|
|
};
|
|
|
|
// Named function expression inside another function.
|
|
function outer() {
|
|
var inner = function innerName() {
|
|
return innerName;
|
|
};
|
|
return inner;
|
|
}
|
|
|
|
// Recursive named function expression with closure.
|
|
function make_counter() {
|
|
let count = 0;
|
|
return function tick() {
|
|
count++;
|
|
return tick;
|
|
};
|
|
}
|