From 3ceb223089632d8cafd296d8f9a70ead1fa3906f Mon Sep 17 00:00:00 2001 From: demotomohiro Date: Wed, 29 Oct 2025 19:08:08 +0900 Subject: [PATCH] adds more procedure test code --- tests/icnif/testcode/modtestprocs.nim | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/icnif/testcode/modtestprocs.nim b/tests/icnif/testcode/modtestprocs.nim index 6f2f0eab00..f17966586b 100644 --- a/tests/icnif/testcode/modtestprocs.nim +++ b/tests/icnif/testcode/modtestprocs.nim @@ -7,3 +7,41 @@ proc baz(a: bool; b: string; c: int): float = result = 0.0 else: result = 1.0 + +proc forwardDecl() +proc forwardDecl() = + foo() + +forwardDecl() + +proc forwardDecl2*(): int +proc forwardDecl2*(): int = bar(1) + +discard forwardDecl2() + +proc forwardDecl3(x, y: int): int +proc forwardDecl3(x, y: int): int = x - y + +discard forwardDecl3(3, 2) + +func func1(): int = 123 +discard func1() +func func2(x: int): int = x +func func3*(x, y: bool): bool = x and y + +proc withDefaultValue(x = 1) = echo x +withDefaultValue() +withDefaultValue(2) +withDefaultValue(x = 3) + +proc withDefaultValue2(x = "foo"; y = true) = echo x, y +withDefaultValue2() +withDefaultValue2("bar") +withDefaultValue2(x = "baz", y = false) + +proc varParam(x: var int) = x = 10 +var x = 0 +varParam(x) + +proc varRet(x: var int): var int = x +varRet(x) = 100