diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/async/config.nims | 2 | ||||
-rw-r--r-- | tests/async/tjsandnativeasync.nim | 30 | ||||
-rw-r--r-- | tests/gc/gcleak.nim | 3 | ||||
-rw-r--r-- | tests/gc/gcleak2.nim | 4 | ||||
-rw-r--r-- | tests/gc/gcleak4.nim | 2 | ||||
-rw-r--r-- | tests/js/tasync.nim | 1 | ||||
-rw-r--r-- | tests/pragmas/tcustom_pragma.nim | 10 | ||||
-rw-r--r-- | tests/testament/categories.nim | 3 |
8 files changed, 45 insertions, 10 deletions
diff --git a/tests/async/config.nims b/tests/async/config.nims deleted file mode 100644 index 97c2e0aa4..000000000 --- a/tests/async/config.nims +++ /dev/null @@ -1,2 +0,0 @@ -when defined(upcoming): - patchFile("stdlib", "asyncdispatch", "$lib/upcoming/asyncdispatch") diff --git a/tests/async/tjsandnativeasync.nim b/tests/async/tjsandnativeasync.nim new file mode 100644 index 000000000..45839899f --- /dev/null +++ b/tests/async/tjsandnativeasync.nim @@ -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() diff --git a/tests/gc/gcleak.nim b/tests/gc/gcleak.nim index 4e47db609..8852a8d91 100644 --- a/tests/gc/gcleak.nim +++ b/tests/gc/gcleak.nim @@ -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() - diff --git a/tests/gc/gcleak2.nim b/tests/gc/gcleak2.nim index 101421683..facb8a008 100644 --- a/tests/gc/gcleak2.nim +++ b/tests/gc/gcleak2.nim @@ -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() - - diff --git a/tests/gc/gcleak4.nim b/tests/gc/gcleak4.nim index d93a13854..e9b17e557 100644 --- a/tests/gc/gcleak4.nim +++ b/tests/gc/gcleak4.nim @@ -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] diff --git a/tests/js/tasync.nim b/tests/js/tasync.nim index 34ef97b8b..76db38b27 100644 --- a/tests/js/tasync.nim +++ b/tests/js/tasync.nim @@ -1,5 +1,4 @@ discard """ - disabled: true output: ''' x e diff --git a/tests/pragmas/tcustom_pragma.nim b/tests/pragmas/tcustom_pragma.nim index a2380522f..415ae6a32 100644 --- a/tests/pragmas/tcustom_pragma.nim +++ b/tests/pragmas/tcustom_pragma.nim @@ -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)) diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index 5c845fc5c..90468e627 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -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"]: |