From cda92048ba9408d356e0023543fcfb45ea357da8 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Tue, 18 Feb 2014 02:46:14 +0200 Subject: fix some trivial errors in the test suite and some more regressions caused by tyTypeDesc[tyNone] --- tests/generics/tgenericlambda.nim | 10 +++++- tests/global/globalaux.nim | 15 +++++++++ tests/global/globalaux2.nim | 4 +++ tests/module/trecinca.nim | 2 +- tests/module/trecincb.nim | 2 +- tests/stdlib/tircbot.nim | 2 +- tests/sunset.tmpl | 68 --------------------------------------- tests/template/sunset.tmpl | 68 +++++++++++++++++++++++++++++++++++++++ tests/typerel/tvoid.nim | 6 +++- 9 files changed, 104 insertions(+), 73 deletions(-) create mode 100644 tests/global/globalaux.nim create mode 100644 tests/global/globalaux2.nim delete mode 100644 tests/sunset.tmpl create mode 100644 tests/template/sunset.tmpl (limited to 'tests') diff --git a/tests/generics/tgenericlambda.nim b/tests/generics/tgenericlambda.nim index a71c592c5..f7aafe1d9 100644 --- a/tests/generics/tgenericlambda.nim +++ b/tests/generics/tgenericlambda.nim @@ -1,5 +1,5 @@ discard """ - output: "10\n10" + output: "10\n10\n1\n2\n3" """ proc test(x: proc (a, b: int): int) = @@ -8,3 +8,11 @@ proc test(x: proc (a, b: int): int) = test(proc (a, b): auto = a + b) test do (a, b) -> auto: a + b + +proc foreach[T](s: seq[T], body: proc(x: T)) = + for e in s: + body(e) + +foreach(@[1,2,3]) do (x): + echo x + diff --git a/tests/global/globalaux.nim b/tests/global/globalaux.nim new file mode 100644 index 000000000..5f6f72721 --- /dev/null +++ b/tests/global/globalaux.nim @@ -0,0 +1,15 @@ +type + TObj*[T] = object + val*: T + +var + totalGlobals* = 0 + +proc makeObj[T](x: T): TObj[T] = + totalGlobals += 1 + result.val = x + +proc globalInstance*[T]: var TObj[T] = + var g {.global.} = when T is int: makeObj(10) else: makeObj("hello") + result = g + diff --git a/tests/global/globalaux2.nim b/tests/global/globalaux2.nim new file mode 100644 index 000000000..6c77f1f48 --- /dev/null +++ b/tests/global/globalaux2.nim @@ -0,0 +1,4 @@ +import globalaux + +echo "in globalaux2: ", globalInstance[int]().val + diff --git a/tests/module/trecinca.nim b/tests/module/trecinca.nim index 73a0ec937..62d37783c 100644 --- a/tests/module/trecinca.nim +++ b/tests/module/trecinca.nim @@ -1,7 +1,7 @@ discard """ file: "tests/reject/trecincb.nim" line: 9 - errormsg: "recursive dependency: 'tests/reject/trecincb.nim'" + errormsg: "recursive dependency: 'tests/module/trecincb.nim'" """ # Test recursive includes diff --git a/tests/module/trecincb.nim b/tests/module/trecincb.nim index 9dd7d51de..a2934052f 100644 --- a/tests/module/trecincb.nim +++ b/tests/module/trecincb.nim @@ -1,7 +1,7 @@ discard """ file: "trecincb.nim" line: 9 - errormsg: "recursive dependency: 'tests/reject/trecincb.nim'" + errormsg: "recursive dependency: 'tests/module/trecincb.nim'" """ # Test recursive includes diff --git a/tests/stdlib/tircbot.nim b/tests/stdlib/tircbot.nim index 71ecb0b48..f0417c7ac 100644 --- a/tests/stdlib/tircbot.nim +++ b/tests/stdlib/tircbot.nim @@ -183,7 +183,7 @@ type channel: string timestamp: TTime case kind*: TSeenType - of PSeenJoin: discard + of PSeenJoin: nil of PSeenPart, PSeenQuit, PSeenMsg: msg: string of PSeenNick: diff --git a/tests/sunset.tmpl b/tests/sunset.tmpl deleted file mode 100644 index 6475bac4e..000000000 --- a/tests/sunset.tmpl +++ /dev/null @@ -1,68 +0,0 @@ -#! stdtmpl -#proc sunsetTemplate*(current, ticker, content: string, -# tabs: openarray[array[0..1, string]]): string = -# result = "" - - - - - Nimrod Programming System - - - - - -
- - -
- -
-
-
-

latest news

-
-
- $ticker -
-
-
-
-

additional links

-
- -
-
-
- $content -
-
- -
- - diff --git a/tests/template/sunset.tmpl b/tests/template/sunset.tmpl new file mode 100644 index 000000000..6475bac4e --- /dev/null +++ b/tests/template/sunset.tmpl @@ -0,0 +1,68 @@ +#! stdtmpl +#proc sunsetTemplate*(current, ticker, content: string, +# tabs: openarray[array[0..1, string]]): string = +# result = "" + + + + + Nimrod Programming System + + + + + +
+ + +
+ +
+
+
+

latest news

+
+
+ $ticker +
+
+
+
+

additional links

+
+ +
+
+
+ $content +
+
+ +
+ + diff --git a/tests/typerel/tvoid.nim b/tests/typerel/tvoid.nim index bb569e7f8..d31936217 100644 --- a/tests/typerel/tvoid.nim +++ b/tests/typerel/tvoid.nim @@ -1,5 +1,9 @@ discard """ - output: "he, no return type;abc a string" + output: '''12 +empty +he, no return type; +abc a string +ha''' """ proc ReturnT[T](x: T): T = -- cgit 1.4.1-2-gfad0