js-on-sx: ** / Math.pow spec edges (NaN exp, abs(base)=1+inf), Number.valueOf ignores args
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 42s

This commit is contained in:
2026-05-10 03:01:02 +00:00
parent 1a34cc4456
commit 058dcd5600
2 changed files with 21 additions and 3 deletions

View File

@@ -2048,7 +2048,23 @@
(sh (modulo (js-math-trunc (js-to-number b)) 32)))
(if (= sh 0) ai (floor (/ ai (js-math-pow 2 sh)))))))
(define js-pow (fn (a b) (pow (js-to-number a) (js-to-number b))))
(define
js-pow-spec
(fn
(b e)
(let
((bn (js-to-number b)) (en (js-to-number e)))
(let
((inf (js-infinity-value)) (abs-b (if (< bn 0) (- 0 bn) bn)))
(cond
((js-number-is-nan en) (js-nan-value))
((= en 0) 1)
((js-number-is-nan bn) (js-nan-value))
((and (= abs-b 1) (or (= en inf) (= en (- 0 inf))))
(js-nan-value))
(else (pow bn en)))))))
(define js-pow (fn (a b) (js-pow-spec a b)))
(define js-neg (fn (a) (* -1 (exact->inexact (js-to-number a)))))
@@ -3653,7 +3669,7 @@
(define js-math-sqrt (fn (x) (sqrt (js-to-number x))))
(define js-math-pow (fn (a b) (pow (js-to-number a) (js-to-number b))))
(define js-math-pow (fn (a b) (js-pow-spec a b)))
(define
js-math-trunc
@@ -3788,7 +3804,7 @@
(else
(raise (js-new-call TypeError (js-args "Number.prototype method requires a Number"))))))))
(define Number {:MIN_SAFE_INTEGER -9007199254740991 :MIN_VALUE 4.94066e-324 :isNaN js-number-is-nan :isSafeInteger js-number-is-safe-integer :NEGATIVE_INFINITY (- 0 (js-infinity-value)) :NaN (js-nan-value) :prototype {:toFixed {:__callable__ (fn (d) (js-number-to-fixed (js-number-this-val) (if (= d nil) 0 (js-to-number d)))) :length 1 :name "toFixed"} :toExponential {:__callable__ (fn (&rest args) (js-number-to-string (js-number-this-val))) :length 1 :name "toExponential"} :toLocaleString {:__callable__ (fn () (js-number-to-string (js-number-this-val))) :length 0 :name "toLocaleString"} :toString {:__callable__ (fn (&rest args) (let ((this-val (js-number-this-val)) (radix (if (empty? args) 10 (js-to-number (nth args 0))))) (js-num-to-str-radix this-val (if (or (= radix nil) (js-undefined? radix)) 10 radix)))) :length 1 :name "toString"} :toPrecision {:__callable__ (fn (&rest args) (js-number-to-string (js-number-this-val))) :length 1 :name "toPrecision"} :valueOf {:__callable__ (fn () (js-number-this-val)) :length 0 :name "valueOf"}} :isInteger js-number-is-integer :__callable__ js-to-number :MAX_VALUE (js-max-value-approx) :POSITIVE_INFINITY (js-infinity-value) :isFinite js-number-is-finite :MAX_SAFE_INTEGER 9007199254740991 :EPSILON 2.22045e-16})
(define Number {:MIN_SAFE_INTEGER -9007199254740991 :MIN_VALUE 4.94066e-324 :isNaN js-number-is-nan :isSafeInteger js-number-is-safe-integer :NEGATIVE_INFINITY (- 0 (js-infinity-value)) :NaN (js-nan-value) :prototype {:toFixed {:__callable__ (fn (d) (js-number-to-fixed (js-number-this-val) (if (= d nil) 0 (js-to-number d)))) :length 1 :name "toFixed"} :toExponential {:__callable__ (fn (&rest args) (js-number-to-string (js-number-this-val))) :length 1 :name "toExponential"} :toLocaleString {:__callable__ (fn () (js-number-to-string (js-number-this-val))) :length 0 :name "toLocaleString"} :toString {:__callable__ (fn (&rest args) (let ((this-val (js-number-this-val)) (radix (if (empty? args) 10 (js-to-number (nth args 0))))) (js-num-to-str-radix this-val (if (or (= radix nil) (js-undefined? radix)) 10 radix)))) :length 1 :name "toString"} :toPrecision {:__callable__ (fn (&rest args) (js-number-to-string (js-number-this-val))) :length 1 :name "toPrecision"} :valueOf {:__callable__ (fn (&rest args) (js-number-this-val)) :length 0 :name "valueOf"}} :isInteger js-number-is-integer :__callable__ js-to-number :MAX_VALUE (js-max-value-approx) :POSITIVE_INFINITY (js-infinity-value) :isFinite js-number-is-finite :MAX_SAFE_INTEGER 9007199254740991 :EPSILON 2.22045e-16})
(dict-set! Number "length" 1)