aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
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/test
parent24ba990800665299b551e66d1bc3d89c96ff6c55 (diff)
Optimized generation of I64, F64 and variants on JVM.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux/data/name.lux84
-rw-r--r--stdlib/source/test/lux/target/jvm.lux12
2 files changed, 54 insertions, 42 deletions
diff --git a/stdlib/source/test/lux/data/name.lux b/stdlib/source/test/lux/data/name.lux
index f2741c7d0..836f75aa1 100644
--- a/stdlib/source/test/lux/data/name.lux
+++ b/stdlib/source/test/lux/data/name.lux
@@ -6,62 +6,70 @@
{[0 #spec]
[/
["$." equivalence]
+ ["$." order]
["$." codec]]}]
[control
pipe]
[data
[number
["n" nat]]
- ["." text ("#@." equivalence)
- ["%" format (#+ format)]]]
+ ["." text ("#@." equivalence)]]
[math
- ["r" random (#+ Random)]]]
+ ["." random (#+ Random)]]]
{1
["." /]})
(def: (part size)
- (-> Nat (r.Random Text))
- (|> (r.unicode size) (r.filter (|>> (text.contains? ".") not))))
+ (-> Nat (Random Text))
+ (random.filter (|>> (text.contains? ".") not)
+ (random.unicode size)))
(def: #export (name module-size short-size)
(-> Nat Nat (Random Name))
- (r.and (..part module-size)
- (..part short-size)))
+ (random.and (..part module-size)
+ (..part short-size)))
(def: #export test
Test
- (<| (_.context (%.name (name-of .Name)))
- (do {@ r.monad}
+ (<| (_.covering /._)
+ (do {@ random.monad}
[## First Name
- sizeM1 (|> r.nat (:: @ map (n.% 100)))
- sizeS1 (|> r.nat (:: @ map (|>> (n.% 100) (n.max 1))))
+ sizeM1 (|> random.nat (:: @ map (n.% 100)))
+ sizeS1 (|> random.nat (:: @ map (|>> (n.% 100) (n.max 1))))
(^@ name1 [module1 short1]) (..name sizeM1 sizeS1)
## Second Name
- sizeM2 (|> r.nat (:: @ map (n.% 100)))
- sizeS2 (|> r.nat (:: @ map (|>> (n.% 100) (n.max 1))))
+ sizeM2 (|> random.nat (:: @ map (n.% 100)))
+ sizeS2 (|> random.nat (:: @ map (|>> (n.% 100) (n.max 1))))
(^@ name2 [module2 short2]) (..name sizeM2 sizeS2)]
- ($_ _.and
- ($equivalence.spec /.equivalence (..name sizeM1 sizeS1))
- ($codec.spec /.equivalence /.codec (..name sizeM1 sizeS1))
-
- (_.test "Can get the module / short parts of an name."
- (and (is? module1 (/.module name1))
- (is? short1 (/.short name1))))
- (let [(^open "/@.") /.codec]
- (_.test "Encoding an name without a module component results in text equal to the short of the name."
- (if (text.empty? module1)
- (text@= short1 (/@encode name1))
- #1)))
- (let [(^open "/@.") /.equivalence]
- ($_ _.and
- (_.test "Can obtain Name from identifier."
- (and (/@= ["lux" "yolo"] (name-of .yolo))
- (/@= ["test/lux/data/name" "yolo"] (name-of ..yolo))
- (/@= ["" "yolo"] (name-of yolo))
- (/@= ["lux/test" "yolo"] (name-of lux/test.yolo))))
- (_.test "Can obtain Name from tag."
- (and (/@= ["lux" "yolo"] (name-of #.yolo))
- (/@= ["test/lux/data/name" "yolo"] (name-of #..yolo))
- (/@= ["" "yolo"] (name-of #yolo))
- (/@= ["lux/test" "yolo"] (name-of #lux/test.yolo))))))
- ))))
+ (_.with-cover [.Name]
+ ($_ _.and
+ (_.with-cover [/.equivalence]
+ ($equivalence.spec /.equivalence (..name sizeM1 sizeS1)))
+ (_.with-cover [/.order]
+ ($order.spec /.order (..name sizeM1 sizeS1)))
+ (_.with-cover [/.codec]
+ (_.and ($codec.spec /.equivalence /.codec (..name sizeM1 sizeS1))
+ (let [(^open "/@.") /.codec]
+ (_.test "Encoding an name without a module component results in text equal to the short of the name."
+ (if (text.empty? module1)
+ (text@= short1 (/@encode name1))
+ #1)))))
+
+ (_.cover [/.module /.short]
+ (and (is? module1 (/.module name1))
+ (is? short1 (/.short name1))))
+
+ (_.with-cover [.name-of]
+ (let [(^open "/@.") /.equivalence]
+ ($_ _.and
+ (_.test "Can obtain Name from identifier."
+ (and (/@= ["lux" "yolo"] (.name-of .yolo))
+ (/@= ["test/lux/data/name" "yolo"] (.name-of ..yolo))
+ (/@= ["" "yolo"] (.name-of yolo))
+ (/@= ["lux/test" "yolo"] (.name-of lux/test.yolo))))
+ (_.test "Can obtain Name from tag."
+ (and (/@= ["lux" "yolo"] (.name-of #.yolo))
+ (/@= ["test/lux/data/name" "yolo"] (.name-of #..yolo))
+ (/@= ["" "yolo"] (.name-of #yolo))
+ (/@= ["lux/test" "yolo"] (.name-of #lux/test.yolo)))))))
+ )))))
diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux
index f2468ab4f..511635a2a 100644
--- a/stdlib/source/test/lux/target/jvm.lux
+++ b/stdlib/source/test/lux/target/jvm.lux
@@ -577,8 +577,10 @@
comparison (: (-> (Bytecode Any) (-> java/lang/Float java/lang/Float Bit) (Random Bit))
(function (_ instruction standard)
(do random.monad
- [reference ..$Float::random
- subject ..$Float::random
+ [#let [valid-float (random.filter (|>> host.float-to-double (:coerce Frac) f.not-a-number? not)
+ ..$Float::random)]
+ reference valid-float
+ subject valid-float
#let [expected (if (for {@.old
("jvm feq" reference subject)
@@ -671,8 +673,10 @@
comparison (: (-> (Bytecode Any) (-> java/lang/Double java/lang/Double Bit) (Random Bit))
(function (_ instruction standard)
(do random.monad
- [reference ..$Double::random
- subject ..$Double::random
+ [#let [valid-double (random.filter (|>> (:coerce Frac) f.not-a-number? not)
+ ..$Double::random)]
+ reference valid-double
+ subject valid-double
#let [expected (if (for {@.old
("jvm deq" reference subject)