diff options
Diffstat (limited to '')
32 files changed, 244 insertions, 80 deletions
diff --git a/stdlib/source/test/aedifex.lux b/stdlib/source/test/aedifex.lux index 477ae4d50..e3c2bd1eb 100644 --- a/stdlib/source/test/aedifex.lux +++ b/stdlib/source/test/aedifex.lux @@ -20,9 +20,8 @@ ["#." pom] ["#." profile] ["#." project] - ## ["#." repository] - ## ["#." runtime] - ]) + ["#." repository] + ["#." runtime]]) (def: dependency Test @@ -48,9 +47,8 @@ /pom.test /profile.test /project.test - - ## /repository.test - ## /runtime.test + /repository.test + /runtime.test )) (program: args diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index 7fd8c3eb3..0e86ef946 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -43,7 +43,7 @@ (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) (#try.Success (: (shell.Simulation []) - (structure + (implementation (def: (on_read state) (exception.throw shell.no_more_output [])) (def: (on_error state) @@ -61,7 +61,7 @@ (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) (#try.Success (: (shell.Simulation []) - (structure + (implementation (def: (on_read state) (exception.throw shell.no_more_output [])) (def: (on_error state) diff --git a/stdlib/source/test/aedifex/command/test.lux b/stdlib/source/test/aedifex/command/test.lux index 291b31863..cad06aa69 100644 --- a/stdlib/source/test/aedifex/command/test.lux +++ b/stdlib/source/test/aedifex/command/test.lux @@ -84,7 +84,7 @@ (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) (#try.Success (: (shell.Simulation []) - (structure + (implementation (def: (on_read state) (exception.throw shell.no_more_output [])) (def: (on_error state) diff --git a/stdlib/source/test/aedifex/command/version.lux b/stdlib/source/test/aedifex/command/version.lux index c7a9aa4ef..079b0fde4 100644 --- a/stdlib/source/test/aedifex/command/version.lux +++ b/stdlib/source/test/aedifex/command/version.lux @@ -31,7 +31,7 @@ (exception: #export console_is_closed!) -(structure: simulation +(implementation: simulation (Simulation [Bit Text]) (def: (on_read [open? state]) diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index ae8c7699b..ebb32b790 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -59,7 +59,7 @@ (def: #export (single artifact package) (-> Artifact Package (Simulation Any)) (let [expected (///artifact.uri (get@ #///artifact.version artifact) artifact)] - (structure + (implementation (def: (on_download uri state) (if (text.contains? expected uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) @@ -122,7 +122,7 @@ (def: (bad_sha-1 expected_artifact expected_package dummy_package) (-> Artifact Package Package (Simulation Any)) - (structure + (implementation (def: (on_download uri state) (if (text.contains? (///artifact.uri (get@ #///artifact.version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) @@ -173,7 +173,7 @@ (def: (bad_md5 expected_artifact expected_package dummy_package) (-> Artifact Package Package (Simulation Any)) - (structure + (implementation (def: (on_download uri state) (if (text.contains? (///artifact.uri (get@ #///artifact.version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index df8db3e88..ed32f0ac3 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -30,6 +30,7 @@ ["$." /]} {#program ["." / + ["#." remote] ["/#" // #_ ["#." artifact (#+ Version Artifact) ["#/." extension (#+ Extension)]]]]}) @@ -42,6 +43,10 @@ (exception.report ["URI" (%.text uri)])) +(exception: (cannot_upload {uri URI}) + (exception.report + ["URI" (%.text uri)])) + (type: Store (Dictionary URI Binary)) @@ -49,27 +54,46 @@ Store (dictionary.new text.hash)) -(structure: #export simulation +(def: valid_version + Version + "1.2.3-YES") + +(def: invalid_version + Version + "4.5.6-NO") + +(implementation: #export simulation (/.Simulation Store) (def: (on_download uri state) (case (dictionary.get uri state) (#.Some content) - (exception.return [state content]) + (case (binary.size content) + 0 (exception.throw ..not_found [uri]) + _ (exception.return [state content])) #.None (exception.throw ..not_found [uri]))) (def: (on_upload uri content state) - (exception.return (dictionary.put uri content state)))) + (if (dictionary.key? state uri) + (exception.throw ..cannot_upload [uri]) + (exception.return (dictionary.put uri content state))))) (def: #export test Test (<| (_.covering /._) ($_ _.and (_.for [/.mock /.Simulation] - ($/.spec (..artifact "1.2.3-YES") - (..artifact "4.5.6-NO") - (/.mock ..simulation ..empty))) + (do random.monad + [_ (wrap [])] + ($/.spec (..artifact ..valid_version) + (..artifact ..invalid_version) + (/.mock ..simulation + (|> ..empty + (dictionary.put (/remote.uri ..invalid_version + (..artifact ..invalid_version) + //artifact/extension.lux_library) + (binary.create 0))))))) /identity.test /origin.test diff --git a/stdlib/source/test/aedifex/runtime.lux b/stdlib/source/test/aedifex/runtime.lux index 17b3428d2..0143eaac8 100644 --- a/stdlib/source/test/aedifex/runtime.lux +++ b/stdlib/source/test/aedifex/runtime.lux @@ -18,8 +18,9 @@ (`` ($_ _.and (~~ (template [<command>] [(_.cover [<command>] - (let [command (<command> path)] - (and (text.starts_with? (<command> "") command) + (let [command (text.join_with " " (#.Cons (<command> path))) + pure_command (text.join_with " " (#.Cons (<command> "")))] + (and (text.starts_with? pure_command command) (text.ends_with? path command))))] [/.java] diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index b2929de58..bc7231470 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -37,6 +37,7 @@ ["#." math] ["#." meta] ["#." program] + ["#." target] ["#." time] ## ["#." tool] ## TODO: Update & expand tests for this ["#." type] @@ -222,6 +223,7 @@ /math.test /meta.test /program.test + /target.test /time.test ## /tool.test /type.test diff --git a/stdlib/source/test/lux/abstract/codec.lux b/stdlib/source/test/lux/abstract/codec.lux index 1bbbcf460..1ac81f9d2 100644 --- a/stdlib/source/test/lux/abstract/codec.lux +++ b/stdlib/source/test/lux/abstract/codec.lux @@ -19,7 +19,7 @@ (def: json (Codec JSON Bit) (let [field "value"] - (structure + (implementation (def: encode (|>> #json.Boolean [field] diff --git a/stdlib/source/test/lux/abstract/equivalence.lux b/stdlib/source/test/lux/abstract/equivalence.lux index cceb75c42..cc6da47eb 100644 --- a/stdlib/source/test/lux/abstract/equivalence.lux +++ b/stdlib/source/test/lux/abstract/equivalence.lux @@ -27,7 +27,7 @@ sample random.nat different (|> random.nat (random.filter (|>> (n.= sample) not))) #let [equivalence (: (Equivalence (Equivalence Nat)) - (structure + (implementation (def: (= left right) (and (bit\= (\ left = leftN leftN) (\ right = leftN leftN)) @@ -42,7 +42,7 @@ (_.cover [/.rec] (let [equivalence (: (Equivalence (List Nat)) (/.rec (function (_ equivalence) - (structure + (implementation (def: (= left right) (case [left right] [#.Nil #.Nil] diff --git a/stdlib/source/test/lux/abstract/hash.lux b/stdlib/source/test/lux/abstract/hash.lux index c527fb9c9..d9ddadabe 100644 --- a/stdlib/source/test/lux/abstract/hash.lux +++ b/stdlib/source/test/lux/abstract/hash.lux @@ -24,7 +24,7 @@ [leftN random.nat rightN random.nat #let [hash (: (Equivalence (/.Hash Nat)) - (structure + (implementation (def: (= (^open "left\.") (^open "right\.")) (and (bit\= (left\= (left\hash leftN) (left\hash leftN)) (right\= (right\hash leftN) (right\hash leftN))) diff --git a/stdlib/source/test/lux/abstract/order.lux b/stdlib/source/test/lux/abstract/order.lux index e9121353a..495db63e8 100644 --- a/stdlib/source/test/lux/abstract/order.lux +++ b/stdlib/source/test/lux/abstract/order.lux @@ -25,7 +25,7 @@ [left random.nat right (|> random.nat (random.filter (|>> (n.= left) not))) #let [equivalence (: (Equivalence (/.Order Nat)) - (structure + (implementation (def: (= leftO rightO) (and (bit\= (\ leftO < left left) (\ rightO < left left)) diff --git a/stdlib/source/test/lux/abstract/predicate.lux b/stdlib/source/test/lux/abstract/predicate.lux index be2953aba..cf8ee5ad5 100644 --- a/stdlib/source/test/lux/abstract/predicate.lux +++ b/stdlib/source/test/lux/abstract/predicate.lux @@ -35,7 +35,7 @@ [sample random.nat samples (random.list 10 random.nat) #let [equivalence (: (Equivalence (/.Predicate Nat)) - (structure + (implementation (def: (= left right) (bit\= (left sample) (right sample)))))]]) diff --git a/stdlib/source/test/lux/control/function.lux b/stdlib/source/test/lux/control/function.lux index 354433cc8..f1730629c 100644 --- a/stdlib/source/test/lux/control/function.lux +++ b/stdlib/source/test/lux/control/function.lux @@ -32,7 +32,7 @@ (<| (_.covering /._) ($_ _.and (let [equivalence (: (Equivalence (-> Nat Nat)) - (structure + (implementation (def: (= left right) (n.= (left extra) (right extra))))) diff --git a/stdlib/source/test/lux/control/function/mixin.lux b/stdlib/source/test/lux/control/function/mixin.lux index 8ca196ba5..ed6ba8591 100644 --- a/stdlib/source/test/lux/control/function/mixin.lux +++ b/stdlib/source/test/lux/control/function/mixin.lux @@ -29,7 +29,7 @@ dummy random.nat shift (|> random.nat (random.filter (|>> (n.= dummy) not))) #let [equivalence (: (Equivalence (/.Mixin Nat Nat)) - (structure + (implementation (def: (= left right) (n.= ((/.mixin left) input) ((/.mixin right) input))))) diff --git a/stdlib/source/test/lux/control/parser/binary.lux b/stdlib/source/test/lux/control/parser/binary.lux index 943b8b3d5..5311ccdb3 100644 --- a/stdlib/source/test/lux/control/parser/binary.lux +++ b/stdlib/source/test/lux/control/parser/binary.lux @@ -70,7 +70,7 @@ (Random Name) (random.and ..random_text ..random_text)) -(structure: location_equivalence +(implementation: location_equivalence (Equivalence Location) (def: (= [expected_module expected_line expected_column] diff --git a/stdlib/source/test/lux/control/security/policy.lux b/stdlib/source/test/lux/control/security/policy.lux index 9c72304d9..c4c0657e7 100644 --- a/stdlib/source/test/lux/control/security/policy.lux +++ b/stdlib/source/test/lux/control/security/policy.lux @@ -35,7 +35,7 @@ (type: Password (Private Text)) -(signature: (Policy %) +(interface: (Policy %) (: (Hash (Password %)) &hash) @@ -50,13 +50,14 @@ (/.with_policy (: (Context Privacy Policy) (function (_ (^@ privilege (^open "%\."))) - (structure + (implementation (def: &hash - (structure + (implementation (def: &equivalence - (structure (def: (= reference sample) - (text\= (!.use %\can_downgrade reference) - (!.use %\can_downgrade sample))))) + (implementation + (def: (= reference sample) + (text\= (!.use %\can_downgrade reference) + (!.use %\can_downgrade sample))))) (def: hash (|>> (!.use %\can_downgrade) (\ text.hash hash))))) diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux index 92705210b..d4ba74ed7 100644 --- a/stdlib/source/test/lux/data/collection/dictionary.lux +++ b/stdlib/source/test/lux/data/collection/dictionary.lux @@ -54,7 +54,7 @@ (do ! [constant random.nat #let [hash (: (Hash Nat) - (structure + (implementation (def: &equivalence n.equivalence) (def: (hash _) constant)))]] diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux index 013936731..d10ee90cc 100644 --- a/stdlib/source/test/lux/data/collection/sequence.lux +++ b/stdlib/source/test/lux/data/collection/sequence.lux @@ -21,7 +21,7 @@ {1 ["." /]}) -(structure: (equivalence super) +(implementation: (equivalence super) (All [a] (-> (Equivalence a) (Equivalence (/.Sequence a)))) (def: (= reference subject) diff --git a/stdlib/source/test/lux/data/collection/set.lux b/stdlib/source/test/lux/data/collection/set.lux index 282749f5e..a0d7e446b 100644 --- a/stdlib/source/test/lux/data/collection/set.lux +++ b/stdlib/source/test/lux/data/collection/set.lux @@ -54,7 +54,7 @@ (do ! [hash (\ ! map (function (_ constant) (: (Hash Nat) - (structure + (implementation (def: &equivalence n.equivalence) (def: (hash _) diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index a8119145b..50b1c1fd6 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -21,10 +21,10 @@ ["f" frac] ["r" rev]]]] {1 - ["." / (#+ Color)]}) + ["." /]}) (def: #export random - (Random Color) + (Random /.Color) (|> ($_ random.and random.nat random.nat random.nat) (\ random.monad map /.from_rgb))) @@ -32,8 +32,13 @@ (-> Nat Frac) (|>> .int int.frac)) -(def: square (-> Frac Frac) (math.pow +2.0)) -(def: square_root (-> Frac Frac) (math.pow +0.5)) +(def: square + (-> Frac Frac) + (math.pow +2.0)) + +(def: square_root + (-> Frac Frac) + (math.pow +0.5)) (def: (distance/1 from to) (-> Frac Frac Frac) @@ -42,7 +47,7 @@ (f.- from to)))) (def: (distance/3 from to) - (-> Color Color Frac) + (-> /.Color /.Color Frac) (let [[fr fg fb] (/.to_rgb from) [tr tg tb] (/.to_rgb to)] (square_root @@ -55,7 +60,7 @@ (template [<field>] [(def: (<field> color) - (-> Color Frac) + (-> /.Color Frac) (let [[hue saturation luminance] (/.to_hsl color)] <field>))] diff --git a/stdlib/source/test/lux/data/format/binary.lux b/stdlib/source/test/lux/data/format/binary.lux index 6cc42d90d..c667c6070 100644 --- a/stdlib/source/test/lux/data/format/binary.lux +++ b/stdlib/source/test/lux/data/format/binary.lux @@ -14,7 +14,7 @@ {1 ["." /]}) -(structure: equivalence +(implementation: equivalence (Equivalence /.Specification) (def: (= reference subject) diff --git a/stdlib/source/test/lux/data/text/format.lux b/stdlib/source/test/lux/data/text/format.lux index 8b1e9a700..1f0c2c9e6 100644 --- a/stdlib/source/test/lux/data/text/format.lux +++ b/stdlib/source/test/lux/data/text/format.lux @@ -50,7 +50,7 @@ {1 ["." /]}) -(structure: (equivalence example) +(implementation: (equivalence example) (All [a] (-> a (Equivalence (/.Format a)))) (def: (= reference subject) diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index 9edaecd0c..d2686f3ba 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -12,34 +12,34 @@ ["i" int]]] ["_" test (#+ Test)]] {1 - ["." / (#+ import: class: interface: object)]}) + ["." /]}) -(import: (java/util/concurrent/Callable a)) +(/.import: (java/util/concurrent/Callable a)) -(import: java/lang/Long) +(/.import: java/lang/Long) -(import: java/lang/String) +(/.import: java/lang/String) -(import: java/lang/Exception +(/.import: java/lang/Exception ["#::." (new [java/lang/String])]) -(import: java/lang/Object) +(/.import: java/lang/Object) -(import: (java/lang/Class a) +(/.import: (java/lang/Class a) ["#::." (getName [] java/lang/String)]) -(import: java/lang/Runnable) +(/.import: java/lang/Runnable) -(import: java/lang/System +(/.import: java/lang/System ["#::." (#static out java/io/PrintStream) (#static currentTimeMillis [] #io long) (#static getenv [java/lang/String] #io #? java/lang/String)]) -## TODO: Handle "class:" ASAP. -## (class: #final (TestClass A) [java/lang/Runnable] +## TODO: Handle "/.class:" ASAP. +## (/.class: #final (TestClass A) [java/lang/Runnable] ## ## Fields ## (#private foo boolean) ## (#private bar A) @@ -58,20 +58,20 @@ ## [])) (def: test_runnable - (object [] [java/lang/Runnable] + (/.object [] [java/lang/Runnable] [] (java/lang/Runnable [] (run self) void []))) (def: test_callable - (object [a] [(java/util/concurrent/Callable a)] + (/.object [a] [(java/util/concurrent/Callable a)] [] ((java/util/concurrent/Callable a) [] (call self) a #throws [java/lang/Exception] (undefined)))) -## (interface: TestInterface +## (/.interface: TestInterface ## ([] foo [boolean java/lang/String] void #throws [java/lang/Exception])) (def: conversions diff --git a/stdlib/source/test/lux/ffi.old.lux b/stdlib/source/test/lux/ffi.old.lux index b14dac30d..37eb2c103 100644 --- a/stdlib/source/test/lux/ffi.old.lux +++ b/stdlib/source/test/lux/ffi.old.lux @@ -12,30 +12,30 @@ ["i" int]]] ["_" test (#+ Test)]] {1 - ["." / (#+ import: class: interface: object)]}) + ["." /]}) -(import: (java/util/concurrent/Callable a)) +(/.import: (java/util/concurrent/Callable a)) -(import: java/lang/Object) -(import: java/lang/String) +(/.import: java/lang/Object) +(/.import: java/lang/String) -(import: java/lang/Exception +(/.import: java/lang/Exception ["#::." (new [java/lang/String])]) -(import: java/lang/Runnable) +(/.import: java/lang/Runnable) -(import: (java/lang/Class a) +(/.import: (java/lang/Class a) ["#::." (getName [] java/lang/String)]) -(import: java/lang/System +(/.import: java/lang/System ["#::." (#static out java/io/PrintStream) (#static currentTimeMillis [] #io long) (#static getenv [java/lang/String] #io #? java/lang/String)]) -(class: #final (TestClass A) [java/lang/Runnable] +(/.class: #final (TestClass A) [java/lang/Runnable] ## Fields (#private foo boolean) (#private bar A) @@ -54,18 +54,18 @@ [])) (def: test_runnable - (object [] [java/lang/Runnable] + (/.object [] [java/lang/Runnable] [] (java/lang/Runnable [] (run self) void []))) (def: test_callable - (object [a] [(java/util/concurrent/Callable a)] + (/.object [a] [(java/util/concurrent/Callable a)] [] (java/util/concurrent/Callable [] (call self) a (undefined)))) -(interface: TestInterface +(/.interface: TestInterface ([] foo [boolean java/lang/String] void #throws [java/lang/Exception])) (def: conversions diff --git a/stdlib/source/test/lux/math/logic/fuzzy.lux b/stdlib/source/test/lux/math/logic/fuzzy.lux index 58587ad95..bb2d7184c 100644 --- a/stdlib/source/test/lux/math/logic/fuzzy.lux +++ b/stdlib/source/test/lux/math/logic/fuzzy.lux @@ -340,7 +340,7 @@ [sample random.rev [_ fuzzy] ..gradient #let [equivalence (: (Equivalence (/.Fuzzy Rev)) - (structure + (implementation (def: (= left right) (r.= (left sample) (right sample)))))]] diff --git a/stdlib/source/test/lux/meta/annotation.lux b/stdlib/source/test/lux/meta/annotation.lux index 51b33a70b..01f410b92 100644 --- a/stdlib/source/test/lux/meta/annotation.lux +++ b/stdlib/source/test/lux/meta/annotation.lux @@ -112,7 +112,7 @@ (..annotation key) <definition>)))))] - [/.structure? #.struct?] + [/.implementation? #.implementation?] [/.recursive_type? #.type-rec?] [/.signature? #.sig?] )) diff --git a/stdlib/source/test/lux/target.lux b/stdlib/source/test/lux/target.lux new file mode 100644 index 000000000..6f6050e1c --- /dev/null +++ b/stdlib/source/test/lux/target.lux @@ -0,0 +1,45 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [data + ["." text] + [collection + ["." list] + ["." set (#+ Set)]]] + [math + [number + ["n" nat]]]] + {1 + ["." /]}) + +(with_expansions [<targets> (as_is /.old + /.js + /.jvm + /.lua + /.python + /.ruby + /.common_lisp + /.php + /.r + /.scheme)] + (def: all + (List /.Target) + (list <targets>)) + + (def: unique + (Set /.Target) + (set.from_list text.hash ..all)) + + (def: verdict + (n.= (list.size ..all) + (set.size ..unique))) + + (def: #export test + Test + (<| (_.covering /._) + (_.for [/.Target]) + ($_ _.and + (_.cover [<targets>] + ..verdict) + ))) + ) diff --git a/stdlib/source/test/lux/world.lux b/stdlib/source/test/lux/world.lux index 62e0fc397..47e4ceb27 100644 --- a/stdlib/source/test/lux/world.lux +++ b/stdlib/source/test/lux/world.lux @@ -10,7 +10,10 @@ ["#/." keyboard]] ["#." output #_ ["#/." video #_ - ["#/." resolution]]]]) + ["#/." resolution]]] + ["#." net #_ + ["#/." http #_ + ["#/." client]]]]) (def: #export test Test @@ -21,4 +24,5 @@ /program.test /input/keyboard.test /output/video/resolution.test + /net/http/client.test )) diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux index 6c71f913c..56e3902f0 100644 --- a/stdlib/source/test/lux/world/console.lux +++ b/stdlib/source/test/lux/world/console.lux @@ -23,7 +23,7 @@ (def: simulation (/.Simulation [Bit Text]) - (structure + (implementation (def: (on_read [dead? content]) (do try.monad [char (try.from_maybe (text.nth 0 content)) diff --git a/stdlib/source/test/lux/world/net/http/client.lux b/stdlib/source/test/lux/world/net/http/client.lux new file mode 100644 index 000000000..0ac51bad0 --- /dev/null +++ b/stdlib/source/test/lux/world/net/http/client.lux @@ -0,0 +1,84 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + [pipe (#+ do>)] + ["." io (#+ IO)] + ["." try] + ["." function]] + [data + ["." binary] + ["." product] + [text + ["%" format (#+ format)] + [encoding + ["." utf8]]]] + [math + ["." random (#+ Random)] + [number + ["." nat]]]] + {1 + ["." / + ["/#" // + ["#." status]]]}) + +(def: #export test + Test + (<| (_.covering /._) + (_.for [/.Client]) + (do random.monad + [on_post random.nat + on_get random.nat + on_put random.nat + on_patch random.nat + on_delete random.nat + on_head random.nat + on_connect random.nat + on_options random.nat + on_trace random.nat + #let [mock (: (/.Client IO) + (implementation + (def: (request method url headers data) + (io.io (let [value (case method + #//.Post on_post + #//.Get on_get + #//.Put on_put + #//.Patch on_patch + #//.Delete on_delete + #//.Head on_head + #//.Connect on_connect + #//.Options on_options + #//.Trace on_trace) + data (|> value + (\ nat.decimal encode) + (\ utf8.codec encode))] + (#try.Success [//status.ok + {#//.headers headers + #//.body (function (_ ?wanted_bytes) + (io.io (#try.Success [(binary.size data) + data])))}]))))))]] + (`` ($_ _.and + (~~ (template [<definition> <expected>] + [(_.cover [<definition>] + (|> (<definition> "" //.empty #.None mock) + (do> try.monad + [io.run] + [product.right (get@ #//.body) (function.apply #.None) io.run] + [product.right (\ utf8.codec decode)] + [(\ nat.decimal decode)] + [(nat.= <expected>) wrap]) + (try.default false)))] + + [/.post on_post] + [/.get on_get] + [/.put on_put] + [/.patch on_patch] + [/.delete on_delete] + [/.head on_head] + [/.connect on_connect] + [/.options on_options] + [/.trace on_trace] + )) + ))))) diff --git a/stdlib/source/test/lux/world/shell.lux b/stdlib/source/test/lux/world/shell.lux index fa7d77f22..334250a96 100644 --- a/stdlib/source/test/lux/world/shell.lux +++ b/stdlib/source/test/lux/world/shell.lux @@ -35,7 +35,7 @@ (def: (simulation [environment working_directory command arguments]) (-> [Environment Path /.Command (List /.Argument)] (/.Simulation Bit)) - (structure + (implementation (def: (on_read dead?) (if dead? (exception.throw ..dead []) @@ -65,14 +65,14 @@ (def: (io_shell command oops input destruction exit) (-> /.Command Text Text Text /.Exit (/.Shell IO)) - (structure + (implementation (def: execute ((debug.private /.can_execute) (function (_ [environment working_directory command arguments]) (io.io (#try.Success (: (/.Process IO) - (structure + (implementation (def: read ((debug.private /.can_read) (function (_ _) |