From ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Mon, 12 Oct 2026 08:46:23 +0330 Subject: a --- tests/programs/typedmethods.zc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/programs/typedmethods.zc (limited to 'tests/programs/typedmethods.zc') diff --git a/tests/programs/typedmethods.zc b/tests/programs/typedmethods.zc new file mode 100644 index 0000000..facd9f1 --- /dev/null +++ b/tests/programs/typedmethods.zc @@ -0,0 +1,16 @@ +// struct methods declare a return type and typed parameters, like functions do +struct Str { + int len; + static int size(int s) { return s * 2; } + int plus(int k) { return this.len + k; } + static fn none() { return 5; } +} +int main() { + Str a; + a.len = 9; + put_n(Str.size(7)); put_c(32); + put_n(Str.none()); put_c(32); + put_n(a.plus(4)); + put_c(10); + return 0; +} -- cgit v1.2.3