mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-11 17:37:33 +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.
26 lines
685 B
JavaScript
26 lines
685 B
JavaScript
// Default parameter expressions create their own scope.
|
|
// The default can reference earlier parameters but not body variables.
|
|
function defaults(a, b = a + 1) {
|
|
let c = b;
|
|
return c;
|
|
}
|
|
|
|
// Default parameter with function expression captures the parameter scope.
|
|
function default_with_closure(x, f = () => x) {
|
|
let x2 = f();
|
|
return x2;
|
|
}
|
|
|
|
// Default parameter cannot see body `let` declarations (they're in a
|
|
// nested scope), but `var` declarations ARE visible to the body.
|
|
function complex_defaults(a = 1) {
|
|
var v = a;
|
|
let l = a;
|
|
return v + l;
|
|
}
|
|
|
|
// Destructuring in parameters with defaults.
|
|
function destruct_defaults({ x = 10 } = {}) {
|
|
return x;
|
|
}
|