fixes #21195; std/assertions continue to use sysFatal when nimPreviewSlimSystem is not defined (#21196)

* fixes #21195; `std/assertions` continue to use `sysFatal`

* try includes

* make `std/assertions` self-contained

* fixes tests

* fixes tests
This commit is contained in:
ringabout 2022-12-30 03:15:08 +08:00 • committed by GitHub
commit ebd1c678be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 30 deletions

View file

@ -0,0 +1,15 @@
# panicoverride.nim
proc printf(fmt: cstring) {.varargs, importc, header:"stdio.h".}
proc exit(code: cint) {.importc, header:"stdlib.h".}
{.push stack_trace: off, profiler:off.}
proc rawoutput(s: cstring) =
printf("RAW: %s\n", s)
proc panic(s: cstring) {.noreturn.} =
printf("PANIC: %s\n", s)
exit(0)
{.pop.}

6
tests/assert/t21195.nim Normal file
View file

@ -0,0 +1,6 @@
discard """
matrix: "--verbosity:0 --os:standalone --mm:none"
"""
# bug #21195
var n = 11
assert(n == 12)

View file

@ -1,8 +1,8 @@
discard """
cmd: "nim $target $options --excessiveStackTrace:off $file"
cmd: "nim $target $options -d:nimPreviewSlimSystem --excessiveStackTrace:off $file"
output: '''true'''
"""
import std/assertions
const expected = """
tassert_c.nim(35) tassert_c
tassert_c.nim(34) foo