Files
rust_browser/tests/external/js262/fixtures/class-multi-level.js
Zachary D. Rowitsch a41ebfc872
Some checks failed
ci / fast (linux) (push) Failing after 13m32s
Add JavaScript class declarations with prototype chain, extends, super, and instanceof
Implements full class support: prototype-chain-based inheritance on JsObject,
class/extends/super/static/instanceof keywords, parser and VM execution for
class declarations and expressions, super() constructor calls and super.method()
dispatch via dedicated SuperInfo fields (not user-observable properties), and
instanceof operator with prototype chain walking. Includes depth guards,
Box<JsValue> in RuntimeError::Thrown to satisfy clippy result_large_err, and
11 JS262 conformance tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 11:18:11 -05:00

26 lines
532 B
JavaScript

// Multi-level inheritance chain (A -> B -> C).
class A {
constructor(x) { this.x = x; }
getX() { return this.x; }
}
class B extends A {
constructor(x, y) {
super(x);
this.y = y;
}
getY() { return this.y; }
}
class C extends B {
constructor(x, y, z) {
super(x, y);
this.z = z;
}
sum() { return this.getX() + this.getY() + this.z; }
}
var c = new C(1, 2, 3);
console.log(c.sum());
console.log(c instanceof A);
console.log(c instanceof B);
console.log(c instanceof C);