fix #17615(runnableExamples silently ignored if placed after some code) (#17619)

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
This commit is contained in:
flywind
2021-04-03 09:26:30 +08:00
committed by GitHub
parent e35946f306
commit a807233aeb
8 changed files with 41 additions and 28 deletions

View File

@@ -288,9 +288,9 @@ proc diffInt*(arrayA, arrayB: openArray[int]): seq[Item] =
var dataB = newDiffData(@arrayB, arrayB.len)
let max = dataA.len + dataB.len + 1
## vector for the (0,0) to (x,y) search
# vector for the (0,0) to (x,y) search
var downVector = newSeq[int](2 * max + 2)
## vector for the (u,v) to (N,M) search
# vector for the (u,v) to (N,M) search
var upVector = newSeq[int](2 * max + 2)
lcs(dataA, 0, dataA.len, dataB, 0, dataB.len, downVector, upVector)
@@ -321,9 +321,9 @@ proc diffText*(textA, textB: string): seq[Item] =
h.clear # free up hashtable memory (maybe)
let max = dataA.len + dataB.len + 1
## vector for the (0,0) to (x,y) search
# vector for the (0,0) to (x,y) search
var downVector = newSeq[int](2 * max + 2)
## vector for the (u,v) to (N,M) search
# vector for the (u,v) to (N,M) search
var upVector = newSeq[int](2 * max + 2)
lcs(dataA, 0, dataA.len, dataB, 0, dataB.len, downVector, upVector)

View File

@@ -293,9 +293,9 @@ proc start*(c: proc(), stacksize: int = defaultStackSize): CoroutineRef {.discar
return coro.reference
proc run*() =
initialize()
## Starts main coroutine scheduler loop which exits when all coroutines exit.
## Calling this proc starts execution of first coroutine.
initialize()
ctx.current = ctx.coroutines.head
var minDelay: float = 0
while ctx.current != nil:

View File

@@ -8,14 +8,13 @@ type JsBigInt* = distinct JsBigIntImpl ## Arbitrary precision integer fo
func big*(integer: SomeInteger): JsBigInt {.importjs: "BigInt(#)".} =
## Constructor for `JsBigInt`.
when nimvm: doAssert false, "JsBigInt can not be used at compile-time nor static context" else: discard
runnableExamples:
doAssert big(1234567890) == big"1234567890"
doAssert 0b1111100111.big == 0o1747.big and 0o1747.big == 999.big
when nimvm: doAssert false, "JsBigInt can not be used at compile-time nor static context" else: discard
func big*(integer: cstring): JsBigInt {.importjs: "BigInt(#)".} =
## Constructor for `JsBigInt`.
when nimvm: doAssert false, "JsBigInt can not be used at compile-time nor static context" else: discard
runnableExamples:
doAssert big"-1" == big"1" - big"2"
# supports decimal, binary, octal, hex:
@@ -24,6 +23,7 @@ func big*(integer: cstring): JsBigInt {.importjs: "BigInt(#)".} =
doAssert big"0o701" == 0o701.big
doAssert big"0xdeadbeaf" == 0xdeadbeaf.big
doAssert big"0xffffffffffffffff" == (1.big shl 64.big) - 1.big
when nimvm: doAssert false, "JsBigInt can not be used at compile-time nor static context" else: discard
func toCstring*(this: JsBigInt; radix: 2..36): cstring {.importjs: "#.toString(#)".} =
## Converts from `JsBigInt` to `cstring` representation.

View File

@@ -565,10 +565,9 @@ proc SSL_ctrl*(ssl: SslPtr, cmd: cint, larg: int, parg: pointer): int{.
cdecl, dynlib: DLLSSLName, importc.}
proc SSL_set_tlsext_host_name*(ssl: SslPtr, name: cstring): int =
result = SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, name)
## Set the SNI server name extension to be used in a client hello.
## Returns 1 if SNI was set, 0 if current SSL configuration doesn't support SNI.
result = SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, name)
proc SSL_get_servername*(ssl: SslPtr, typ: cint = TLSEXT_NAMETYPE_host_name): cstring {.cdecl, dynlib: DLLSSLName, importc.}
## Retrieve the server name requested in the client hello. This can be used