aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/aedifex')
-rw-r--r--stdlib/source/test/aedifex/cache.lux137
-rw-r--r--stdlib/source/test/aedifex/command/install.lux4
-rw-r--r--stdlib/source/test/aedifex/command/pom.lux6
-rw-r--r--stdlib/source/test/aedifex/hash.lux6
-rw-r--r--stdlib/source/test/aedifex/input.lux4
-rw-r--r--stdlib/source/test/aedifex/local.lux2
-rw-r--r--stdlib/source/test/aedifex/parser.lux4
-rw-r--r--stdlib/source/test/aedifex/profile.lux4
8 files changed, 152 insertions, 15 deletions
diff --git a/stdlib/source/test/aedifex/cache.lux b/stdlib/source/test/aedifex/cache.lux
new file mode 100644
index 000000000..e1b4abfc5
--- /dev/null
+++ b/stdlib/source/test/aedifex/cache.lux
@@ -0,0 +1,137 @@
+(.module:
+ [lux (#- Type type)
+ ["_" test (#+ Test)]
+ [abstract
+ ["." monad (#+ do)]]
+ [control
+ ["." try]
+ [concurrency
+ ["." promise (#+ Promise)]]]
+ [data
+ [binary (#+ Binary)]
+ ["." text]
+ [number
+ ["n" nat]]
+ [format
+ [xml (#+ XML)]]
+ [collection
+ ["." set]
+ ["." dictionary]]]
+ [math
+ ["." random (#+ Random) ("#@." monad)]]
+ [world
+ ["." file]]]
+ [//
+ ["@." profile]
+ ["@." artifact]
+ [//
+ [lux
+ [data
+ ["_." binary]]]]]
+ {#program
+ ["." /
+ ["/#" // #_
+ ["#" profile (#+ Profile)]
+ ["#." package (#+ Package)]
+ ["#." pom]
+ ["#." dependency (#+ Dependency)
+ ["#/." resolution (#+ Resolution)]]
+ ["#." artifact (#+ Artifact)
+ ["#/." type (#+ Type)]]]]})
+
+(def: type
+ (Random Type)
+ ($_ random.either
+ (random@wrap //artifact/type.lux-library)
+ (random@wrap //artifact/type.jvm-library)))
+
+(def: profile
+ (Random [Artifact Profile XML])
+ (random.one (function (_ profile)
+ (try.to-maybe
+ (do try.monad
+ [pom (//pom.write profile)
+ identity (try.from-maybe (get@ #//.identity profile))]
+ (wrap [identity profile pom]))))
+ @profile.random))
+
+(def: content
+ (Random Binary)
+ (do {! random.monad}
+ [content-size (:: ! map (n.% 100) random.nat)]
+ (_binary.random content-size)))
+
+(def: package
+ (Random [Dependency Package])
+ (do {! random.monad}
+ [[identity profile pom] ..profile
+ type ..type
+ content ..content]
+ (wrap [{#//dependency.artifact identity
+ #//dependency.type type}
+ (//package.local pom content)])))
+
+(def: resolution
+ (Random Resolution)
+ (do {! random.monad}
+ [[main-dependency main-package] ..package
+ dependencies (|> (//package.dependencies main-package)
+ (:: try.monad map set.to-list)
+ (try.default (list))
+ (monad.map ! (function (_ dependency)
+ (do !
+ [pom (random.one (function (_ [identity profile pom])
+ (|> profile
+ (set@ #//.dependencies (set.new //dependency.hash))
+ (set@ #//.identity (#.Some (get@ #//dependency.artifact dependency)))
+ //pom.write
+ try.to-maybe))
+ ..profile)
+ content ..content]
+ (wrap [dependency
+ (//package.local pom content)])))))]
+ (wrap (dictionary.from-list //dependency.hash (list& [main-dependency main-package] dependencies)))))
+
+(def: singular
+ Test
+ (do {! random.monad}
+ [[dependency expected-package] ..package
+ #let [fs (: (file.System Promise)
+ (file.mock (:: file.default separator)))]]
+ (wrap (do promise.monad
+ [wrote! (/.write-one fs dependency expected-package)
+ read! (/.read-one fs dependency)]
+ (_.claim [/.write-one /.read-one]
+ (<| (try.default false)
+ (do try.monad
+ [_ wrote!
+ actual-package read!]
+ (wrap (:: //package.equivalence =
+ expected-package
+ actual-package)))))))))
+
+(def: plural
+ Test
+ (do {! random.monad}
+ [expected ..resolution
+ #let [fs (: (file.System Promise)
+ (file.mock (:: file.default separator)))]]
+ (wrap (do promise.monad
+ [wrote! (/.write-all fs expected)
+ read! (/.read-all fs (dictionary.keys expected) //dependency/resolution.empty)]
+ (_.claim [/.write-all /.read-all]
+ (<| (try.default false)
+ (do try.monad
+ [_ wrote!
+ actual read!]
+ (wrap (:: //dependency/resolution.equivalence =
+ expected
+ actual)))))))))
+
+(def: #export test
+ Test
+ (<| (_.covering /._)
+ ($_ _.and
+ ..singular
+ ..plural
+ )))
diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux
index 7f8a4557f..60a46116d 100644
--- a/stdlib/source/test/aedifex/command/install.lux
+++ b/stdlib/source/test/aedifex/command/install.lux
@@ -69,7 +69,7 @@
#let [fs (file.mock (:: file.default separator))]]
(wrap (case (get@ #///.identity sample)
(#.Some identity)
- (do {@ promise.monad}
+ (do {! promise.monad}
[verdict (do ///action.monad
[_ (..execute! fs sample)
#let [artifact-path (format (///local.path fs identity)
@@ -90,7 +90,7 @@
(try.default false verdict)))
#.None
- (do {@ promise.monad}
+ (do {! promise.monad}
[outcome (..execute! fs sample)]
(_.claim [/.do!]
(case outcome
diff --git a/stdlib/source/test/aedifex/command/pom.lux b/stdlib/source/test/aedifex/command/pom.lux
index cd0eed8e9..c973678cc 100644
--- a/stdlib/source/test/aedifex/command/pom.lux
+++ b/stdlib/source/test/aedifex/command/pom.lux
@@ -34,15 +34,15 @@
(do random.monad
[sample @profile.random
#let [fs (file.mock (:: file.default separator))]]
- (wrap (do {@ promise.monad}
+ (wrap (do {! promise.monad}
[outcome (/.do! fs sample)]
(case outcome
(#try.Success path)
- (do @
+ (do !
[verdict (do ///action.monad
[expected (|> (///pom.write sample)
(try@map (|>> (:: xml.codec encode) encoding.to-utf8))
- (:: @ wrap))
+ (:: ! wrap))
file (: (Promise (Try (File Promise)))
(file.get-file promise.monad fs path))
actual (!.use (:: file content) [])
diff --git a/stdlib/source/test/aedifex/hash.lux b/stdlib/source/test/aedifex/hash.lux
index bc6bb1b4b..745ec0910 100644
--- a/stdlib/source/test/aedifex/hash.lux
+++ b/stdlib/source/test/aedifex/hash.lux
@@ -29,9 +29,9 @@
(All [h]
(-> (-> Binary (/.Hash h))
(Random (/.Hash h))))
- (do {@ random.monad}
- [size (:: @ map (n.% 100) random.nat)]
- (:: @ map hash (_binary.random size))))
+ (do {! random.monad}
+ [size (:: ! map (n.% 100) random.nat)]
+ (:: ! map hash (_binary.random size))))
(def: #export test
Test
diff --git a/stdlib/source/test/aedifex/input.lux b/stdlib/source/test/aedifex/input.lux
index 50b99a218..b05d0afcb 100644
--- a/stdlib/source/test/aedifex/input.lux
+++ b/stdlib/source/test/aedifex/input.lux
@@ -31,8 +31,8 @@
(def: #export test
Test
(<| (_.covering /._)
- (do {@ random.monad}
- [expected (:: @ map (set@ #//.parents (list)) @profile.random)
+ (do {! random.monad}
+ [expected (:: ! map (set@ #//.parents (list)) @profile.random)
#let [fs (: (file.System Promise)
(file.mock (:: file.default separator)))]]
(wrap (do promise.monad
diff --git a/stdlib/source/test/aedifex/local.lux b/stdlib/source/test/aedifex/local.lux
index a883f565e..1c713684c 100644
--- a/stdlib/source/test/aedifex/local.lux
+++ b/stdlib/source/test/aedifex/local.lux
@@ -22,7 +22,7 @@
(def: #export test
Test
(<| (_.covering /._)
- (do {@ random.monad}
+ (do {! random.monad}
[sample @artifact.random
#let [fs (: (file.System Promise)
(file.mock (:: file.default separator)))]]
diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux
index 0c85156d2..e26240562 100644
--- a/stdlib/source/test/aedifex/parser.lux
+++ b/stdlib/source/test/aedifex/parser.lux
@@ -38,8 +38,8 @@
(def: (list-of random)
(All [a] (-> (Random a) (Random (List a))))
- (do {@ random.monad}
- [size (:: @ map (n.% 5) random.nat)]
+ (do {! random.monad}
+ [size (:: ! map (n.% 5) random.nat)]
(random.list size random)))
(def: (dictionary-of key-hash key-random value-random)
diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux
index 398a85f5b..d0da1ff2a 100644
--- a/stdlib/source/test/aedifex/profile.lux
+++ b/stdlib/source/test/aedifex/profile.lux
@@ -70,8 +70,8 @@
(def: (list-of random)
(All [a] (-> (Random a) (Random (List a))))
- (do {@ random.monad}
- [size (:: @ map (n.% 5) random.nat)]
+ (do {! random.monad}
+ [size (:: ! map (n.% 5) random.nat)]
(random.list size random)))
(def: (set-of hash random)