mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-17 00:24:16 +00:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user