Files
ladybird/Tests/LibJS/AST/input/multiple-binding-forms.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

41 lines
860 B
JavaScript

// Comprehensive test of different binding forms and their local/global status.
// let, const, var at top level are all global.
let top_let = 1;
const top_const = 2;
var top_var = 3;
function all_binding_types() {
// These should all be local.
let a = 1;
const b = 2;
var c = 3;
return a + b + c;
}
// for-loop heads create locals.
function for_binding_forms() {
for (let i = 0; i < 1; i++) {}
for (const x of [1]) {
x;
}
for (var j = 0; j < 1; j++) {}
j;
}
// Destructuring bindings in all forms.
function destructuring_bindings() {
let [a, b] = [1, 2];
const { c, d } = { c: 3, d: 4 };
var [e, ...f] = [5, 6, 7];
return a + b + c + d + e + f[0];
}
// Multiple declarators in one statement.
function multi_declarator() {
let x = 1,
y = 2,
z = 3;
return x + y + z;
}