Merge branch 'devel' of github.com:nim-lang/Nim into devel
This commit is contained in:
commit
090d22c715
18 changed files with 98 additions and 27 deletions
|
|
@ -1,2 +0,0 @@
|
|||
when defined(upcoming):
|
||||
patchFile("stdlib", "asyncdispatch", "$lib/upcoming/asyncdispatch")
|
||||
30
tests/async/tjsandnativeasync.nim
Normal file
30
tests/async/tjsandnativeasync.nim
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
discard """
|
||||
output: '''hi
|
||||
bye'''
|
||||
"""
|
||||
|
||||
import async, times
|
||||
when defined(js):
|
||||
proc sleepAsync(t: int): Future[void] =
|
||||
var promise = newPromise() do(resolve: proc()):
|
||||
{.emit: """
|
||||
setTimeout(function(){
|
||||
`resolve`();
|
||||
}, `t`);
|
||||
""".}
|
||||
result = promise
|
||||
else:
|
||||
from asyncdispatch import sleepAsync, waitFor
|
||||
|
||||
proc foo() {.async.} =
|
||||
echo "hi"
|
||||
var s = epochTime()
|
||||
await sleepAsync(500)
|
||||
var e = epochTime()
|
||||
doAssert(e - s > 0.1)
|
||||
echo "bye"
|
||||
|
||||
when defined(js):
|
||||
discard foo()
|
||||
else:
|
||||
waitFor foo()
|
||||
|
|
@ -13,11 +13,10 @@ proc MakeObj(): TTestObj =
|
|||
result.x = "Hello"
|
||||
|
||||
for i in 1 .. 1_000_000:
|
||||
when defined(gcMarkAndSweep):
|
||||
when defined(gcMarkAndSweep) or defined(boehmgc):
|
||||
GC_fullcollect()
|
||||
var obj = MakeObj()
|
||||
if getOccupiedMem() > 300_000: quit("still a leak!")
|
||||
# echo GC_getstatistics()
|
||||
|
||||
echo "no leak: ", getOccupiedMem()
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ proc MakeObj(): TTestObj =
|
|||
|
||||
proc inProc() =
|
||||
for i in 1 .. 1_000_000:
|
||||
when defined(gcMarkAndSweep):
|
||||
when defined(gcMarkAndSweep) or defined(boehmgc):
|
||||
GC_fullcollect()
|
||||
var obj: TTestObj
|
||||
obj = MakeObj()
|
||||
|
|
@ -24,5 +24,3 @@ proc inProc() =
|
|||
|
||||
inProc()
|
||||
echo "no leak: ", getOccupiedMem()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ proc newPlus(a, b: ref TExpr): ref TPlusExpr =
|
|||
result.b = b
|
||||
result.op2 = $getOccupiedMem()
|
||||
|
||||
const Limit = when compileOption("gc", "markAndSweep"): 5*1024*1024 else: 500_000
|
||||
const Limit = when compileOption("gc", "markAndSweep") or compileOption("gc", "boehm"): 5*1024*1024 else: 500_000
|
||||
|
||||
for i in 0..100_000:
|
||||
var s: array[0..11, ref TExpr]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
discard """
|
||||
disabled: true
|
||||
output: '''
|
||||
x
|
||||
e
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ block: # A bit more advanced case
|
|||
d {.alternativeKey("df", 5).}: float
|
||||
e {.alternativeKey(V = 5).}: seq[bool]
|
||||
|
||||
|
||||
proc myproc(x: int, s: string) {.alternativeKey(V = 5), serializationKey"myprocSS".} =
|
||||
echo x, s
|
||||
|
||||
|
||||
var s: MySerializable
|
||||
|
||||
const aDefVal = s.a.getCustomPragmaVal(defaultValue)
|
||||
|
|
@ -41,3 +46,8 @@ block: # A bit more advanced case
|
|||
|
||||
const cSerKey = getCustomPragmaVal(s.field.c, serializationKey)
|
||||
static: assert(cSerKey == "cc")
|
||||
|
||||
const procSerKey = getCustomPragmaVal(myproc, serializationKey)
|
||||
static: assert(procSerKey == "myprocSS")
|
||||
|
||||
static: assert(hasCustomPragma(myproc, alternativeKey))
|
||||
|
|
|
|||
|
|
@ -226,7 +226,8 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
|
|||
"actiontable/tactiontable", "method/tmultim1",
|
||||
"method/tmultim3", "method/tmultim4",
|
||||
"varres/tvarres0", "varres/tvarres3", "varres/tvarres4",
|
||||
"varres/tvartup", "misc/tints", "misc/tunsignedinc"]:
|
||||
"varres/tvartup", "misc/tints", "misc/tunsignedinc",
|
||||
"async/tjsandnativeasync"]:
|
||||
test "tests/" & testfile & ".nim"
|
||||
|
||||
for testfile in ["strutils", "json", "random", "times", "logging"]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue