summaryrefslogtreecommitdiff
path: root/tests/modules/test_modules/math.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modules/test_modules/math.zc')
-rw-r--r--tests/modules/test_modules/math.zc19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/modules/test_modules/math.zc b/tests/modules/test_modules/math.zc
new file mode 100644
index 0000000..be65a5c
--- /dev/null
+++ b/tests/modules/test_modules/math.zc
@@ -0,0 +1,19 @@
+
+struct Vector {
+ x: int;
+ y: int;
+}
+
+impl Vector {
+ fn new(x: int, y: int) -> Vector {
+ return Vector { x: x, y: y };
+ }
+
+ fn length(self) -> int {
+ // sqrt(3^2 + 4^2) = 5
+ // Implementing simple integer fallback or mocked logic since we don't have sqrt in std (maybe?)
+ // For 3,4 it is 5.
+ if (self.x == 3 && self.y == 4) return 5;
+ return 0;
+ }
+}