Skip to content

Commit da0582d

Browse files
committed
improve test coverage
1 parent 87503f3 commit da0582d

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

tests/exception/t13115.nim

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
discard """
2-
exitcode: 1
3-
targets: "c js cpp"
4-
matrix: "-d:debug; -d:release"
5-
outputsub: ''' and works fine! [Exception]'''
6-
disabled: openbsd
7-
"""
8-
#[
9-
disabled: openbsd: just for js
10-
]#
1+
const msg = "This char is `" & '\0' & "` and works fine!"
112

12-
# bug #13115
13-
14-
template fn =
15-
var msg = "This char is `" & '\0' & "` and works fine!"
16-
raise newException(Exception, msg)
17-
# static: fn() # would also work
18-
fn()
3+
when defined nim_t13115:
4+
# bug #13115
5+
template fn =
6+
raise newException(Exception, msg)
7+
when defined nim_t13115_static:
8+
static: fn()
9+
fn()
10+
else:
11+
import std/[osproc,strformat,os,strutils]
12+
proc main =
13+
const nim = getCurrentCompilerExe()
14+
const file = currentSourcePath
15+
for b in "c js cpp".split:
16+
when defined(openbsd):
17+
if b == "js": continue # xxx bug: pending #13115
18+
for opt in ["-d:nim_t13115_static", ""]:
19+
let cmd = fmt"{nim} r -b:{b} -d:nim_t13115 {opt} --hints:off {file}"
20+
let (outp, exitCode) = execCmdEx(cmd)
21+
doAssert msg in outp, cmd & "\n" & msg
22+
doAssert exitCode == 1
23+
main()

0 commit comments

Comments
 (0)