diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/constr/tnocompiletimefunc.nim | 14 | ||||
-rw-r--r-- | tests/constr/tnocompiletimefunclambda.nim | 6 | ||||
-rw-r--r-- | tests/converter/tconverter.nim | 11 | ||||
-rw-r--r-- | tests/generics/tnullary_generics.nim | 26 | ||||
-rw-r--r-- | tests/statictypes/tstatictypes.nim | 6 |
5 files changed, 62 insertions, 1 deletions
diff --git a/tests/constr/tnocompiletimefunc.nim b/tests/constr/tnocompiletimefunc.nim new file mode 100644 index 000000000..a95648c0f --- /dev/null +++ b/tests/constr/tnocompiletimefunc.nim @@ -0,0 +1,14 @@ +discard """ + errormsg: "request to generate code for .compileTime proc: foo" +""" + +# ensure compileTime funcs can't be called from runtime + +func foo(a: int): int {.compileTime.} = + a * a + +proc doAThing(): int = + for i in 0..2: + result += foo(i) + +echo doAThing() diff --git a/tests/constr/tnocompiletimefunclambda.nim b/tests/constr/tnocompiletimefunclambda.nim new file mode 100644 index 000000000..d134eea40 --- /dev/null +++ b/tests/constr/tnocompiletimefunclambda.nim @@ -0,0 +1,6 @@ +discard """ + errormsg: "request to generate code for .compileTime proc: :anonymous" +""" + +let a = func(a: varargs[int]) {.compileTime, closure.} = + discard a[0] \ No newline at end of file diff --git a/tests/converter/tconverter.nim b/tests/converter/tconverter.nim new file mode 100644 index 000000000..0bf067c55 --- /dev/null +++ b/tests/converter/tconverter.nim @@ -0,0 +1,11 @@ +discard """ + output: '''fooo fooo''' +""" + +converter intToString[T](i: T): string = "fooo" + +let + foo: string = 1 + bar: string = intToString(2) + +echo foo, " ", bar \ No newline at end of file diff --git a/tests/generics/tnullary_generics.nim b/tests/generics/tnullary_generics.nim new file mode 100644 index 000000000..c79558ee3 --- /dev/null +++ b/tests/generics/tnullary_generics.nim @@ -0,0 +1,26 @@ +discard """ + nimout: ''' +hah +hey +hey +hah +''' +""" + +# non-generic +proc foo(s: string) = + static: echo "hah" + echo s + +static: echo "hey" + +foo("hoo") + +# nullary generic +proc bar[](s: string) = + static: echo "hah" + echo s + +static: echo "hey" + +bar("hoo") diff --git a/tests/statictypes/tstatictypes.nim b/tests/statictypes/tstatictypes.nim index 41c060138..a76276d2c 100644 --- a/tests/statictypes/tstatictypes.nim +++ b/tests/statictypes/tstatictypes.nim @@ -2,6 +2,8 @@ discard """ nimout: ''' staticAlialProc instantiated with 358 staticAlialProc instantiated with 368 +0: Foo +1: Bar ''' output: ''' 16 @@ -289,8 +291,10 @@ macro fooParam(x: static array[2, string]): untyped = echo i, ": ", val macro barParam(x: static Table[int, string]): untyped = - for i, val in x: + let barParamInsides = proc(i: int, val: string): NimNode = echo i, ": ", val + for i, val in x: + discard barParamInsides(i, val) fooM() barM() |