(.module: [library [lux "*" ["_" test {"+" [Test]}] [abstract [monad {"+" [do]}] [\\specification ["$." equivalence]]] [control [pipe {"+" [case>]}] ["." try] [parser ["." cli]]] [data ["." text] [collection ["." list]]] [math ["." random {"+" [Random]} ("#\." monad)]]]] [\\program ["." / ["/#" // "_" ["#" profile]]]]) (def: compilation (Random /.Compilation) (random.or (random\in []) (random\in []))) (def: command (Random /.Command) ($_ random.or ... #Version (random\in []) ... #Clean (random\in []) ... #POM (random\in []) ... #Dependencies (random\in []) ... #Install (random\in []) ... #Deploy ($_ random.and (random.ascii/alpha 1) (random.ascii/alpha 1) (random.ascii/alpha 1)) ... #Compilation ..compilation ... #Auto ..compilation)) (def: (compilation_format value) (-> /.Compilation (List Text)) (case value #/.Build (list "build") #/.Test (list "test"))) (def: (format value) (-> /.Command (List Text)) (case 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& "auto" (..compilation_format compilation)))) (def: without_profile Test (do random.monad [expected ..command] (_.test "Without profile." (|> expected ..format (cli.result /.command) (case> (#try.Success [names actual]) (and (\ (list.equivalence text.equivalence) = (list //.default) names) (\ /.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.result /.command) (case> (#try.Success [actual_profile actual_command]) (and (\ (list.equivalence text.equivalence) = (list expected_profile //.default) actual_profile) (\ /.equivalence = expected_command actual_command)) (#try.Failure error) false))))) (def: .public test Test (<| (_.covering /._) (_.for [/.Compilation /.Command] ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..command)) (_.for [/.command] ($_ _.and ..without_profile ..with_profile ))))))