diff options
author | metagn <metagngn@gmail.com> | 2023-04-11 22:20:20 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-11 21:20:20 +0200 |
commit | f05387045df55bf7123ee68002238e943716815e (patch) | |
tree | 9ba7959434162830612e31351eadbae79cf3bc37 /tests/stdlib/tstrutils.nim | |
parent | be06446ffecd7665651a25d6b07fade5cc019296 (diff) | |
download | Nim-f05387045df55bf7123ee68002238e943716815e.tar.gz |
int64/uint64 as bigint in JS (#21613)
* int64/uint64 as bigint in JS * fix CI * convert to compile option * fix lie * smaller diff, changelog entry
Diffstat (limited to 'tests/stdlib/tstrutils.nim')
-rw-r--r-- | tests/stdlib/tstrutils.nim | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/stdlib/tstrutils.nim b/tests/stdlib/tstrutils.nim index 4e88197ff..12b0c13b1 100644 --- a/tests/stdlib/tstrutils.nim +++ b/tests/stdlib/tstrutils.nim @@ -1,10 +1,11 @@ discard """ - targets: "c cpp js" + matrix: "; --backend:cpp; --backend:js --jsbigint64:off; --backend:js --jsbigint64:on" """ import std/strutils from stdtest/testutils import disableVm import std/assertions +import std/private/jsutils # xxx each instance of `disableVm` and `when not defined js:` should eventually be fixed template rejectParse(e) = @@ -509,7 +510,8 @@ template main() = block: # toHex doAssert(toHex(100i16, 32) == "00000000000000000000000000000064") doAssert(toHex(-100i16, 32) == "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9C") - when not defined js: + whenJsNoBigInt64: discard + do: doAssert(toHex(high(uint64)) == "FFFFFFFFFFFFFFFF") doAssert(toHex(high(uint64), 16) == "FFFFFFFFFFFFFFFF") doAssert(toHex(high(uint64), 32) == "0000000000000000FFFFFFFFFFFFFFFF") @@ -530,11 +532,12 @@ template main() = doAssert(spaces(0) == "") block: # toBin, toOct - block:# bug #11369 + whenJsNoBigInt64: # bug #11369 + discard + do: var num: int64 = -1 - when not defined js: - doAssert num.toBin(64) == "1111111111111111111111111111111111111111111111111111111111111111" - doAssert num.toOct(24) == "001777777777777777777777" + doAssert num.toBin(64) == "1111111111111111111111111111111111111111111111111111111111111111" + doAssert num.toOct(24) == "001777777777777777777777" block: # replace doAssert "oo".replace("", "abc") == "oo" @@ -741,7 +744,8 @@ bar block: # formatSize disableVm: - when not defined(js): + whenJsNoBigInt64: discard + do: doAssert formatSize((1'i64 shl 31) + (300'i64 shl 20)) == "2.293GiB" # <=== bug #8231 doAssert formatSize((2.234*1024*1024).int) == "2.234MiB" doAssert formatSize(4096) == "4KiB" |