diff options
author | Eduardo Julian | 2019-04-17 20:56:46 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-04-17 20:56:46 -0400 |
commit | 319f5d120a88eb9e9a75e5ca0c03f5fd555cab14 (patch) | |
tree | 789b20fcbe76c2c598eb45db1c9473604b9f02b6 /stdlib/source/test | |
parent | 31d7f09f2c410951948134bb3045b2ca0147327d (diff) |
Simplified the "Order" signature.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux/abstract/interval.lux | 15 | ||||
-rw-r--r-- | stdlib/source/test/lux/abstract/number.lux | 6 | ||||
-rw-r--r-- | stdlib/source/test/lux/abstract/order.lux | 19 |
3 files changed, 22 insertions, 18 deletions
diff --git a/stdlib/source/test/lux/abstract/interval.lux b/stdlib/source/test/lux/abstract/interval.lux index cfc19f6a9..62b56a5fb 100644 --- a/stdlib/source/test/lux/abstract/interval.lux +++ b/stdlib/source/test/lux/abstract/interval.lux @@ -3,6 +3,7 @@ ["_" test (#+ Test)] [abstract/monad (#+ do)] [abstract + ["." order] {[0 #test] [/ ["$." equivalence]]}] @@ -19,7 +20,7 @@ [math ["r" random (#+ Random)]]] {1 - ["." / (#+ Interval) ("_@." equivalence)]}) + ["." / (#+ Interval) (",@." equivalence)]}) (template [<name> <cmp>] [(def: #export <name> @@ -79,7 +80,7 @@ right-outer ..outer] ($_ _.and (_.test "The union of an interval to itself yields the same interval." - (_@= some-interval (/.union some-interval some-interval))) + (,@= some-interval (/.union some-interval some-interval))) (_.test "The union of 2 inner intervals is another inner interval." (/.inner? (/.union left-inner right-inner))) (_.test "The union of 2 outer intervals yields an inner interval when their complements don't overlap, and an outer when they do." @@ -100,7 +101,7 @@ right-outer ..outer] ($_ _.and (_.test "The intersection of an interval to itself yields the same interval." - (_@= some-interval (/.intersection some-interval some-interval))) + (,@= some-interval (/.intersection some-interval some-interval))) (_.test "The intersection of 2 inner intervals yields an inner interval when they overlap, and an outer when they don't." (if (/.overlaps? left-inner right-inner) (/.inner? (/.intersection left-inner right-inner)) @@ -115,7 +116,7 @@ [some-interval ..interval] ($_ _.and (_.test "The complement of a complement is the same as the original." - (_@= some-interval (|> some-interval /.complement /.complement))) + (,@= some-interval (|> some-interval /.complement /.complement))) (_.test "The complement of an interval does not overlap it." (not (/.overlaps? some-interval (/.complement some-interval)))) ))) @@ -235,14 +236,14 @@ ..overlap) ))) -(def: #export (spec (^open "_@.") gen-sample) +(def: #export (spec (^open ",@.") gen-sample) (All [a] (-> (Interval a) (Random a) Test)) (<| (_.context (%name (name-of /.Interval))) (do r.monad [sample gen-sample] ($_ _.and (_.test "No value is bigger than the top." - (_@< _@top sample)) + (,@< ,@top sample)) (_.test "No value is smaller than the bottom." - (_@> _@bottom sample)) + (order.> ,@&order ,@bottom sample)) )))) diff --git a/stdlib/source/test/lux/abstract/number.lux b/stdlib/source/test/lux/abstract/number.lux index 2d726dfed..363621791 100644 --- a/stdlib/source/test/lux/abstract/number.lux +++ b/stdlib/source/test/lux/abstract/number.lux @@ -10,9 +10,9 @@ {1 ["." / (#+ Number) [// - [order (#+ Order)]]]}) + ["." order (#+ Order)]]]}) -(def: #export (spec (^open "/@.") (^open "/@.") gen-sample) +(def: #export (spec (^@ order (^open "/@.")) (^open "/@.") gen-sample) (All [a] (-> (Order a) (Number a) (Random a) Test)) (do r.monad [#let [non-zero (r.filter (function (_ sample) @@ -42,5 +42,5 @@ (/@negate parameter))] (if unsigned? (/@= subject (/@abs subject)) - (/@>= subject (/@abs subject))))) + (order.>= order subject (/@abs subject))))) )))) diff --git a/stdlib/source/test/lux/abstract/order.lux b/stdlib/source/test/lux/abstract/order.lux index 535d774a7..5406a490c 100644 --- a/stdlib/source/test/lux/abstract/order.lux +++ b/stdlib/source/test/lux/abstract/order.lux @@ -13,14 +13,17 @@ (def: #export (spec (^open ",@.") generator) (All [a] (-> (Order a) (Random a) Test)) (do r.monad - [left generator - right generator] + [parameter generator + subject generator] (<| (_.context (%name (name-of /.Order))) ($_ _.and (_.test "Values are either ordered, or they are equal. All options are mutually exclusive." - (if (,@= left right) - (not (or (,@< left right) - (,@> left right))) - (if (,@< left right) - (not (,@> left right)) - (,@> left right)))))))) + (cond (,@< parameter subject) + (not (or (,@< subject parameter) + (,@= parameter subject))) + + (,@< subject parameter) + (not (,@= parameter subject)) + + ## else + (,@= parameter subject))))))) |