diff options
Diffstat (limited to 'stdlib/source/spec')
-rw-r--r-- | stdlib/source/spec/lux/abstract/order.lux | 52 |
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?))))) + ))) |