tstempl.nim 428 B

12345678910111213141516171819202122232425
  1. discard """
  2. output: '''global = levB, arg = levA, test = false
  3. levB'''
  4. """
  5. # tstempl.nim
  6. import strutils
  7. type
  8. TLev = enum
  9. levA,
  10. levB
  11. var abclev = levB
  12. template tstLev(abclev: TLev) =
  13. bind tstempl.abclev, `%`
  14. writeLine(stdout, "global = $1, arg = $2, test = $3" % [
  15. $tstempl.abclev, $abclev, $(tstempl.abclev == abclev)])
  16. # evaluates to true, but must be false
  17. tstLev(levA)
  18. writeLine(stdout, $abclev)