js-on-sx: relational ops ToPrimitive operands + NaN-safe le/ge
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 42s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 42s
This commit is contained in:
@@ -1876,6 +1876,8 @@
|
||||
(fn
|
||||
(v)
|
||||
(cond
|
||||
((or (= (type-of v) "lambda") (= (type-of v) "function") (= (type-of v) "component"))
|
||||
(let ((s (js-to-string v))) s))
|
||||
((not (= (type-of v) "dict")) v)
|
||||
((contains? (keys v) "__js_string_value__")
|
||||
(get v "__js_string_value__"))
|
||||
@@ -2076,16 +2078,37 @@
|
||||
js-lt
|
||||
(fn
|
||||
(a b)
|
||||
(cond
|
||||
((and (= (type-of a) "string") (= (type-of b) "string"))
|
||||
(js-str-lt a b))
|
||||
(else (< (js-to-number a) (js-to-number b))))))
|
||||
(let
|
||||
((ap (js-add-unwrap a)) (bp (js-add-unwrap b)))
|
||||
(cond
|
||||
((and (= (type-of ap) "string") (= (type-of bp) "string"))
|
||||
(js-str-lt ap bp))
|
||||
(else
|
||||
(let
|
||||
((an (js-to-number ap)) (bn (js-to-number bp)))
|
||||
(cond
|
||||
((or (js-number-is-nan an) (js-number-is-nan bn)) false)
|
||||
(else (< an bn)))))))))
|
||||
|
||||
(define js-gt (fn (a b) (js-lt b a)))
|
||||
|
||||
(define js-le (fn (a b) (not (js-lt b a))))
|
||||
(define
|
||||
js-le
|
||||
(fn
|
||||
(a b)
|
||||
(let
|
||||
((ap (js-add-unwrap a)) (bp (js-add-unwrap b)))
|
||||
(cond
|
||||
((and (= (type-of ap) "string") (= (type-of bp) "string"))
|
||||
(or (js-str-lt ap bp) (= ap bp)))
|
||||
(else
|
||||
(let
|
||||
((an (js-to-number ap)) (bn (js-to-number bp)))
|
||||
(cond
|
||||
((or (js-number-is-nan an) (js-number-is-nan bn)) false)
|
||||
(else (<= an bn)))))))))
|
||||
|
||||
(define js-ge (fn (a b) (not (js-lt a b))))
|
||||
(define js-ge (fn (a b) (js-le b a)))
|
||||
|
||||
(define
|
||||
js-str-lt
|
||||
|
||||
Reference in New Issue
Block a user