Bob/tests/test_class_super.bob
Bobby Lucero 3138f6fb92 Various changes, again. Updated extension. Added classes, super, this, polymorphism.
Runtime: add method dispatch for array/string/dict/number (.len, .push, .pop, .keys, .values, .has, .toInt)
Stdlib: delete global len/push/pop/keys/values/has
Tests/docs/examples: migrate to method style; add tests/test_builtin_methods_style.bob
All tests pass
Breaking: global len/push/pop/keys/values/has removed; use methods instead
Parser/AST: add class/extends/extension/super, field initializers
Runtime: shared methods with this injection; classParents/classTemplates; super resolution; ownerClass/currentClass; extension lookup order
Builtins: method dispatch for array/string/dict/number (.len/.push/.pop/.keys/.values/.has/.toInt); remove global forms
Tests/docs/examples: add/refresh for classes, inheritance, super, polymorphism; migrate to method style; all tests pass
VS Code extension: update grammar/readme/snippets for new features
2025-08-10 22:44:46 -04:00

22 lines
416 B
Plaintext

print("\n--- Test: super calls ---");
class A { }
class B extends A { }
class C extends B { }
extension A { func v() { return 1; } }
extension B { func v() { return super.v() + 1; } }
extension C { func v() { return super.v() + 1; } }
var a = A();
var b = B();
var c = C();
assert(a.v() == 1, "A.v");
assert(b.v() == 2, "B.v via super");
assert(c.v() == 3, "C.v via super chain");
print("super calls: PASS");