From 3b5dc43cfba74117e1c29bde496906cc52d2e4e5 Mon Sep 17 00:00:00 2001 From: nitrix Date: Sat, 7 Mar 2020 01:22:38 +0100 Subject: [PATCH] implement test functions --- src/test/test.k | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/test/test.k b/src/test/test.k index 539f333..0f98231 100644 --- a/src/test/test.k +++ b/src/test/test.k @@ -415,4 +415,68 @@ function mixdiv(x: float, y: int): float { return x / y; } +struct testStruct { + a: int; + b: bool; + c: int; +} + +struct testStructRec { + a: int; + b: testStructRec; +} + +function getTestStruct(a: int, b: bool, c: int): testStruct { + return create testStruct(a, b, c); +} + +function getTestStructRec(a: int, b: testStructRec): testStructRec { + return create testStructRec(a, b); +} + +function getStructFieldA(t: testStruct): int { + return t.a; +} + +function getStructFieldB(t: testStruct): bool { + return t.b; +} + +function getStructFieldC(t: testStruct): int { + return t.c; +} + +function setStructFieldA(t: testStruct, a: int): testStruct { + t.a = a; + return t; +} + +function setStructFieldB(t: testStruct, b: bool): testStruct { + t.b = b; + return t; +} + +function setStructFieldC(t: testStruct, c: int): testStruct { + t.c = c; + return t; +} + +function getStructFieldRecA(t: testStructRec): int { + return t.a; +} + +function getStructFieldRecB(t: testStructRec): testStructRec { + return t.b; +} + +function setStructFieldRecA(t: testStructRec, a: int): testStructRec { + t.a = a; + return t; +} + +function setStructFieldRecB(t: testStructRec, b: testStructRec): testStructRec { + t.b = b; + return t; +} + add(1, 1);