File: t13115.nim

package info (click to toggle)
nim 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,911,644 kB
  • sloc: sh: 24,603; ansic: 1,761; python: 1,492; makefile: 1,013; sql: 298; asm: 141; xml: 13
file content (31 lines) | stat: -rw-r--r-- 1,026 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const msg = "This char is `" & '\0' & "` and works fine!"

when defined nim_t13115:
  # bug #13115
  template fn =
    raise newException(Exception, msg)
  when defined nim_t13115_static:
    static: fn()
  fn()
else:
  import std/[osproc,strformat,os,strutils]
  proc main =
    const nim = getCurrentCompilerExe()
    const file = currentSourcePath
    for b in "c js cpp".split:
      # save CI time by avoiding mostly redundant combinations as far as this bug is concerned
      var opts = case b
        of "c": @["", "-d:nim_t13115_static", "-d:danger", "-d:debug"]
        of "js": @["", "-d:nim_t13115_static"]
        else: @[""]

      for opt in opts:
        let cmd = fmt"{nim} r -b:{b} -d:nim_t13115 {opt} --hints:off {file}"
        let (outp, exitCode) = execCmdEx(cmd)
        when defined windows:
          # `\0` not preserved on windows
          doAssert "` and works fine!" in outp, cmd & "\n" & msg
        else:
          doAssert msg in outp, cmd & "\n" & msg
        doAssert exitCode == 1
  main()