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.
36 lines
659 B
JavaScript
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;
|
|
}
|