Files
ladybird/Tests/LibJS/AST/input/function-declaration-hoisting.js
Andreas Kling f7c961136f Tests/LibJS: Add AST dump test cases
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.
2026-02-10 02:05:20 +01:00

36 lines
659 B
JavaScript

// Function declarations are hoisted to the top of their scope.
function uses_hoisted() {
hoisted();
function hoisted() {
return 1;
}
}
// Function declaration in a block (annex B semantics).
function block_function() {
{
function inner() {
return 1;
}
inner();
}
}
// Two function declarations with the same name: last one wins.
function duplicate_decls() {
function dup() {
return 1;
}
function dup() {
return 2;
}
return dup();
}
// Function declaration vs var with same name.
function func_vs_var() {
var x = 1;
function x() {}
return x;
}