fixes overflow defect when compiled with js backend (#25132)

Follow up to https://github.com/nim-lang/Nim/pull/25126.
This fixes overflow defect when `tests/stdlib/tstrutils.nim` was
compiled with js backend.

(cherry picked from commit 87dc1820c0)
This commit is contained in:
Tomohiro
2025-09-02 01:29:58 +09:00
committed by narimiran
parent 55806c8b36
commit fe12553cfb

View File

@@ -789,8 +789,8 @@ bar
block: # formatSize
disableVm:
when hasWorkingInt64:
doAssert formatSize(1024 * 1024 * 1024 * 2 - 1) == "1.999GiB"
doAssert formatSize(1024 * 1024 * 1024 * 2) == "2GiB"
doAssert formatSize(1024'i64 * 1024 * 1024 * 2 - 1) == "1.999GiB"
doAssert formatSize(1024'i64 * 1024 * 1024 * 2) == "2GiB"
doAssert formatSize((1'i64 shl 31) + (300'i64 shl 20)) == "2.293GiB" # <=== bug #8231
doAssert formatSize(int64.high) == "7.999EiB"
doAssert formatSize(int64.high div 2 + 1) == "4EiB"