1
0
mirror of https://github.com/janet-lang/janet synced 2025-02-06 12:00:01 +00:00

Add some more test cases for hex floats.

This commit is contained in:
Calvin Rose 2025-02-01 08:09:57 -06:00
parent f63a33884f
commit eecffe01a5
3 changed files with 8 additions and 3 deletions

View File

@ -298,11 +298,10 @@ int janet_scan_number_base(
}
/* If still base is 0, set to default (10) */
int exp_base = base;
if (base == 0) {
base = 10;
exp_base = 10;
}
int exp_base = base;
/* Skip leading zeros */
while (str < end && (*str == '0' || *str == '.')) {

View File

@ -39,7 +39,7 @@
(defmacro assert
[x &opt e]
(def xx (gensym))
(default e ~',x)
(default e (string/format "%j" x))
~(do
(def ,xx ,x)
(,assert-no-tail ,xx ,e)

View File

@ -210,6 +210,12 @@
# Hex floats
(assert (= math/pi +0x1.921fb54442d18p+0001))
(assert (= math/int-max +0x1.ffff_ffff_ffff_ffp+0052))
(assert (= math/int-min -0x1.ffff_ffff_ffff_ffp+0052))
(assert (= 1 0x1P0))
(assert (= 2 0x1P1))
(assert (= -2 -0x1p1))
(assert (= -0.5 -0x1p-1))
(end-suite)