privateAccess now works with ref | ptr (#17760)

This commit is contained in:
Timothee Cour 2021-04-18 15:15:58 -07:00 • committed by GitHub
commit 0a10af5a2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 149 additions and 15 deletions

View file

@ -1,5 +1,6 @@
import std/private/miscdollars
from std/os import getEnv
import std/[macros, genasts]
template flakyAssert*(cond: untyped, msg = "", notifySuccess = true) =
## API to deal with flaky or failing tests. This avoids disabling entire tests
@ -89,3 +90,22 @@ template reject*(a) =
template disableVm*(body) =
when nimvm: discard
else: body
template typeOrVoid[T](a: T): type =
# FACTOR with asyncjs.typeOrVoid
T
macro assertAll*(body) =
## works in VM, unlike `check`, `require`
runnableExamples:
assertAll:
1+1 == 2
var a = @[1, 2] # statements work
a.len == 2
# remove this once these support VM, pending #10129 (closed but not yet fixed)
result = newStmtList()
for a in body:
result.add genAst(a) do:
# better than: `when not compiles(typeof(a)):`
when typeOrVoid(a) is void: a
else: doAssert a