Files
ladybird/Tests/LibJS/AST/input/class-scope.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

39 lines
749 B
JavaScript

// Class name is visible inside the class body but not outside (for class expressions).
var C = class MyClass {
method() {
return MyClass;
}
};
// Class declaration name IS visible in the enclosing scope.
function uses_class() {
class Foo {
method() {
return new Foo();
}
}
return new Foo();
}
// Computed property keys are evaluated in the class scope.
function computed_key() {
let key = "hello";
class Bar {
[key]() {
return 1;
}
}
return new Bar();
}
// Static methods and fields.
function static_members() {
class Baz {
static x = 1;
static method() {
return Baz.x;
}
}
return Baz.method();
}