Skip to content

Commit 70168c6

Browse files
committed
add tests
1 parent 1a30591 commit 70168c6

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

tests/stdlib/trepr.nim

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ discard """
55

66
# if excessive, could remove 'cpp' from targets
77

8-
from strutils import endsWith, contains
8+
from strutils import endsWith, contains, strip
99
from std/macros import newLit
10-
macro deb(a): string = newLit a.repr
10+
11+
macro deb(a): string = newLit a.repr.strip
1112

1213
template main() =
1314
doAssert repr({3,5}) == "{3, 5}"
@@ -67,17 +68,16 @@ template main() =
6768
else:
6869
doAssert reprOpenarray(arr) == "[1, 2, 3]"
6970

70-
block: # bug #17292
71+
block: # bug #17292 repr with `do`
7172
template foo(a, b, c, d) = discard
7273
block:
7374
let a = deb:
7475
foo(1, 2, 3, 4)
75-
doAssert a == "\nfoo(1, 2, 3, 4)"
76+
doAssert a == "foo(1, 2, 3, 4)"
7677
block:
7778
let a = deb:
7879
foo(1, 2, 3): 4
7980
doAssert a == """
80-
8181
foo(1, 2, 3):
8282
4"""
8383

@@ -86,7 +86,6 @@ foo(1, 2, 3):
8686
foo(1, 2): 3
8787
do: 4
8888
doAssert a == """
89-
9089
foo(1, 2):
9190
3
9291
do:
@@ -98,7 +97,6 @@ do:
9897
do: 3
9998
do: 4
10099
doAssert a == """
101-
102100
foo(1):
103101
3
104102
do:
@@ -118,7 +116,6 @@ do:
118116
4
119117

120118
doAssert a == """
121-
122119
foo(1):
123120
3
124121
do:
@@ -135,7 +132,6 @@ do:
135132
do: 3
136133
do: 4
137134
doAssert a == """
138-
139135
foo:
140136
1
141137
do:
@@ -145,5 +141,12 @@ do:
145141
do:
146142
4"""
147143

144+
block: # bug #17292 repr with `(discard)` (`discard` would result in illegal code)
145+
let a = deb:
146+
let f {.inject.} = () => (discard)
147+
doAssert a == """
148+
let f {.inject.} = () =>
149+
(discard )"""
150+
148151
static: main()
149152
main()

0 commit comments

Comments
 (0)