(.require [library [lux (.except) [abstract [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]]] [control ["[0]" pipe] ["[0]" try]] [data ["[0]" text] [collection ["[0]" list]]] [math ["[0]" random (.only Random) (.use "[1]#[0]" monad)]] [program ["cli" \\parser]] [test ["_" property (.only Test)]]]] [\\program ["[0]" / (.only) ["/[1]" // ["[1]" profile]]]]) (def compilation (Random /.Compilation) (random.or (random#in []) (random#in []))) (def command (Random /.Command) (all random.or ... #Version (random#in []) ... #Clean (random#in []) ... #POM (random#in []) ... #Dependencies (random#in []) ... #Install (random#in []) ... #Deploy (all random.and (random.alphabetic 1) (random.alphabetic 1) (random.alphabetic 1)) ... #Compilation ..compilation ... #Auto ..compilation)) (def (compilation_format value) (-> /.Compilation (List Text)) (when value {/.#Build} (list "build") {/.#Test} (list "test"))) (def (format value) (-> /.Command (List Text)) (when value {/.#Version} (list "version") {/.#Clean} (list "clean") {/.#POM} (list "pom") {/.#Dependencies} (list "deps") {/.#Install} (list "install") {/.#Deploy repository [user password]} (list "deploy" repository user password) {/.#Compilation compilation} (..compilation_format compilation) {/.#Auto compilation} (list.partial "auto" (..compilation_format compilation)))) (def without_profile Test (do random.monad [expected ..command] (_.test "Without profile." (|> expected ..format (cli.result /.command) (pipe.when {try.#Success [names actual]} (and (of (list.equivalence text.equivalence) = (list) names) (of /.equivalence = expected actual)) {try.#Failure error} false))))) (def with_profile Test (do random.monad [expected_profile (random.alphabetic 1) expected_command ..command] (_.test "With profile." (|> expected_command ..format (list.partial "with" expected_profile) (cli.result /.command) (pipe.when {try.#Success [actual_profile actual_command]} (and (of (list.equivalence text.equivalence) = (list expected_profile) actual_profile) (of /.equivalence = expected_command actual_command)) {try.#Failure error} false))))) (def .public test Test (<| (_.covering /._) (_.for [/.Compilation /.#Build /.#Test /.Command /.#Version /.#Clean /.#POM /.#Dependencies /.#Install /.#Deploy /.#Compilation /.#Auto] (all _.and (_.for [/.equivalence] (equivalenceT.spec /.equivalence ..command)) (_.for [/.command] (all _.and ..without_profile ..with_profile ))))))