aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/spec
diff options
context:
space:
mode:
authorEduardo Julian2020-10-07 23:03:33 -0400
committerEduardo Julian2020-10-07 23:03:33 -0400
commit79aa92dfd81d569fe6120b8e5c00d41528801153 (patch)
treeee5d301077038e7e10bbd2773b9209d9eba77037 /stdlib/source/spec
parent24ba990800665299b551e66d1bc3d89c96ff6c55 (diff)
Optimized generation of I64, F64 and variants on JVM.
Diffstat (limited to 'stdlib/source/spec')
-rw-r--r--stdlib/source/spec/lux/abstract/order.lux52
1 files changed, 41 insertions, 11 deletions
diff --git a/stdlib/source/spec/lux/abstract/order.lux b/stdlib/source/spec/lux/abstract/order.lux
index 4cdb5689a..35aef0c9d 100644
--- a/stdlib/source/spec/lux/abstract/order.lux
+++ b/stdlib/source/spec/lux/abstract/order.lux
@@ -11,17 +11,47 @@
(def: #export (spec (^open "/@.") generator)
(All [a] (-> (/.Order a) (Random a) Test))
(<| (_.with-cover [/.Order])
- (do random.monad
- [parameter generator
- subject generator])
($_ _.and
- (_.test "Values are either ordered, or they are equal. All options are mutually exclusive."
- (cond (/@< parameter subject)
- (not (or (/@< subject parameter)
- (/@= parameter subject)))
+ (do random.monad
+ [parameter generator
+ subject generator]
+ (_.test "Values are either ordered, or they are equal. All options are mutually exclusive."
+ (cond (/@< parameter subject)
+ (not (or (/@< subject parameter)
+ (/@= parameter subject)))
- (/@< subject parameter)
- (not (/@= parameter subject))
+ (/@< subject parameter)
+ (not (/@= parameter subject))
- ## else
- (/@= parameter subject))))))
+ ## else
+ (/@= parameter subject))))
+ (do random.monad
+ [parameter generator
+ subject (random.filter (|>> (/@= parameter) not)
+ generator)
+ extra (random.filter (function (_ value)
+ (not (or (/@= parameter value)
+ (/@= subject value))))
+ generator)]
+ (_.test "Transitive property."
+ (if (/@< parameter subject)
+ (let [greater? (and (/@< subject extra)
+ (/@< parameter extra))
+ lesser? (and (/@< extra parameter)
+ (/@< extra subject))
+ in-between? (and (/@< parameter extra)
+ (/@< extra subject))]
+ (or greater?
+ lesser?
+ in-between?))
+ ## (/@< subject parameter)
+ (let [greater? (and (/@< extra subject)
+ (/@< extra parameter))
+ lesser? (and (/@< parameter extra)
+ (/@< subject extra))
+ in-between? (and (/@< subject extra)
+ (/@< extra parameter))]
+ (or greater?
+ lesser?
+ in-between?)))))
+ )))