diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-17 15:33:18 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-17 15:33:18 +0000 |
| commit | b885629239d04d2860a8853799a3d335d8bec154 (patch) | |
| tree | 98ee21d5e7ef791948456da4f23e6b5bb496de7f /tests/features | |
| parent | e0cf5aca2a17fae1f89860d5106aa901dde32782 (diff) | |
Add support for mixin method dispatch.
Diffstat (limited to 'tests/features')
| -rw-r--r-- | tests/features/test_mixin_methods.zc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/features/test_mixin_methods.zc b/tests/features/test_mixin_methods.zc new file mode 100644 index 0000000..0932429 --- /dev/null +++ b/tests/features/test_mixin_methods.zc @@ -0,0 +1,33 @@ + +struct Foo { + i: i32; +} + +impl Foo { + fn get_i(self) -> i32 { + return self.i; + } + + fn set_i(self, val: i32) { + self.i = val; + } +} + +struct Bar { + use Foo; + f: f32; +} + +test "test_mixin_methods" { + var b: Bar; + b.i = 42; + b.f = 3.14; + + var val = b.get_i(); + assert(val == 42, "Mixin method get_i() should return 42"); + + b.set_i(100); + assert(b.i == 100, "Mixin method set_i() should update i to 100"); + + "Mixin method dispatch OK"; +} |
