Make use of used in unittest (#5410)
This commit is contained in:
parent
16aafddee5
commit
f250c30b9d
3 changed files with 45 additions and 14 deletions
|
|
@ -1,13 +1,35 @@
|
|||
discard """
|
||||
output: '''8'''
|
||||
nimout: '''
|
||||
compile start
|
||||
tused.nim(15, 8) Hint: 'tused.echoSub(a: int, b: int)' is declared but not used [XDeclaredButNotUsed]
|
||||
compile end'''
|
||||
output: "8\n8"
|
||||
"""
|
||||
|
||||
template implementArithOps(T) =
|
||||
static:
|
||||
echo "compile start"
|
||||
|
||||
template implementArithOpsOld(T) =
|
||||
proc echoAdd(a, b: T) =
|
||||
echo a + b
|
||||
proc echoSub(a, b: T) =
|
||||
echo a - b
|
||||
|
||||
template implementArithOpsNew(T) =
|
||||
proc echoAdd(a, b: T) {.used.} =
|
||||
echo a + b
|
||||
proc echoSub(a, b: T) {.used.} =
|
||||
echo a - b
|
||||
|
||||
# no warning produced for the unused 'echoSub'
|
||||
implementArithOps(int)
|
||||
echoAdd 3, 5
|
||||
block:
|
||||
# should produce warning for the unused 'echoSub'
|
||||
implementArithOpsOld(int)
|
||||
echoAdd 3, 5
|
||||
|
||||
block:
|
||||
# no warning produced for the unused 'echoSub'
|
||||
implementArithOpsNew(int)
|
||||
echoAdd 3, 5
|
||||
|
||||
static:
|
||||
echo "compile end"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue