From 04c7f49a732380a2b9f72b1b937171b341c24323 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 9 Apr 2022 03:03:46 -0400 Subject: Better names for testing macros (plus better indentation). --- stdlib/source/test/lux.lux | 1378 ++++++++++++++++++++++---------------------- 1 file changed, 689 insertions(+), 689 deletions(-) (limited to 'stdlib/source/test/lux.lux') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 7d529f04e..fde45451b 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -78,60 +78,60 @@ dummy random.nat] (_.for [/.Bit /.if] (all _.and - (_.cover [/.false] - (n.= expected - (/.if /.false - dummy - expected))) - (_.cover [/.true] - (n.= expected - (/.if /.true - expected - dummy))) - (_.cover [/.or] - (and (not (/.or /.false /.false)) - (/.or /.false /.true) - (/.or /.true /.false) - (/.or /.true /.true))) - (_.cover [/.and] - (and (not (/.and /.false /.false)) - (not (/.and /.false /.true)) - (not (/.and /.true /.false)) - (/.and /.true /.true))) - (_.cover [/.not] - (and (bit#= /.true (/.not /.false)) - (bit#= /.false (/.not /.true)))) - (_.cover [/.cond] - (and (n.= expected - (/.cond /.true - expected - - ... else - dummy)) - (n.= expected - (/.cond /.false - dummy - - ... else - expected)) - (n.= expected - (/.cond /.true - expected - - /.false - dummy - - ... else - dummy)) - (n.= expected - (/.cond /.false - dummy - - /.true - expected - - ... else - dummy)))) + (_.coverage [/.false] + (n.= expected + (/.if /.false + dummy + expected))) + (_.coverage [/.true] + (n.= expected + (/.if /.true + expected + dummy))) + (_.coverage [/.or] + (and (not (/.or /.false /.false)) + (/.or /.false /.true) + (/.or /.true /.false) + (/.or /.true /.true))) + (_.coverage [/.and] + (and (not (/.and /.false /.false)) + (not (/.and /.false /.true)) + (not (/.and /.true /.false)) + (/.and /.true /.true))) + (_.coverage [/.not] + (and (bit#= /.true (/.not /.false)) + (bit#= /.false (/.not /.true)))) + (_.coverage [/.cond] + (and (n.= expected + (/.cond /.true + expected + + ... else + dummy)) + (n.= expected + (/.cond /.false + dummy + + ... else + expected)) + (n.= expected + (/.cond /.true + expected + + /.false + dummy + + ... else + dummy)) + (n.= expected + (/.cond /.false + dummy + + /.true + expected + + ... else + dummy)))) )))) (def: for_try @@ -140,27 +140,27 @@ [expected_error (random.lower_case 5) expected random.nat] (all _.and - (_.cover [/.try] - (case (/.try expected) - {.#Left _} - false - - {.#Right actual} - (n.= expected actual))) - (_.cover [/.undefined] - (case (/.try (/.undefined)) - {.#Left _} - true - - {.#Right _} - false)) - (_.cover [/.panic!] - (case (/.try (/.panic! expected_error)) - {.#Left actual_error} - (text.contains? expected_error actual_error) - - {.#Right _} - false)) + (_.coverage [/.try] + (case (/.try expected) + {.#Left _} + false + + {.#Right actual} + (n.= expected actual))) + (_.coverage [/.undefined] + (case (/.try (/.undefined)) + {.#Left _} + true + + {.#Right _} + false)) + (_.coverage [/.panic!] + (case (/.try (/.panic! expected_error)) + {.#Left actual_error} + (text.contains? expected_error actual_error) + + {.#Right _} + false)) ))) (def: for_list @@ -171,24 +171,24 @@ e/2 random.nat e/3 random.nat] (all _.and - (_.cover [/.list] - (case (/.list e/0 e/1) - (pattern (/.list a/0 a/1)) - (and (n.= e/0 a/0) - (n.= e/1 a/1)) - - _ - false)) - (_.cover [/.partial_list] - (case (/.partial_list e/0 e/1 (/.list e/2 e/3)) - (pattern (/.partial_list a/0 a/1 (/.list a/2 a/3))) - (and (n.= e/0 a/0) - (n.= e/1 a/1) - (n.= e/2 a/2) - (n.= e/3 a/3)) - - _ - false)) + (_.coverage [/.list] + (case (/.list e/0 e/1) + (pattern (/.list a/0 a/1)) + (and (n.= e/0 a/0) + (n.= e/1 a/1)) + + _ + false)) + (_.coverage [/.partial_list] + (case (/.partial_list e/0 e/1 (/.list e/2 e/3)) + (pattern (/.partial_list a/0 a/1 (/.list a/2 a/3))) + (and (n.= e/0 a/0) + (n.= e/1 a/1) + (n.= e/2 a/2) + (n.= e/3 a/3)) + + _ + false)) ))) (type: (Returner a) @@ -216,30 +216,30 @@ expected)))]] (_.for [/.Interface] (all _.and - (_.cover [/.implementation:] - (n.= expected (# (global_returner expected) return []))) - (_.cover [/.implementation] - (n.= expected (# local_returner return []))) - (_.cover [/.open:] - (n.= static_return (global#return []))) - (_.cover [/.open] - (let [(/.open "local#[0]") local_returner] - (n.= expected (local#return [])))) - (_.cover [/.#] - (n.= expected (/.# local_returner return []))) + (_.coverage [/.implementation:] + (n.= expected (# (global_returner expected) return []))) + (_.coverage [/.implementation] + (n.= expected (# local_returner return []))) + (_.coverage [/.open:] + (n.= static_return (global#return []))) + (_.coverage [/.open] + (let [(/.open "local#[0]") local_returner] + (n.= expected (local#return [])))) + (_.coverage [/.#] + (n.= expected (/.# local_returner return []))) )))) (def: for_module Test (all _.and (let [[module short] (/.symbol .example)] - (_.cover [/.symbol /.prelude_module] - (and (text#= /.prelude_module module) - (text#= short "example")))) + (_.coverage [/.symbol /.prelude_module] + (and (text#= /.prelude_module module) + (text#= short "example")))) (let [[module short] (/.symbol ..example)] - (_.cover [/.module_separator] - (and (text.contains? /.module_separator module) - (not (text.contains? /.module_separator short))))) + (_.coverage [/.module_separator] + (and (text.contains? /.module_separator module) + (not (text.contains? /.module_separator short))))) )) (def: for_pipe @@ -249,18 +249,18 @@ factor random.nat .let [expected (n.* factor (++ start))]] (all _.and - (_.cover [/.|>] - (n.= expected - (/.|> start ++ (n.* factor)))) - (_.cover [/.|>>] - (n.= expected - ((/.|>> ++ (n.* factor)) start))) - (_.cover [/.<|] - (n.= expected - (/.<| (n.* factor) ++ start))) - (_.cover [/.<<|] - (n.= expected - ((/.<<| (n.* factor) ++) start))) + (_.coverage [/.|>] + (n.= expected + (/.|> start ++ (n.* factor)))) + (_.coverage [/.|>>] + (n.= expected + ((/.|>> ++ (n.* factor)) start))) + (_.coverage [/.<|] + (n.= expected + (/.<| (n.* factor) ++ start))) + (_.coverage [/.<<|] + (n.= expected + ((/.<<| (n.* factor) ++) start))) ))) (def: example_symbol "YOLO") @@ -275,89 +275,89 @@ Test (do random.monad [example_nat random.nat] - (_.cover [/.'] - (and (code#= (code.nat 0) (/.' 0)) - (code#= (code.int -1) (/.' -1)) - (code#= (code.rev .2) (/.' .2)) - (code#= (code.frac +3.4) (/.' +3.4)) - (code#= (code.text "5") (/.' "5")) - (code#= (code.symbol ["" "example_symbol"]) - (/.' example_symbol)) - (code#= (code.symbol [/.prelude_module "example_symbol"]) - (/.' .example_symbol)) - (code#= (code.symbol [..current_module "example_symbol"]) - (/.' ..example_symbol)) - (code#= (code.form (list (code.nat 6) (code.int +7) (code.rev .8))) - (/.' (6 +7 .8))) - (code#= (code.variant (list (code.frac +9.0) - (code.text "9") - (code.symbol ["" "i8"]))) - (/.' {+9.0 "9" i8})) - (code#= (code.tuple (list (code.frac +9.0) - (code.text "9") - (code.symbol ["" "i8"]))) - (/.' [+9.0 "9" i8])) - (not (code#= (code.nat example_nat) - (/.' (~ (code.nat example_nat))))) - )))) + (_.coverage [/.'] + (and (code#= (code.nat 0) (/.' 0)) + (code#= (code.int -1) (/.' -1)) + (code#= (code.rev .2) (/.' .2)) + (code#= (code.frac +3.4) (/.' +3.4)) + (code#= (code.text "5") (/.' "5")) + (code#= (code.symbol ["" "example_symbol"]) + (/.' example_symbol)) + (code#= (code.symbol [/.prelude_module "example_symbol"]) + (/.' .example_symbol)) + (code#= (code.symbol [..current_module "example_symbol"]) + (/.' ..example_symbol)) + (code#= (code.form (list (code.nat 6) (code.int +7) (code.rev .8))) + (/.' (6 +7 .8))) + (code#= (code.variant (list (code.frac +9.0) + (code.text "9") + (code.symbol ["" "i8"]))) + (/.' {+9.0 "9" i8})) + (code#= (code.tuple (list (code.frac +9.0) + (code.text "9") + (code.symbol ["" "i8"]))) + (/.' [+9.0 "9" i8])) + (not (code#= (code.nat example_nat) + (/.' (~ (code.nat example_nat))))) + )))) (def: for_code/` Test (do random.monad [example_nat random.nat] - (_.cover [/.`] - (and (code#= (code.nat 0) (/.` 0)) - (code#= (code.int -1) (/.` -1)) - (code#= (code.rev .2) (/.` .2)) - (code#= (code.frac +3.4) (/.` +3.4)) - (code#= (code.text "5") (/.` "5")) - (code#= (code.symbol [..current_module "example_symbol"]) - (/.` example_symbol)) - (code#= (code.symbol [/.prelude_module "example_symbol"]) - (/.` .example_symbol)) - (code#= (code.symbol [..current_module "example_symbol"]) - (/.` ..example_symbol)) - (code#= (code.form (list (code.nat 6) (code.int +7) (code.rev .8))) - (/.` (6 +7 .8))) - (code#= (code.variant (list (code.frac +9.0) - (code.text "9") - (code.symbol [..current_module "i8"]))) - (/.` {+9.0 "9" i8})) - (code#= (code.tuple (list (code.frac +9.0) - (code.text "9") - (code.symbol [..current_module "i8"]))) - (/.` [+9.0 "9" i8])) - (code#= (code.nat example_nat) - (/.` (~ (code.nat example_nat)))))))) + (_.coverage [/.`] + (and (code#= (code.nat 0) (/.` 0)) + (code#= (code.int -1) (/.` -1)) + (code#= (code.rev .2) (/.` .2)) + (code#= (code.frac +3.4) (/.` +3.4)) + (code#= (code.text "5") (/.` "5")) + (code#= (code.symbol [..current_module "example_symbol"]) + (/.` example_symbol)) + (code#= (code.symbol [/.prelude_module "example_symbol"]) + (/.` .example_symbol)) + (code#= (code.symbol [..current_module "example_symbol"]) + (/.` ..example_symbol)) + (code#= (code.form (list (code.nat 6) (code.int +7) (code.rev .8))) + (/.` (6 +7 .8))) + (code#= (code.variant (list (code.frac +9.0) + (code.text "9") + (code.symbol [..current_module "i8"]))) + (/.` {+9.0 "9" i8})) + (code#= (code.tuple (list (code.frac +9.0) + (code.text "9") + (code.symbol [..current_module "i8"]))) + (/.` [+9.0 "9" i8])) + (code#= (code.nat example_nat) + (/.` (~ (code.nat example_nat)))))))) (def: for_code/`' Test (do random.monad [example_nat random.nat] - (_.cover [/.`'] - (and (code#= (code.nat 0) (/.`' 0)) - (code#= (code.int -1) (/.`' -1)) - (code#= (code.rev .2) (/.`' .2)) - (code#= (code.frac +3.4) (/.`' +3.4)) - (code#= (code.text "5") (/.`' "5")) - (code#= (code.symbol ["" "example_symbol"]) - (/.`' example_symbol)) - (code#= (code.symbol [/.prelude_module "example_symbol"]) - (/.`' .example_symbol)) - (code#= (code.symbol [..current_module "example_symbol"]) - (/.`' ..example_symbol)) - (code#= (code.form (list (code.nat 6) (code.int +7) (code.rev .8))) - (/.`' (6 +7 .8))) - (code#= (code.variant (list (code.frac +9.0) - (code.text "9") - (code.symbol ["" "i8"]))) - (/.`' {+9.0 "9" i8})) - (code#= (code.tuple (list (code.frac +9.0) - (code.text "9") - (code.symbol ["" "i8"]))) - (/.`' [+9.0 "9" i8])) - (code#= (code.nat example_nat) - (/.`' (~ (code.nat example_nat)))))))) + (_.coverage [/.`'] + (and (code#= (code.nat 0) (/.`' 0)) + (code#= (code.int -1) (/.`' -1)) + (code#= (code.rev .2) (/.`' .2)) + (code#= (code.frac +3.4) (/.`' +3.4)) + (code#= (code.text "5") (/.`' "5")) + (code#= (code.symbol ["" "example_symbol"]) + (/.`' example_symbol)) + (code#= (code.symbol [/.prelude_module "example_symbol"]) + (/.`' .example_symbol)) + (code#= (code.symbol [..current_module "example_symbol"]) + (/.`' ..example_symbol)) + (code#= (code.form (list (code.nat 6) (code.int +7) (code.rev .8))) + (/.`' (6 +7 .8))) + (code#= (code.variant (list (code.frac +9.0) + (code.text "9") + (code.symbol ["" "i8"]))) + (/.`' {+9.0 "9" i8})) + (code#= (code.tuple (list (code.frac +9.0) + (code.text "9") + (code.symbol ["" "i8"]))) + (/.`' [+9.0 "9" i8])) + (code#= (code.nat example_nat) + (/.`' (~ (code.nat example_nat)))))))) (def: for_code Test @@ -370,10 +370,10 @@ ..for_code/` ..for_code/`' )) - (_.cover [/.Ann] - (|> example - (the /.#meta) - (location#= location.dummy))) + (_.coverage [/.Ann] + (|> example + (the /.#meta) + (location#= location.dummy))) ))) (/.macro: (identity_macro tokens) @@ -410,130 +410,130 @@ (do random.monad [expected random.nat] (`` (`` (all _.and - (_.cover [/.Macro'] - (|> macro - (is /.Macro') - (same? macro))) - (_.cover [/.Macro] - (|> macro - "lux macro" - (is /.Macro) - (is Any) - (same? (is Any macro)))) - (_.cover [/.macro:] - (same? expected (..identity_macro expected))) + (_.coverage [/.Macro'] + (|> macro + (is /.Macro') + (same? macro))) + (_.coverage [/.Macro] + (|> macro + "lux macro" + (is /.Macro) + (is Any) + (same? (is Any macro)))) + (_.coverage [/.macro:] + (same? expected (..identity_macro expected))) (~~ (for @.old (~~ (these)) - (_.cover [/.Source] - (..found_crosshair?)))) - (_.cover [/.macro] - (with_expansions [n/0 (static.random_nat) - n/1 (static.random_nat) - n/1 (static.random_nat)] - (n.= (..sum n/0 n/1 n/1) - (..sum' n/0 n/1 n/1)))) - (_.cover [/.using] - (`` (with_expansions [ ("lux in-module" "library/lux" library/lux.refer) - (static.random code.text (random.lower_case 1)) - (static.random code.local (random.lower_case 1)) - (static.random code.text (random.lower_case 2)) - ' (template.symbol []) - (static.random code.text (random.lower_case 3)) - ' (template.symbol []) - (static.random code.text (random.lower_case 4)) - ' (template.symbol []) - (template.text [ "/" ]) - (template.text [// ']) - ' (template.symbol []) - <\\> (template.text [\\ ']) - <\\>' (template.symbol [<\\>]) - (template.text [ "/" ]) - (template.text [ "/" ]) - (template.text [ "/" "/" ]) - (template.text [ "#[0]"])] - (and (~~ (template [ ] - [(with_expansions [' (macro.final )] - (let [scenario (is (-> Any Bit) - (function (_ _) - ... TODO: Remove this hack once Jython is no longer being used as the Python interpreter. - (`` (for @.python (case (' [']) - (^.` [ - ("lux def" (~ [_ {.#Symbol ["" _]}]) [] #0) - (~~ (template.spliced ))]) - true - - _ - false) - (case (' [']) - (^.` [ (~~ (template.spliced ))]) - true - - _ - false)))))] - (scenario [])))] - - [(.using [']) - ("lux def module" []) - []] - - [(.using [ ' "*"]) - ("lux def module" [[ ]]) - [( "*")]] - - [(.using [ ' {"+" }]) - ("lux def module" [[ ]]) - [( {"+" })]] - - [(.using [ ' {"-" }]) - ("lux def module" [[ ]]) - [( {"-" })]] - - [(.using [ ' "_"]) - ("lux def module" []) - []] - - [(.using [' - [ ']]) - ("lux def module" [[ ]]) - [( )]] - - [(.using ["[0]" ' - ["[0]" ']]) - ("lux def module" [[ ] - [ ]]) - [( ) - ( )]] - - [(.using ["[0]" ' "_" - ["[1]" ']]) - ("lux def module" [[ ]]) - [( )]] - - [(.using ["[0]" ' "_" - ["[1]" ' "_" - ["[2]" ']]]) - ("lux def module" [[ ]]) - [( )]] - - [(.using [' - ["[0]" ' - ["[0]" ']]]) - ("lux def module" [[ ] - [ ]]) - [( ) - ( )]] - - [(.using ["[0]" ' - [' - ["[0]" <\\>']]]) - ("lux def module" [[ ] - [ <\\>]]) - [( ) - ( )]] - - [(.using ["[0]" ' ("[1]#[0]" )]) - ("lux def module" [[ ]]) - [( ( ))]] - )))))) + (_.coverage [/.Source] + (..found_crosshair?)))) + (_.coverage [/.macro] + (with_expansions [n/0 (static.random_nat) + n/1 (static.random_nat) + n/1 (static.random_nat)] + (n.= (..sum n/0 n/1 n/1) + (..sum' n/0 n/1 n/1)))) + (_.coverage [/.using] + (`` (with_expansions [ ("lux in-module" "library/lux" library/lux.refer) + (static.random code.text (random.lower_case 1)) + (static.random code.local (random.lower_case 1)) + (static.random code.text (random.lower_case 2)) + ' (template.symbol []) + (static.random code.text (random.lower_case 3)) + ' (template.symbol []) + (static.random code.text (random.lower_case 4)) + ' (template.symbol []) + (template.text [ "/" ]) + (template.text [// ']) + ' (template.symbol []) + <\\> (template.text [\\ ']) + <\\>' (template.symbol [<\\>]) + (template.text [ "/" ]) + (template.text [ "/" ]) + (template.text [ "/" "/" ]) + (template.text [ "#[0]"])] + (and (~~ (template [ ] + [(with_expansions [' (macro.final )] + (let [scenario (is (-> Any Bit) + (function (_ _) + ... TODO: Remove this hack once Jython is no longer being used as the Python interpreter. + (`` (for @.python (case (' [']) + (^.` [ + ("lux def" (~ [_ {.#Symbol ["" _]}]) [] #0) + (~~ (template.spliced ))]) + true + + _ + false) + (case (' [']) + (^.` [ (~~ (template.spliced ))]) + true + + _ + false)))))] + (scenario [])))] + + [(.using [']) + ("lux def module" []) + []] + + [(.using [ ' "*"]) + ("lux def module" [[ ]]) + [( "*")]] + + [(.using [ ' {"+" }]) + ("lux def module" [[ ]]) + [( {"+" })]] + + [(.using [ ' {"-" }]) + ("lux def module" [[ ]]) + [( {"-" })]] + + [(.using [ ' "_"]) + ("lux def module" []) + []] + + [(.using [' + [ ']]) + ("lux def module" [[ ]]) + [( )]] + + [(.using ["[0]" ' + ["[0]" ']]) + ("lux def module" [[ ] + [ ]]) + [( ) + ( )]] + + [(.using ["[0]" ' "_" + ["[1]" ']]) + ("lux def module" [[ ]]) + [( )]] + + [(.using ["[0]" ' "_" + ["[1]" ' "_" + ["[2]" ']]]) + ("lux def module" [[ ]]) + [( )]] + + [(.using [' + ["[0]" ' + ["[0]" ']]]) + ("lux def module" [[ ] + [ ]]) + [( ) + ( )]] + + [(.using ["[0]" ' + [' + ["[0]" <\\>']]]) + ("lux def module" [[ ] + [ <\\>]]) + [( ) + ( )]] + + [(.using ["[0]" ' ("[1]#[0]" )]) + ("lux def module" [[ ]]) + [( ( ))]] + )))))) )))))) (/.type: for_type/variant @@ -563,77 +563,77 @@ expected/1 existential_type] (<| (_.for [/.Type]) (all _.and - (_.cover [/.is] - (|> expected - (/.is Any) - (same? (/.is Any expected)))) - (_.cover [/.as] - (|> expected - (/.is Any) - (/.as /.Nat) - (same? expected))) - (_.cover [/.as_expected] - (|> expected - (/.is Any) - /.as_expected - (/.is /.Nat) - (same? expected))) - (_.cover [/.type_of] - (same? /.Nat (/.type_of expected))) - (_.cover [/.Primitive] - (case (/.Primitive "foo" [expected/0 expected/1]) - (pattern {.#Primitive "foo" (list actual/0 actual/1)}) - (and (same? expected/0 actual/0) - (same? expected/1 actual/1)) - - _ - false)) - (_.cover [/.type] - (and (case (/.type [expected/0 expected/1]) - {.#Product actual/0 actual/1} - (and (same? expected/0 actual/0) - (same? expected/1 actual/1)) - - _ - false) - (case (/.type (/.Or expected/0 expected/1)) - {.#Sum actual/0 actual/1} - (and (same? expected/0 actual/0) - (same? expected/1 actual/1)) - - _ - false) - (case (/.type (-> expected/0 expected/1)) - {.#Function actual/0 actual/1} - (and (same? expected/0 actual/0) - (same? expected/1 actual/1)) - - _ - false) - (case (/.type (expected/0 expected/1)) - {.#Apply actual/1 actual/0} - (and (same? expected/0 actual/0) - (same? expected/1 actual/1)) - - _ - false))) - (_.cover [/.type:] - (exec - (is /.Type ..for_type/variant) - (is /.Type ..for_type/record) - (is /.Type ..for_type/all) - true)) - (_.cover [/.Variant] - (exec - (is for_type/variant - {#Case/1 expected_left}) - true)) - (_.cover [/.Record] - (exec - (is for_type/record - [#slot/0 (n.= expected_left expected_right) - #slot/1 (.rev expected_right)]) - true)) + (_.coverage [/.is] + (|> expected + (/.is Any) + (same? (/.is Any expected)))) + (_.coverage [/.as] + (|> expected + (/.is Any) + (/.as /.Nat) + (same? expected))) + (_.coverage [/.as_expected] + (|> expected + (/.is Any) + /.as_expected + (/.is /.Nat) + (same? expected))) + (_.coverage [/.type_of] + (same? /.Nat (/.type_of expected))) + (_.coverage [/.Primitive] + (case (/.Primitive "foo" [expected/0 expected/1]) + (pattern {.#Primitive "foo" (list actual/0 actual/1)}) + (and (same? expected/0 actual/0) + (same? expected/1 actual/1)) + + _ + false)) + (_.coverage [/.type] + (and (case (/.type [expected/0 expected/1]) + {.#Product actual/0 actual/1} + (and (same? expected/0 actual/0) + (same? expected/1 actual/1)) + + _ + false) + (case (/.type (/.Or expected/0 expected/1)) + {.#Sum actual/0 actual/1} + (and (same? expected/0 actual/0) + (same? expected/1 actual/1)) + + _ + false) + (case (/.type (-> expected/0 expected/1)) + {.#Function actual/0 actual/1} + (and (same? expected/0 actual/0) + (same? expected/1 actual/1)) + + _ + false) + (case (/.type (expected/0 expected/1)) + {.#Apply actual/1 actual/0} + (and (same? expected/0 actual/0) + (same? expected/1 actual/1)) + + _ + false))) + (_.coverage [/.type:] + (exec + (is /.Type ..for_type/variant) + (is /.Type ..for_type/record) + (is /.Type ..for_type/all) + true)) + (_.coverage [/.Variant] + (exec + (is for_type/variant + {#Case/1 expected_left}) + true)) + (_.coverage [/.Record] + (exec + (is for_type/record + [#slot/0 (n.= expected_left expected_right) + #slot/1 (.rev expected_right)]) + true)) )))) (def: for_i64 @@ -641,24 +641,24 @@ (do random.monad [expected random.i64] (all _.and - (_.cover [/.i64] - (same? (is Any expected) - (is Any (/.i64 expected)))) - (_.cover [/.nat] - (same? (is Any expected) - (is Any (/.nat expected)))) - (_.cover [/.int] - (same? (is Any expected) - (is Any (/.int expected)))) - (_.cover [/.rev] - (same? (is Any expected) - (is Any (/.rev expected)))) - (_.cover [/.++] - (n.= 1 (n.- expected - (/.++ expected)))) - (_.cover [/.--] - (n.= 1 (n.- (/.-- expected) - expected))) + (_.coverage [/.i64] + (same? (is Any expected) + (is Any (/.i64 expected)))) + (_.coverage [/.nat] + (same? (is Any expected) + (is Any (/.nat expected)))) + (_.coverage [/.int] + (same? (is Any expected) + (is Any (/.int expected)))) + (_.coverage [/.rev] + (same? (is Any expected) + (is Any (/.rev expected)))) + (_.coverage [/.++] + (n.= 1 (n.- expected + (/.++ expected)))) + (_.coverage [/.--] + (n.= 1 (n.- (/.-- expected) + expected))) ))) (def: for_function @@ -666,17 +666,17 @@ (do random.monad [expected_left random.nat expected_right random.nat] - (_.cover [/.-> /.function] - (and (let [actual (is (/.-> Nat Nat Nat) - (/.function (_ actual_left actual_right) - (n.* (++ actual_left) (-- actual_right))))] - (n.= (n.* (++ expected_left) (-- expected_right)) - (actual expected_left expected_right))) - (let [actual (is (/.-> [Nat Nat] Nat) - (/.function (_ [actual_left actual_right]) - (n.* (++ actual_left) (-- actual_right))))] - (n.= (n.* (++ expected_left) (-- expected_right)) - (actual [expected_left expected_right]))))))) + (_.coverage [/.-> /.function] + (and (let [actual (is (/.-> Nat Nat Nat) + (/.function (_ actual_left actual_right) + (n.* (++ actual_left) (-- actual_right))))] + (n.= (n.* (++ expected_left) (-- expected_right)) + (actual expected_left expected_right))) + (let [actual (is (/.-> [Nat Nat] Nat) + (/.function (_ [actual_left actual_right]) + (n.* (++ actual_left) (-- actual_right))))] + (n.= (n.* (++ expected_left) (-- expected_right)) + (actual [expected_left expected_right]))))))) (/.template: (!n/+ ) [(n.+ )]) @@ -684,20 +684,20 @@ (def: for_template Test (`` (all _.and - (_.cover [/.template] - (let [bits (list (~~ (/.template [_] - [true] - - [0] [1] [2] - )))] - (and (n.= 3 (list.size bits)) - (list.every? (bit#= true) bits)))) + (_.coverage [/.template] + (let [bits (list (~~ (/.template [_] + [true] + + [0] [1] [2] + )))] + (and (n.= 3 (list.size bits)) + (list.every? (bit#= true) bits)))) (do random.monad [left random.nat right random.nat] - (_.cover [/.template:] - (n.= (n.+ left right) - (!n/+ left right)))) + (_.coverage [/.template:] + (n.= (n.+ left right) + (!n/+ left right)))) ))) (def: option/0 "0") @@ -710,15 +710,15 @@ [sample (random.either (in option/0) (in option/1))] (all _.and - (_.cover [/.static] - (case sample - (pattern (/.static option/0)) true - (pattern (/.static option/1)) true - _ false)) - (_.cover [/.char] - (|> (`` (/.char (~~ (/.static static_char)))) - text.of_char - (text#= static_char))) + (_.coverage [/.static] + (case sample + (pattern (/.static option/0)) true + (pattern (/.static option/1)) true + _ false)) + (_.coverage [/.char] + (|> (`` (/.char (~~ (/.static static_char)))) + text.of_char + (text#= static_char))) ))) (type: Small @@ -746,73 +746,73 @@ #big_right [#small_left start/s #small_right text]]]] (all _.and - (_.cover [/.the] - (and (and (|> sample - (/.the #big_left) - (same? start/b)) - (|> sample - ((/.the #big_left)) - (same? start/b))) - (and (|> sample - (/.the [#big_right #small_left]) - (same? start/s)) - (|> sample - ((/.the [#big_right #small_left])) - (same? start/s))))) - (_.cover [/.has] - (and (and (|> sample - (/.has #big_left shift/b) - (/.the #big_left) - (same? shift/b)) - (|> sample - ((/.has #big_left shift/b)) - (/.the #big_left) - (same? shift/b)) - (|> sample - ((/.has #big_left) shift/b) - (/.the #big_left) - (same? shift/b))) - (and (|> sample - (/.has [#big_right #small_left] shift/s) - (/.the [#big_right #small_left]) - (same? shift/s)) - (|> sample - ((/.has [#big_right #small_left] shift/s)) - (/.the [#big_right #small_left]) - (same? shift/s)) - (|> sample - ((/.has [#big_right #small_left]) shift/s) - (/.the [#big_right #small_left]) - (same? shift/s))))) - (_.cover [/.revised] - (and (and (|> sample - (/.revised #big_left (n.+ shift/b)) - (/.the #big_left) - (n.= expected/b)) - (|> sample - ((/.revised #big_left (n.+ shift/b))) - (/.the #big_left) - (n.= expected/b)) - (|> sample - ((is (-> (-> Nat Nat) (-> Big Big)) - (/.revised #big_left)) - (n.+ shift/b)) - (/.the #big_left) - (n.= expected/b))) - (and (|> sample - (/.revised [#big_right #small_left] (n.+ shift/s)) - (/.the [#big_right #small_left]) - (n.= expected/s)) - (|> sample - ((/.revised [#big_right #small_left] (n.+ shift/s))) - (/.the [#big_right #small_left]) - (n.= expected/s)) - (|> sample - ((is (-> (-> Nat Nat) (-> Big Big)) - (/.revised [#big_right #small_left])) - (n.+ shift/s)) - (/.the [#big_right #small_left]) - (n.= expected/s))))) + (_.coverage [/.the] + (and (and (|> sample + (/.the #big_left) + (same? start/b)) + (|> sample + ((/.the #big_left)) + (same? start/b))) + (and (|> sample + (/.the [#big_right #small_left]) + (same? start/s)) + (|> sample + ((/.the [#big_right #small_left])) + (same? start/s))))) + (_.coverage [/.has] + (and (and (|> sample + (/.has #big_left shift/b) + (/.the #big_left) + (same? shift/b)) + (|> sample + ((/.has #big_left shift/b)) + (/.the #big_left) + (same? shift/b)) + (|> sample + ((/.has #big_left) shift/b) + (/.the #big_left) + (same? shift/b))) + (and (|> sample + (/.has [#big_right #small_left] shift/s) + (/.the [#big_right #small_left]) + (same? shift/s)) + (|> sample + ((/.has [#big_right #small_left] shift/s)) + (/.the [#big_right #small_left]) + (same? shift/s)) + (|> sample + ((/.has [#big_right #small_left]) shift/s) + (/.the [#big_right #small_left]) + (same? shift/s))))) + (_.coverage [/.revised] + (and (and (|> sample + (/.revised #big_left (n.+ shift/b)) + (/.the #big_left) + (n.= expected/b)) + (|> sample + ((/.revised #big_left (n.+ shift/b))) + (/.the #big_left) + (n.= expected/b)) + (|> sample + ((is (-> (-> Nat Nat) (-> Big Big)) + (/.revised #big_left)) + (n.+ shift/b)) + (/.the #big_left) + (n.= expected/b))) + (and (|> sample + (/.revised [#big_right #small_left] (n.+ shift/s)) + (/.the [#big_right #small_left]) + (n.= expected/s)) + (|> sample + ((/.revised [#big_right #small_left] (n.+ shift/s))) + (/.the [#big_right #small_left]) + (n.= expected/s)) + (|> sample + ((is (-> (-> Nat Nat) (-> Big Big)) + (/.revised [#big_right #small_left])) + (n.+ shift/s)) + (/.the [#big_right #small_left]) + (n.= expected/s))))) ))) (def: for_associative @@ -822,19 +822,19 @@ mid (random.lower_case 1) right (random.lower_case 1) .let [expected (text.interposed "" (list left mid right))]] - (_.cover [/.all /.left] - (with_expansions [ (/.left format - left - mid - right) - (/.all format - left - mid - right)] - (and (text#= - ) - (not (code#= (' ) - (' )))))))) + (_.coverage [/.all /.left] + (with_expansions [ (/.left format + left + mid + right) + (/.all format + left + mid + right)] + (and (text#= + ) + (not (code#= (' ) + (' )))))))) (def: for_expansion Test @@ -844,37 +844,37 @@ dummy random.nat .let [expected (n.+ left right)]] (all _.and - (_.cover [/.these] - (`` (and (~~ (these true - true - true))))) - (_.cover [/.with_expansions] - (/.with_expansions [ (these left right)] - (n.= expected - (n.+ )))) - (_.cover [/.comment] - (/.with_expansions [ (/.comment dummy) - (these left right)] - (n.= expected - (all n.+ )))) - (_.cover [/.``] - (n.= expected - (/.`` (all n.+ - (~~ (these left right)) - (~~ (/.comment dummy)))))) - (_.cover [/.for] - (and (n.= expected - (/.for "fake host" dummy - expected)) - (n.= expected - (/.for @.old expected - @.jvm expected - @.js expected - @.python expected - @.lua expected - @.ruby expected - @.php expected - dummy)))) + (_.coverage [/.these] + (`` (and (~~ (these true + true + true))))) + (_.coverage [/.with_expansions] + (/.with_expansions [ (these left right)] + (n.= expected + (n.+ )))) + (_.coverage [/.comment] + (/.with_expansions [ (/.comment dummy) + (these left right)] + (n.= expected + (all n.+ )))) + (_.coverage [/.``] + (n.= expected + (/.`` (all n.+ + (~~ (these left right)) + (~~ (/.comment dummy)))))) + (_.coverage [/.for] + (and (n.= expected + (/.for "fake host" dummy + expected)) + (n.= expected + (/.for @.old expected + @.jvm expected + @.js expected + @.python expected + @.lua expected + @.ruby expected + @.php expected + dummy)))) ))) (def: for_value @@ -887,76 +887,76 @@ item/1 random.nat item/2 random.nat] (all _.and - (_.cover [/.Either] - (and (exec - (is (/.Either Nat Text) - {.#Left left}) - true) - (exec - (is (/.Either Nat Text) - {.#Right right}) - true))) - (_.cover [/.Any] - (and (exec - (is /.Any - left) - true) - (exec - (is /.Any - right) - true))) - (_.cover [/.Nothing] - (and (exec - (is (-> /.Any /.Nothing) - (function (_ _) - (undefined))) - true) - (exec - (is (-> /.Any /.Int) - (function (_ _) - (is /.Int (undefined)))) - true))) + (_.coverage [/.Either] + (and (exec + (is (/.Either Nat Text) + {.#Left left}) + true) + (exec + (is (/.Either Nat Text) + {.#Right right}) + true))) + (_.coverage [/.Any] + (and (exec + (is /.Any + left) + true) + (exec + (is /.Any + right) + true))) + (_.coverage [/.Nothing] + (and (exec + (is (-> /.Any /.Nothing) + (function (_ _) + (undefined))) + true) + (exec + (is (-> /.Any /.Int) + (function (_ _) + (is /.Int (undefined)))) + true))) (_.for [/.__adjusted_quantified_type__] (all _.and - (_.cover [/.All] - (let [identity (is (/.All (_ a) (-> a a)) - (|>>))] - (and (exec - (is Nat - (identity left)) - true) - (exec - (is Text - (identity right)) - true)))) - (_.cover [/.Ex] - (let [hide (is (/.Ex (_ a) (-> Nat a)) - (|>>))] - (exec - (is /.Any - (hide left)) - true))))) - (_.cover [/.same?] - (let [not_left (atom.atom left) - left (atom.atom left)] - (and (/.same? left left) - (/.same? not_left not_left) - (not (/.same? left not_left))))) - (_.cover [/.Rec] - (let [list (is (/.Rec NList - (Maybe [Nat NList])) - {.#Some [item/0 - {.#Some [item/1 - {.#Some [item/2 - {.#None}]}]}]})] - (case list - {.#Some [actual/0 {.#Some [actual/1 {.#Some [actual/2 {.#None}]}]}]} - (and (same? item/0 actual/0) - (same? item/1 actual/1) - (same? item/2 actual/2)) - - _ - false))) + (_.coverage [/.All] + (let [identity (is (/.All (_ a) (-> a a)) + (|>>))] + (and (exec + (is Nat + (identity left)) + true) + (exec + (is Text + (identity right)) + true)))) + (_.coverage [/.Ex] + (let [hide (is (/.Ex (_ a) (-> Nat a)) + (|>>))] + (exec + (is /.Any + (hide left)) + true))))) + (_.coverage [/.same?] + (let [not_left (atom.atom left) + left (atom.atom left)] + (and (/.same? left left) + (/.same? not_left not_left) + (not (/.same? left not_left))))) + (_.coverage [/.Rec] + (let [list (is (/.Rec NList + (Maybe [Nat NList])) + {.#Some [item/0 + {.#Some [item/1 + {.#Some [item/2 + {.#None}]}]}]})] + (case list + {.#Some [actual/0 {.#Some [actual/1 {.#Some [actual/2 {.#None}]}]}]} + (and (same? item/0 actual/0) + (same? item/1 actual/1) + (same? item/2 actual/2)) + + _ + false))) ))) (type: (Pair l r) @@ -980,48 +980,48 @@ expected_text (random.either (in "+0.5") (in "+1.25"))] (all _.and - (_.cover [/.case] - (and (/.case expected_nat - 0 true - _ false) - (/.case expected_int - +0 true - _ false) - (/.case expected_rev - .5 true - .25 true - _ false) - (/.case expected_frac - +0.5 true - +1.25 true - _ false) - (/.case expected_text - "+0.5" true - "+1.25" true - _ false) - (/.case [expected_nat expected_int] - [0 +0] true - _ false) - (/.case [..#left expected_nat ..#right expected_int] - [..#left 0 ..#right +0] true - _ false) - (/.case (is (Either Nat Int) {.#Left expected_nat}) - {.#Left 0} true - _ false) - (/.case (is (Either Nat Int) {.#Right expected_int}) - {.#Right +0} true - _ false) - )) - (_.cover [/.pattern] - (/.case [..#left expected_nat ..#right expected_int] - (/.pattern (!pair 0 +0)) true - _ false)) - (_.cover [/.let] - (and (/.let [actual_nat expected_nat] - (/.same? expected_nat actual_nat)) - (/.let [[actual_left actual_right] [..#left expected_nat ..#right expected_int]] - (and (/.same? expected_nat actual_left) - (/.same? expected_int actual_right))))) + (_.coverage [/.case] + (and (/.case expected_nat + 0 true + _ false) + (/.case expected_int + +0 true + _ false) + (/.case expected_rev + .5 true + .25 true + _ false) + (/.case expected_frac + +0.5 true + +1.25 true + _ false) + (/.case expected_text + "+0.5" true + "+1.25" true + _ false) + (/.case [expected_nat expected_int] + [0 +0] true + _ false) + (/.case [..#left expected_nat ..#right expected_int] + [..#left 0 ..#right +0] true + _ false) + (/.case (is (Either Nat Int) {.#Left expected_nat}) + {.#Left 0} true + _ false) + (/.case (is (Either Nat Int) {.#Right expected_int}) + {.#Right +0} true + _ false) + )) + (_.coverage [/.pattern] + (/.case [..#left expected_nat ..#right expected_int] + (/.pattern (!pair 0 +0)) true + _ false)) + (_.coverage [/.let] + (and (/.let [actual_nat expected_nat] + (/.same? expected_nat actual_nat)) + (/.let [[actual_left actual_right] [..#left expected_nat ..#right expected_int]] + (and (/.same? expected_nat actual_left) + (/.same? expected_int actual_right))))) ))) (def: for_control_flow @@ -1031,22 +1031,22 @@ [factor (random#each (|>> (n.% 10) (n.max 1)) random.nat) iterations (random#each (n.% 10) random.nat) .let [expected (n.* factor iterations)]] - (_.cover [/.loop] - (n.= expected - (/.loop (again [counter 0 - value 0]) - (if (n.< iterations counter) - (again (++ counter) (n.+ factor value)) - value))))) + (_.coverage [/.loop] + (n.= expected + (/.loop (again [counter 0 + value 0]) + (if (n.< iterations counter) + (again (++ counter) (n.+ factor value)) + value))))) (do random.monad [pre random.nat post (random.only (|>> (n.= pre) not) random.nat) .let [box (atom.atom pre)]] - (_.cover [/.exec] - (and (same? pre (io.run! (atom.read! box))) - (/.exec - (io.run! (atom.write! post box)) - (same? post (io.run! (atom.read! box))))))) + (_.coverage [/.exec] + (and (same? pre (io.run! (atom.read! box))) + (/.exec + (io.run! (atom.write! post box)) + (same? post (io.run! (atom.read! box))))))) )) (def: identity/constant @@ -1062,9 +1062,9 @@ Test (do random.monad [expected random.nat] - (_.cover [/.def:] - (and (same? expected (identity/constant expected)) - (same? expected (identity/function expected)))))) + (_.coverage [/.def:] + (and (same? expected (identity/constant expected)) + (same? expected (identity/function expected)))))) (def: possible_targets (Set @.Target) @@ -1100,20 +1100,20 @@ (def: for_meta Test (all _.and - (_.cover [/.Mode /.Info] - (for_meta|Info)) - (_.cover [/.Module_State] - (for_meta|Module_State)) + (_.coverage [/.Mode /.Info] + (for_meta|Info)) + (_.coverage [/.Module_State] + (for_meta|Module_State)) )) (def: for_export Test (all _.and - (_.cover [/.public /.private] - (and /.public (not /.private))) - (_.cover [/.global /.local] - (and (bit#= /.public /.global) - (bit#= /.private /.local))) + (_.coverage [/.public /.private] + (and /.public (not /.private))) + (_.coverage [/.global /.local] + (and (bit#= /.public /.global) + (bit#= /.private /.local))) )) (for @.old (these) @@ -1192,8 +1192,8 @@ fn/1 var/1 let/1 fn/2 var/2 let/2 let/3)] - (_.cover [/.Bindings /.Ref] - verdict))) + (_.coverage [/.Bindings /.Ref] + verdict))) 0 1 2)))) (def: test|lux -- cgit v1.2.3