aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex
diff options
context:
space:
mode:
authorEduardo Julian2020-10-09 01:16:47 -0400
committerEduardo Julian2020-10-09 01:16:47 -0400
commitbae39f32cddb816a6123697269c20dbf4a65ac19 (patch)
treed9ee53073ebe0d83e29dbd24e0dda8d5dd95dc47 /stdlib/source/test/aedifex
parent79aa92dfd81d569fe6120b8e5c00d41528801153 (diff)
Also using BIPUSH and SIPUSH during JVM generation.
Diffstat (limited to 'stdlib/source/test/aedifex')
-rw-r--r--stdlib/source/test/aedifex/cli.lux108
-rw-r--r--stdlib/source/test/aedifex/parser.lux108
-rw-r--r--stdlib/source/test/aedifex/profile.lux154
3 files changed, 269 insertions, 101 deletions
diff --git a/stdlib/source/test/aedifex/cli.lux b/stdlib/source/test/aedifex/cli.lux
new file mode 100644
index 000000000..dfbf0b7a9
--- /dev/null
+++ b/stdlib/source/test/aedifex/cli.lux
@@ -0,0 +1,108 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]
+ {[0 #spec]
+ [/
+ ["$." equivalence]]}]
+ [control
+ [pipe (#+ case>)]
+ ["." try]
+ [parser
+ ["." cli]]]
+ [data
+ ["." text ("#@." equivalence)]]
+ [math
+ ["." random (#+ Random) ("#@." monad)]]]
+ {#program
+ ["." /
+ ["/#" // #_
+ ["#" profile]
+ [upload (#+ User Password)]]]})
+
+(def: compilation
+ (Random /.Compilation)
+ (random.or (random@wrap [])
+ (random@wrap [])))
+
+(def: command
+ (Random /.Command)
+ ($_ random.or
+ ## #POM
+ (random@wrap [])
+ ## #Dependencies
+ (random@wrap [])
+ ## #Install
+ (random@wrap [])
+ ## #Deploy
+ ($_ random.and
+ (random.ascii/alpha 1)
+ (random.ascii/alpha 1)
+ (random.ascii/alpha 1))
+ ## #Compilation
+ ..compilation
+ ## #Auto
+ ..compilation))
+
+(def: (format-compilation value)
+ (-> /.Compilation (List Text))
+ (case value
+ #/.Build (list "build")
+ #/.Test (list "test")))
+
+(def: (format value)
+ (-> /.Command (List Text))
+ (case value
+ #/.POM (list "pom")
+ #/.Dependencies (list "deps")
+ #/.Install (list "install")
+ (#/.Deploy repository user password) (list "deploy" repository user password)
+ (#/.Compilation compilation) (..format-compilation compilation)
+ (#/.Auto compilation) (list& "auto" (..format-compilation compilation))))
+
+(def: without-profile
+ Test
+ (do random.monad
+ [expected ..command]
+ (_.test "Without profile."
+ (|> expected
+ ..format
+ (cli.run /.command)
+ (case> (#try.Success [name actual])
+ (and (text@= //.default name)
+ (:: /.equivalence = expected actual))
+
+ (#try.Failure error)
+ false)))))
+
+(def: with-profile
+ Test
+ (do random.monad
+ [expected-profile (random.ascii/alpha 1)
+ expected-command ..command]
+ (_.test "With profile."
+ (|> expected-command
+ ..format
+ (list& "with" expected-profile)
+ (cli.run /.command)
+ (case> (#try.Success [actual-profile actual-command])
+ (and (text@= expected-profile actual-profile)
+ (:: /.equivalence = expected-command actual-command))
+
+ (#try.Failure error)
+ false)))))
+
+(def: #export test
+ Test
+ (<| (_.covering /._)
+ (_.with-cover [/.Compilation /.Command]
+ ($_ _.and
+ (_.with-cover [/.equivalence]
+ ($equivalence.spec /.equivalence ..command))
+
+ (_.with-cover [/.command]
+ ($_ _.and
+ ..without-profile
+ ..with-profile
+ ))))))
diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux
index 97895a201..988883779 100644
--- a/stdlib/source/test/aedifex/parser.lux
+++ b/stdlib/source/test/aedifex/parser.lux
@@ -10,8 +10,7 @@
[parser
["<c>" code]]]
[data
- ["." text
- ["%" format (#+ format)]]
+ ["." text]
[number
["n" nat]]
[collection
@@ -22,6 +21,8 @@
["." random (#+ Random) ("#@." monad)]]
[macro
["." code]]]
+ [//
+ ["_." profile]]
{#program
["." /
["/#" // #_
@@ -31,120 +32,25 @@
["#." dependency (#+ Repository Dependency)]
["#." format]]]})
-(def: distribution
- (Random //.Distribution)
- (random.or (random@wrap [])
- (random@wrap [])))
-
-(def: license
- (Random //.License)
- ($_ random.and
- (random.ascii/alpha 1)
- (random.ascii/alpha 1)
- ..distribution))
-
-(def: scm
- (Random //.SCM)
- (random.ascii/alpha 1))
-
-(def: organization
- (Random //.Organization)
- ($_ random.and
- (random.ascii/alpha 1)
- (random.ascii/alpha 1)))
-
-(def: email
- (Random //.Email)
+(def: name
+ (Random //.Name)
(random.ascii/alpha 1))
-(def: developer
- (Random //.Developer)
- ($_ random.and
- (random.ascii/alpha 1)
- (random.ascii/alpha 1)
- (random.maybe organization)))
-
-(def: contributor
- (Random //.Contributor)
- ..developer)
-
(def: (list-of random)
(All [a] (-> (Random a) (Random (List a))))
(do {@ random.monad}
[size (:: @ map (n.% 5) random.nat)]
(random.list size random)))
-(def: (set-of hash random)
- (All [a] (-> (Hash a) (Random a) (Random (Set a))))
- (:: random.functor map
- (set.from-list hash)
- (..list-of random)))
-
(def: (dictionary-of key-hash key-random value-random)
(All [k v] (-> (Hash k) (Random k) (Random v) (Random (Dictionary k v))))
(:: random.functor map
(dictionary.from-list key-hash)
(..list-of (random.and key-random value-random))))
-(def: info
- (Random //.Info)
- ($_ random.and
- (random.maybe (random.ascii/alpha 1))
- (random.maybe ..scm)
- (random.maybe (random.ascii/alpha 1))
- (..list-of ..license)
- (random.maybe ..organization)
- (..list-of ..developer)
- (..list-of ..contributor)
- ))
-
-(def: name
- (Random //.Name)
- (random.ascii/alpha 1))
-
-(def: artifact
- (Random Artifact)
- ($_ random.and
- (random.ascii/alpha 1)
- (random.ascii/alpha 1)
- (random.ascii/alpha 1)))
-
-(def: repository
- (Random Repository)
- (random.ascii/alpha 1))
-
-(def: dependency
- (Random Dependency)
- ($_ random.and
- ..artifact
- (random.ascii/alpha 1)))
-
-(def: source
- (Random //.Source)
- (random.ascii/alpha 1))
-
-(def: target
- (Random //.Target)
- (random.ascii/alpha 1))
-
-(def: profile
- (Random //.Profile)
- ($_ random.and
- (..list-of ..name)
- (random.maybe ..artifact)
- (random.maybe ..info)
- (..set-of text.hash ..repository)
- (..set-of //dependency.hash ..dependency)
- (..set-of text.hash ..source)
- (random.maybe ..target)
- (random.maybe (random.ascii/alpha 1))
- (random.maybe (random.ascii/alpha 1))
- (..dictionary-of text.hash (random.ascii/alpha 1) ..repository)
- ))
-
(def: project
(Random Project)
- (..dictionary-of text.hash ..name ..profile))
+ (..dictionary-of text.hash ..name _profile.random))
(def: with-default-sources
(-> //.Profile //.Profile)
@@ -158,7 +64,7 @@
(def: single-profile
Test
(do random.monad
- [expected ..profile]
+ [expected _profile.random]
(_.test "Single profile."
(|> expected
//format.profile
diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux
new file mode 100644
index 000000000..3f1e08cc7
--- /dev/null
+++ b/stdlib/source/test/aedifex/profile.lux
@@ -0,0 +1,154 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]
+ [hash (#+ Hash)]
+ {[0 #spec]
+ [/
+ ["$." equivalence]
+ ["$." monoid]]}]
+ [control
+ [pipe (#+ case>)]
+ ["." try]
+ [parser
+ ["." cli]]]
+ [data
+ ["." text ("#@." equivalence)]
+ [number
+ ["n" nat]]
+ [collection
+ ["." set (#+ Set)]
+ ["." dictionary (#+ Dictionary)]]]
+ [math
+ ["." random (#+ Random) ("#@." monad)]]]
+ {#program
+ ["." /
+ ["/#" // #_
+ ["#." artifact (#+ Artifact)]
+ ["#." dependency (#+ Repository Dependency)]
+ ["#." format]]]})
+
+(def: distribution
+ (Random /.Distribution)
+ (random.or (random@wrap [])
+ (random@wrap [])))
+
+(def: license
+ (Random /.License)
+ ($_ random.and
+ (random.ascii/alpha 1)
+ (random.ascii/alpha 1)
+ ..distribution))
+
+(def: scm
+ (Random /.SCM)
+ (random.ascii/alpha 1))
+
+(def: organization
+ (Random /.Organization)
+ ($_ random.and
+ (random.ascii/alpha 1)
+ (random.ascii/alpha 1)))
+
+(def: email
+ (Random /.Email)
+ (random.ascii/alpha 1))
+
+(def: developer
+ (Random /.Developer)
+ ($_ random.and
+ (random.ascii/alpha 1)
+ (random.ascii/alpha 1)
+ (random.maybe organization)))
+
+(def: contributor
+ (Random /.Contributor)
+ ..developer)
+
+(def: (list-of random)
+ (All [a] (-> (Random a) (Random (List a))))
+ (do {@ random.monad}
+ [size (:: @ map (n.% 5) random.nat)]
+ (random.list size random)))
+
+(def: (set-of hash random)
+ (All [a] (-> (Hash a) (Random a) (Random (Set a))))
+ (:: random.functor map
+ (set.from-list hash)
+ (..list-of random)))
+
+(def: (dictionary-of key-hash key-random value-random)
+ (All [k v] (-> (Hash k) (Random k) (Random v) (Random (Dictionary k v))))
+ (:: random.functor map
+ (dictionary.from-list key-hash)
+ (..list-of (random.and key-random value-random))))
+
+(def: info
+ (Random /.Info)
+ ($_ random.and
+ (random.maybe (random.ascii/alpha 1))
+ (random.maybe ..scm)
+ (random.maybe (random.ascii/alpha 1))
+ (..list-of ..license)
+ (random.maybe ..organization)
+ (..list-of ..developer)
+ (..list-of ..contributor)
+ ))
+
+(def: name
+ (Random /.Name)
+ (random.ascii/alpha 1))
+
+(def: artifact
+ (Random Artifact)
+ ($_ random.and
+ (random.ascii/alpha 1)
+ (random.ascii/alpha 1)
+ (random.ascii/alpha 1)))
+
+(def: repository
+ (Random Repository)
+ (random.ascii/alpha 1))
+
+(def: dependency
+ (Random Dependency)
+ ($_ random.and
+ ..artifact
+ (random.ascii/alpha 1)))
+
+(def: source
+ (Random /.Source)
+ (random.ascii/alpha 1))
+
+(def: target
+ (Random /.Target)
+ (random.ascii/alpha 1))
+
+(def: #export random
+ (Random /.Profile)
+ ($_ random.and
+ (..list-of ..name)
+ (random.maybe ..artifact)
+ (random.maybe ..info)
+ (..set-of text.hash ..repository)
+ (..set-of //dependency.hash ..dependency)
+ (..set-of text.hash ..source)
+ (random.maybe ..target)
+ (random.maybe (random.ascii/alpha 1))
+ (random.maybe (random.ascii/alpha 1))
+ (..dictionary-of text.hash (random.ascii/alpha 1) ..repository)
+ ))
+
+(def: #export test
+ Test
+ (<| (_.covering /._)
+ (_.with-cover [/.Distribution /.License /.SCM /.Organization
+ /.Email /.Developer /.Contributor /.Info
+ /.Source /.Target /.Name /.Profile]
+ ($_ _.and
+ (_.with-cover [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+ (_.with-cover [/.monoid]
+ ($monoid.spec /.equivalence /.monoid ..random))
+ ))))