mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
clean up stdlib with --jsbigint64 (#24255)
refs #6978, refs #6752, refs #21613, refs #24234
The `jsNoInt64`, `whenHasBigInt64`, `whenJsNoBigInt64` templates are
replaced with bool constants to use with `when`. Weird that I didn't do
this in the first place.
The `whenJsNoBigInt64` template was also slightly misleading. The first
branch was compiled for both no bigint64 on JS as well as on C/C++. It
seems only `trandom` depended on this by mistake.
The workaround for #6752 added in #6978 to `times` is also removed with
`--jsbigint64:on`, but #24233 was also encountered with this, so this PR
depends on #24234.
(cherry picked from commit 041098e882)
This commit is contained in:
@@ -314,8 +314,7 @@ block: # bug #17383
|
||||
else:
|
||||
testRoundtrip(int.high): "9223372036854775807"
|
||||
testRoundtrip(uint.high): "18446744073709551615"
|
||||
whenJsNoBigInt64: discard
|
||||
do:
|
||||
when hasWorkingInt64:
|
||||
testRoundtrip(int64.high): "9223372036854775807"
|
||||
testRoundtrip(uint64.high): "18446744073709551615"
|
||||
|
||||
|
||||
@@ -225,8 +225,9 @@ block: # same as above but use slice overload
|
||||
doAssert a3.type is a2.type
|
||||
test cast[uint](int.high)
|
||||
test cast[uint](int.high) + 1
|
||||
whenJsNoBigInt64: discard
|
||||
do:
|
||||
when hasWorkingInt64 and defined(js):
|
||||
# weirdly this has to run only in JS for the final int32.high test
|
||||
# to be the same between C/C++ and --jsbigint64:on
|
||||
test uint64.high
|
||||
test uint64.high - 1
|
||||
test uint.high - 2
|
||||
|
||||
@@ -527,8 +527,7 @@ template main() =
|
||||
|
||||
block: # toHex
|
||||
doAssert(toHex(100i16, 32) == "00000000000000000000000000000064")
|
||||
whenJsNoBigInt64: discard
|
||||
do:
|
||||
when hasWorkingInt64:
|
||||
doAssert(toHex(-100i16, 32) == "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9C")
|
||||
doAssert(toHex(high(uint64)) == "FFFFFFFFFFFFFFFF")
|
||||
doAssert(toHex(high(uint64), 16) == "FFFFFFFFFFFFFFFF")
|
||||
@@ -550,9 +549,8 @@ template main() =
|
||||
doAssert(spaces(0) == "")
|
||||
|
||||
block: # toBin, toOct
|
||||
whenJsNoBigInt64: # bug #11369
|
||||
discard
|
||||
do:
|
||||
when hasWorkingInt64:
|
||||
# bug #11369
|
||||
var num: int64 = -1
|
||||
doAssert num.toBin(64) == "1111111111111111111111111111111111111111111111111111111111111111"
|
||||
doAssert num.toOct(24) == "001777777777777777777777"
|
||||
@@ -773,8 +771,7 @@ bar
|
||||
|
||||
block: # formatSize
|
||||
disableVm:
|
||||
whenJsNoBigInt64: discard
|
||||
do:
|
||||
when hasWorkingInt64:
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user