make the 'canimport' template work
This commit is contained in:
parent
077ff83b6e
commit
eeea000582
2 changed files with 27 additions and 1 deletions
19
tests/modules/tcanimport.nim
Normal file
19
tests/modules/tcanimport.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
discard """
|
||||
output: '''ABC
|
||||
nope'''
|
||||
"""
|
||||
|
||||
template canImport(x): bool =
|
||||
compiles:
|
||||
import x
|
||||
|
||||
when canImport(strutils):
|
||||
import strutils
|
||||
echo "abc".toUpperAscii
|
||||
else:
|
||||
echo "meh"
|
||||
|
||||
when canImport(none):
|
||||
echo "what"
|
||||
else:
|
||||
echo "nope"
|
||||
Loading…
Add table
Add a link
Reference in a new issue