t13115.nim 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. const msg = "This char is `" & '\0' & "` and works fine!"
  2. when defined nim_t13115:
  3. # bug #13115
  4. template fn =
  5. raise newException(Exception, msg)
  6. when defined nim_t13115_static:
  7. static: fn()
  8. fn()
  9. else:
  10. import std/[osproc,strformat,os,strutils]
  11. proc main =
  12. const nim = getCurrentCompilerExe()
  13. const file = currentSourcePath
  14. for b in "c js cpp".split:
  15. # save CI time by avoiding mostly redundant combinations as far as this bug is concerned
  16. var opts = case b
  17. of "c": @["", "-d:nim_t13115_static", "-d:danger", "-d:debug"]
  18. of "js": @["", "-d:nim_t13115_static"]
  19. else: @[""]
  20. for opt in opts:
  21. let cmd = fmt"{nim} r -b:{b} -d:nim_t13115 {opt} --hints:off {file}"
  22. let (outp, exitCode) = execCmdEx(cmd)
  23. when defined windows:
  24. # `\0` not preserved on windows
  25. doAssert "` and works fine!" in outp, cmd & "\n" & msg
  26. else:
  27. doAssert msg in outp, cmd & "\n" & msg
  28. doAssert exitCode == 1
  29. main()