diff options
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/coro.nim | 2 | ||||
-rw-r--r-- | lib/pure/coro.nimcfg | 1 | ||||
-rw-r--r-- | lib/pure/math.nim | 2 | ||||
-rw-r--r-- | lib/pure/nativesockets.nim | 1 | ||||
-rw-r--r-- | lib/pure/ospaths.nim | 4 | ||||
-rw-r--r-- | lib/pure/subexes.nim | 19 |
6 files changed, 16 insertions, 13 deletions
diff --git a/lib/pure/coro.nim b/lib/pure/coro.nim index 8fa529474..c5724f26f 100644 --- a/lib/pure/coro.nim +++ b/lib/pure/coro.nim @@ -119,7 +119,7 @@ proc wait*(c: proc(), interval=0.01) = while alive(c): suspend interval -when isMainModule: +when defined(nimCoroutines) and isMainModule: var stackCheckValue = 1100220033 proc c2() diff --git a/lib/pure/coro.nimcfg b/lib/pure/coro.nimcfg new file mode 100644 index 000000000..b011bc585 --- /dev/null +++ b/lib/pure/coro.nimcfg @@ -0,0 +1 @@ +-d:nimCoroutines diff --git a/lib/pure/math.nim b/lib/pure/math.nim index 06a018d9f..391a880ae 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -475,7 +475,7 @@ when isMainModule and not defined(JS): return sqrt(num) # check gamma function - assert(tgamma(5.0) == 24.0) # 4! + assert($tgamma(5.0) == $24.0) # 4! assert(lgamma(1.0) == 0.0) # ln(1.0) == 0.0 assert(erf(6.0) > erf(5.0)) assert(erfc(6.0) < erfc(5.0)) diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim index b5661c4d3..c9e067a3e 100644 --- a/lib/pure/nativesockets.nim +++ b/lib/pure/nativesockets.nim @@ -349,7 +349,6 @@ proc getAddrString*(sockAddr: ptr SockAddr): string = elif sockAddr.sa_family == nativeAfInet6: when not useWinVersion: # TODO: Windows - var v6addr = cast[ptr Sockaddr_in6](sockAddr).sin6_addr result = newString(posix.INET6_ADDRSTRLEN) let addr6 = addr cast[ptr Sockaddr_in6](sockAddr).sin6_addr discard posix.inet_ntop(posix.AF_INET6, addr6, result.cstring, diff --git a/lib/pure/ospaths.nim b/lib/pure/ospaths.nim index dcc710193..667ca82d7 100644 --- a/lib/pure/ospaths.nim +++ b/lib/pure/ospaths.nim @@ -10,6 +10,10 @@ # Included by the ``os`` module but a module in its own right for NimScript # support. +when isMainModule: + {.pragma: rtl.} + import strutils + when defined(nimscript) or (defined(nimdoc) and not declared(os)): {.pragma: rtl.} {.push hint[ConvFromXtoItselfNotNeeded]:off.} diff --git a/lib/pure/subexes.nim b/lib/pure/subexes.nim index 2d1adc0eb..5824ace81 100644 --- a/lib/pure/subexes.nim +++ b/lib/pure/subexes.nim @@ -351,6 +351,7 @@ proc format*(formatstr: Subex, a: varargs[string, `$`]): string {.noSideEffect, {.pop.} when isMainModule: + from strutils import replace proc `%`(formatstr: string, a: openarray[string]): string = result = newStringOfCap(formatstr.len + a.len shl 4) @@ -382,18 +383,18 @@ when isMainModule: doAssert "${$1}" % "1" == "1" doAssert "${$$-1} $$1" % "1" == "1 $1" - doAssert "$#($', '10c'\n '{#..})" % ["doAssert", "longishA", "longish"] == + doAssert(("$#($', '10c'\n '{#..})" % ["doAssert", "longishA", "longish"]).replace(" \n", "\n") == """doAssert( longishA, - longish)""" + longish)""") - assert "type MyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA", - "fieldB", "FiledClkad", "fieldD", "fieldE", "longishFieldName"] == + doAssert(("type MyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA", + "fieldB", "FiledClkad", "fieldD", "fieldE", "longishFieldName"]).replace(" \n", "\n") == strutils.unindent """ type MyEnum* = enum fieldA, fieldB, FiledClkad, fieldD, - fieldE, longishFieldName""" + fieldE, longishFieldName""") doAssert subex"$1($', '{2..})" % ["f", "a", "b", "c"] == "f(a, b, c)" @@ -401,12 +402,10 @@ when isMainModule: doAssert subex"$['''|'|''''|']']#" % "0" == "'|" - assert subex("type\n Enum = enum\n $', '40c'\n '{..}") % [ - "fieldNameA", "fieldNameB", "fieldNameC", "fieldNameD"] == + doAssert((subex("type\n Enum = enum\n $', '40c'\n '{..}") % [ + "fieldNameA", "fieldNameB", "fieldNameC", "fieldNameD"]).replace(" \n", "\n") == strutils.unindent """ type Enum = enum fieldNameA, fieldNameB, fieldNameC, - fieldNameD""" - - + fieldNameD""") |