Skip to content

Commit

Permalink
improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Dec 3, 2020
1 parent 0469b85 commit f6893f2
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions tests/exception/t13115.nim
@@ -1,18 +1,23 @@
discard """
exitcode: 1
targets: "c js cpp"
matrix: "-d:debug; -d:release"
outputsub: ''' and works fine! [Exception]'''
disabled: openbsd
"""
#[
disabled: openbsd: just for js
]#
const msg = "This char is `" & '\0' & "` and works fine!"

# bug #13115

template fn =
var msg = "This char is `" & '\0' & "` and works fine!"
raise newException(Exception, msg)
# static: fn() # would also work
fn()
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:
when defined(openbsd):
if b == "js": continue # xxx bug: pending #13115
for opt in ["-d:nim_t13115_static", ""]:
let cmd = fmt"{nim} r -b:{b} -d:nim_t13115 {opt} --hints:off {file}"
let (outp, exitCode) = execCmdEx(cmd)
doAssert msg in outp, cmd & "\n" & msg
doAssert exitCode == 1
main()

0 comments on commit f6893f2

Please sign in to comment.