diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/data/format/tar.lux | 282 |
1 files changed, 141 insertions, 141 deletions
diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux index 7f271de05..72024ba29 100644 --- a/stdlib/source/test/lux/data/format/tar.lux +++ b/stdlib/source/test/lux/data/format/tar.lux @@ -38,148 +38,148 @@ Test (_.for [/.Path] (do {! random.monad} - [expected (random.ascii/lower-alpha /.path-size) - invalid (random.ascii/lower-alpha (inc /.path-size)) - not-ascii (random.text (random.char (unicode.set [unicode/block.katakana (list)])) - /.path-size)] + [expected (random.ascii/lower_alpha /.path_size) + invalid (random.ascii/lower_alpha (inc /.path_size)) + not_ascii (random.text (random.char (unicode.set [unicode/block.katakana (list)])) + /.path_size)] (`` ($_ _.and - (_.cover [/.path /.from-path] + (_.cover [/.path /.from_path] (case (/.path expected) (#try.Success actual) (text\= expected - (/.from-path actual)) + (/.from_path actual)) (#try.Failure error) false)) - (_.cover [/.path-size /.path-is-too-long] + (_.cover [/.path_size /.path_is_too_long] (case (/.path invalid) (#try.Success _) false (#try.Failure error) - (exception.match? /.path-is-too-long error))) - (_.cover [/.not-ascii] - (case (/.path not-ascii) + (exception.match? /.path_is_too_long error))) + (_.cover [/.not_ascii] + (case (/.path not_ascii) (#try.Success actual) false (#try.Failure error) - (exception.match? /.not-ascii error))) + (exception.match? /.not_ascii error))) ))))) (def: name Test (_.for [/.Name] (do {! random.monad} - [expected (random.ascii/lower-alpha /.name-size) - invalid (random.ascii/lower-alpha (inc /.name-size)) - not-ascii (random.text (random.char (unicode.set [unicode/block.katakana (list)])) - /.name-size)] + [expected (random.ascii/lower_alpha /.name_size) + invalid (random.ascii/lower_alpha (inc /.name_size)) + not_ascii (random.text (random.char (unicode.set [unicode/block.katakana (list)])) + /.name_size)] (`` ($_ _.and - (_.cover [/.name /.from-name] + (_.cover [/.name /.from_name] (case (/.name expected) (#try.Success actual) (text\= expected - (/.from-name actual)) + (/.from_name actual)) (#try.Failure error) false)) - (_.cover [/.name-size /.name-is-too-long] + (_.cover [/.name_size /.name_is_too_long] (case (/.name invalid) (#try.Success _) false (#try.Failure error) - (exception.match? /.name-is-too-long error))) - (_.cover [/.not-ascii] - (case (/.name not-ascii) + (exception.match? /.name_is_too_long error))) + (_.cover [/.not_ascii] + (case (/.name not_ascii) (#try.Success actual) false (#try.Failure error) - (exception.match? /.not-ascii error))) + (exception.match? /.not_ascii error))) ))))) (def: small Test (_.for [/.Small] (do {! random.monad} - [expected (|> random.nat (\ ! map (n.% /.small-limit))) - invalid (|> random.nat (\ ! map (n.max /.small-limit)))] + [expected (|> random.nat (\ ! map (n.% /.small_limit))) + invalid (|> random.nat (\ ! map (n.max /.small_limit)))] (`` ($_ _.and - (_.cover [/.small /.from-small] + (_.cover [/.small /.from_small] (case (/.small expected) (#try.Success actual) (n.= expected - (/.from-small actual)) + (/.from_small actual)) (#try.Failure error) false)) - (_.cover [/.small-limit /.not-a-small-number] + (_.cover [/.small_limit /.not_a_small_number] (case (/.small invalid) (#try.Success actual) false (#try.Failure error) - (exception.match? /.not-a-small-number error))) + (exception.match? /.not_a_small_number error))) ))))) (def: big Test (_.for [/.Big] (do {! random.monad} - [expected (|> random.nat (\ ! map (n.% /.big-limit))) - invalid (|> random.nat (\ ! map (n.max /.big-limit)))] + [expected (|> random.nat (\ ! map (n.% /.big_limit))) + invalid (|> random.nat (\ ! map (n.max /.big_limit)))] (`` ($_ _.and - (_.cover [/.big /.from-big] + (_.cover [/.big /.from_big] (case (/.big expected) (#try.Success actual) (n.= expected - (/.from-big actual)) + (/.from_big actual)) (#try.Failure error) false)) - (_.cover [/.big-limit /.not-a-big-number] + (_.cover [/.big_limit /.not_a_big_number] (case (/.big invalid) (#try.Success actual) false (#try.Failure error) - (exception.match? /.not-a-big-number error))) + (exception.match? /.not_a_big_number error))) ))))) -(def: chunk-size 32) +(def: chunk_size 32) (def: entry Test (do {! random.monad} - [expected-path (random.ascii/lower-alpha (dec /.path-size)) - expected-moment (\ ! map (|>> (n.% 1,0,00,00,00,00,000) .int instant.from-millis) + [expected_path (random.ascii/lower_alpha (dec /.path_size)) + expected_moment (\ ! map (|>> (n.% 1,0,00,00,00,00,000) .int instant.from_millis) random.nat) - chunk (random.ascii/lower-alpha chunk-size) + chunk (random.ascii/lower_alpha chunk_size) chunks (\ ! map (n.% 100) random.nat) #let [content (|> chunk (list.repeat chunks) - (text.join-with "") + (text.join_with "") (\ encoding.utf8 encode))]] (`` ($_ _.and (~~ (template [<type> <tag>] [(_.cover [<type>] (|> (do try.monad - [expected-path (/.path expected-path) - tar (|> (row.row (<tag> expected-path)) + [expected_path (/.path expected_path) + tar (|> (row.row (<tag> expected_path)) (format.run /.writer) (<b>.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (<tag> actual-path))) - (text\= (/.from-path expected-path) - (/.from-path actual-path)) + (wrap (case (row.to_list tar) + (^ (list (<tag> actual_path))) + (text\= (/.from_path expected_path) + (/.from_path actual_path)) _ false))) (try.default false)))] - [/.Symbolic-Link #/.Symbolic-Link] + [/.Symbolic_Link #/.Symbolic_Link] [/.Directory #/.Directory] )) (_.for [/.File /.Content /.content /.data] @@ -187,28 +187,28 @@ (~~ (template [<type> <tag>] [(_.cover [<type>] (|> (do try.monad - [expected-path (/.path expected-path) - expected-content (/.content content) - tar (|> (row.row (<tag> [expected-path - expected-moment + [expected_path (/.path expected_path) + expected_content (/.content content) + tar (|> (row.row (<tag> [expected_path + expected_moment /.none {#/.user {#/.name /.anonymous - #/.id /.no-id} + #/.id /.no_id} #/.group {#/.name /.anonymous - #/.id /.no-id}} - expected-content])) + #/.id /.no_id}} + expected_content])) (format.run /.writer) (<b>.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (<tag> [actual-path actual-moment actual-mode actual-ownership actual-content]))) + (wrap (case (row.to_list tar) + (^ (list (<tag> [actual_path actual_moment actual_mode actual_ownership actual_content]))) (let [seconds (: (-> Instant Int) (|>> instant.relative (duration.query duration.second)))] - (and (text\= (/.from-path expected-path) - (/.from-path actual-path)) - (i.= (seconds expected-moment) - (seconds actual-moment)) - (binary\= (/.data expected-content) - (/.data actual-content)))) + (and (text\= (/.from_path expected_path) + (/.from_path actual_path)) + (i.= (seconds expected_moment) + (seconds actual_moment)) + (binary\= (/.data expected_content) + (/.data actual_content)))) _ false))) @@ -218,72 +218,72 @@ [/.Contiguous #/.Contiguous] )))))))) -(def: random-mode +(def: random_mode (Random /.Mode) (do {! random.monad} [] - (random.either (random.either (random.either (wrap /.execute-by-other) - (wrap /.write-by-other)) - (random.either (wrap /.read-by-other) - (wrap /.execute-by-group))) - (random.either (random.either (random.either (wrap /.write-by-group) - (wrap /.read-by-group)) - (random.either (wrap /.execute-by-owner) - (wrap /.write-by-owner))) - (random.either (random.either (wrap /.read-by-owner) - (wrap /.save-text)) - (random.either (wrap /.set-group-id-on-execution) - (wrap /.set-user-id-on-execution))))))) + (random.either (random.either (random.either (wrap /.execute_by_other) + (wrap /.write_by_other)) + (random.either (wrap /.read_by_other) + (wrap /.execute_by_group))) + (random.either (random.either (random.either (wrap /.write_by_group) + (wrap /.read_by_group)) + (random.either (wrap /.execute_by_owner) + (wrap /.write_by_owner))) + (random.either (random.either (wrap /.read_by_owner) + (wrap /.save_text)) + (random.either (wrap /.set_group_id_on_execution) + (wrap /.set_user_id_on_execution))))))) (def: mode Test (_.for [/.Mode /.mode] (do {! random.monad} - [path (random.ascii/lower-alpha 10) - modes (random.list 4 ..random-mode) - #let [expected-mode (list\fold /.and /.none modes)]] + [path (random.ascii/lower_alpha 10) + modes (random.list 4 ..random_mode) + #let [expected_mode (list\fold /.and /.none modes)]] (`` ($_ _.and (_.cover [/.and] (|> (do try.monad [path (/.path path) content (/.content (binary.create 0)) tar (|> (row.row (#/.Normal [path - (instant.from-millis +0) - expected-mode + (instant.from_millis +0) + expected_mode {#/.user {#/.name /.anonymous - #/.id /.no-id} + #/.id /.no_id} #/.group {#/.name /.anonymous - #/.id /.no-id}} + #/.id /.no_id}} content])) (format.run /.writer) (<b>.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (#/.Normal [_ _ actual-mode _ _]))) - (n.= (/.mode expected-mode) - (/.mode actual-mode)) + (wrap (case (row.to_list tar) + (^ (list (#/.Normal [_ _ actual_mode _ _]))) + (n.= (/.mode expected_mode) + (/.mode actual_mode)) _ false))) (try.default false))) - (~~ (template [<expected-mode>] - [(_.cover [<expected-mode>] + (~~ (template [<expected_mode>] + [(_.cover [<expected_mode>] (|> (do try.monad [path (/.path path) content (/.content (binary.create 0)) tar (|> (row.row (#/.Normal [path - (instant.from-millis +0) - <expected-mode> + (instant.from_millis +0) + <expected_mode> {#/.user {#/.name /.anonymous - #/.id /.no-id} + #/.id /.no_id} #/.group {#/.name /.anonymous - #/.id /.no-id}} + #/.id /.no_id}} content])) (format.run /.writer) (<b>.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (#/.Normal [_ _ actual-mode _ _]))) - (n.= (/.mode <expected-mode>) - (/.mode actual-mode)) + (wrap (case (row.to_list tar) + (^ (list (#/.Normal [_ _ actual_mode _ _]))) + (n.= (/.mode <expected_mode>) + (/.mode actual_mode)) _ false))) @@ -291,96 +291,96 @@ [/.none] - [/.execute-by-other] - [/.write-by-other] - [/.read-by-other] + [/.execute_by_other] + [/.write_by_other] + [/.read_by_other] - [/.execute-by-group] - [/.write-by-group] - [/.read-by-group] + [/.execute_by_group] + [/.write_by_group] + [/.read_by_group] - [/.execute-by-owner] - [/.write-by-owner] - [/.read-by-owner] + [/.execute_by_owner] + [/.write_by_owner] + [/.read_by_owner] - [/.save-text] - [/.set-group-id-on-execution] - [/.set-user-id-on-execution] + [/.save_text] + [/.set_group_id_on_execution] + [/.set_user_id_on_execution] ))))))) (def: ownership Test (do {! random.monad} - [path (random.ascii/lower-alpha /.path-size) - expected (random.ascii/lower-alpha /.name-size) - invalid (random.ascii/lower-alpha (inc /.name-size)) - not-ascii (random.text (random.char (unicode.set [unicode/block.katakana (list)])) - /.name-size)] + [path (random.ascii/lower_alpha /.path_size) + expected (random.ascii/lower_alpha /.name_size) + invalid (random.ascii/lower_alpha (inc /.name_size)) + not_ascii (random.text (random.char (unicode.set [unicode/block.katakana (list)])) + /.name_size)] (_.for [/.Ownership /.Owner /.ID] ($_ _.and - (_.cover [/.name-size /.name-is-too-long] + (_.cover [/.name_size /.name_is_too_long] (case (/.name invalid) (#try.Success _) false (#try.Failure error) - (exception.match? /.name-is-too-long error))) - (_.cover [/.not-ascii] - (case (/.name not-ascii) + (exception.match? /.name_is_too_long error))) + (_.cover [/.not_ascii] + (case (/.name not_ascii) (#try.Success actual) false (#try.Failure error) - (exception.match? /.not-ascii error))) - (_.cover [/.Name /.name /.from-name] + (exception.match? /.not_ascii error))) + (_.cover [/.Name /.name /.from_name] (|> (do try.monad [path (/.path path) content (/.content (binary.create 0)) expected (/.name expected) tar (|> (row.row (#/.Normal [path - (instant.from-millis +0) + (instant.from_millis +0) /.none {#/.user {#/.name expected - #/.id /.no-id} + #/.id /.no_id} #/.group {#/.name /.anonymous - #/.id /.no-id}} + #/.id /.no_id}} content])) (format.run /.writer) (<b>.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (#/.Normal [_ _ _ actual-ownership _]))) - (and (text\= (/.from-name expected) - (/.from-name (get@ [#/.user #/.name] actual-ownership))) - (text\= (/.from-name /.anonymous) - (/.from-name (get@ [#/.group #/.name] actual-ownership)))) + (wrap (case (row.to_list tar) + (^ (list (#/.Normal [_ _ _ actual_ownership _]))) + (and (text\= (/.from_name expected) + (/.from_name (get@ [#/.user #/.name] actual_ownership))) + (text\= (/.from_name /.anonymous) + (/.from_name (get@ [#/.group #/.name] actual_ownership)))) _ false))) (try.default false))) - (_.cover [/.anonymous /.no-id] + (_.cover [/.anonymous /.no_id] (|> (do try.monad [path (/.path path) content (/.content (binary.create 0)) tar (|> (row.row (#/.Normal [path - (instant.from-millis +0) + (instant.from_millis +0) /.none {#/.user {#/.name /.anonymous - #/.id /.no-id} + #/.id /.no_id} #/.group {#/.name /.anonymous - #/.id /.no-id}} + #/.id /.no_id}} content])) (format.run /.writer) (<b>.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (#/.Normal [_ _ _ actual-ownership _]))) - (and (text\= (/.from-name /.anonymous) - (/.from-name (get@ [#/.user #/.name] actual-ownership))) - (n.= (/.from-small /.no-id) - (/.from-small (get@ [#/.user #/.id] actual-ownership))) - (text\= (/.from-name /.anonymous) - (/.from-name (get@ [#/.group #/.name] actual-ownership))) - (n.= (/.from-small /.no-id) - (/.from-small (get@ [#/.group #/.id] actual-ownership)))) + (wrap (case (row.to_list tar) + (^ (list (#/.Normal [_ _ _ actual_ownership _]))) + (and (text\= (/.from_name /.anonymous) + (/.from_name (get@ [#/.user #/.name] actual_ownership))) + (n.= (/.from_small /.no_id) + (/.from_small (get@ [#/.user #/.id] actual_ownership))) + (text\= (/.from_name /.anonymous) + (/.from_name (get@ [#/.group #/.name] actual_ownership))) + (n.= (/.from_small /.no_id) + (/.from_small (get@ [#/.group #/.id] actual_ownership)))) _ false))) |