test.check generators: rand-double, take +Inf, UUID/Long/shiftLeft, transient
More general fixes from clojure.test.check's own suite. - *unchecked-math* on doubles: unchecked-* only wrap integer math; on a flonum operand they're an ordinary float op (Clojure: (unchecked-multiply 1.5 2.0) => 3.0). test.check's rand-double is (* double-unit shifted) under *unchecked-math* and was truncating to a long 0, so every distribution-driven generator (choose, vector, …) collapsed to its lower bound. - (take Double/POSITIVE_INFINITY coll) takes the whole coll instead of throwing on the infinite count coercion (rose-tree unchunk relies on it). - (java.util.UUID. msb lsb) 2-long constructor (the uuid generator), formatted as the canonical lowercase 8-4-4-4-12 string; (Long. n) constructor; BigInteger .shiftLeft / .shiftRight (size-bounded-bigint); number methods now receive args. - A transient (ITransientSet) responds to .contains / .valAt / .count (distinct-collection generators). make test green (+3 corpus rows, 0 new divergences), runtime only (no re-mint).
This commit is contained in:
parent
992fc0af34
commit
f32bd335e3
5 changed files with 59 additions and 15 deletions
|
|
@ -103,13 +103,13 @@
|
|||
(if f
|
||||
(apply f obj (if (jolt-nil? rest-args) '() (seq->list rest-args)))
|
||||
(error #f (string-append "No method " method-name " on host " (jhost-tag obj)))))))
|
||||
((number? obj) (number-method method-name obj))
|
||||
((number? obj) (apply number-method method-name obj (if (jolt-nil? rest-args) '() (seq->list rest-args))))
|
||||
(else (%hs-record-method-dispatch obj method-name rest-args)))))
|
||||
|
||||
;; java.lang.Number method surface (the boxed-number methods cljc code calls). The
|
||||
;; integer projections wrap modulo their width (ring-codec relies on byteValue
|
||||
;; overflow: (.byteValue 255) => -1); the float projections are identity flonums.
|
||||
(define (number-method method n)
|
||||
(define (number-method method n . args)
|
||||
(cond
|
||||
((string=? method "byteValue") (let ((b (modulo (jnum->exact n) 256))) (->num (if (>= b 128) (- b 256) b))))
|
||||
((string=? method "shortValue") (let ((b (modulo (jnum->exact n) 65536))) (->num (if (>= b 32768) (- b 65536) b))))
|
||||
|
|
@ -129,6 +129,10 @@
|
|||
((string=? method "abs") (->num (abs (jnum->exact n))))
|
||||
((string=? method "bitLength") (->num (integer-length (jnum->exact n))))
|
||||
((string=? method "signum") (->num (let ((e (jnum->exact n))) (cond ((> e 0) 1) ((< e 0) -1) (else 0)))))
|
||||
;; BigInteger.shiftLeft/shiftRight (test.check's size-bounded-bigint): arbitrary
|
||||
;; precision, so an arithmetic shift by the (positive) amount.
|
||||
((string=? method "shiftLeft") (->num (bitwise-arithmetic-shift-left (jnum->exact n) (jnum->exact (car args)))))
|
||||
((string=? method "shiftRight") (->num (bitwise-arithmetic-shift-right (jnum->exact n) (jnum->exact (car args)))))
|
||||
(else (error #f (string-append "No method " method " for number")))))
|
||||
|
||||
;; Mutable static fields: "Class" -> (member -> 1-vector cell). A library that
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue