diff options
author | Eduardo Julian | 2020-12-25 09:22:38 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-12-25 09:22:38 -0400 |
commit | 4ca397765805eda5ddee393901ed3a02001a960a (patch) | |
tree | 2ab184a1a4e244f3a69e86c8a7bb3ad49c22b4a3 /stdlib/source/test | |
parent | d29e091e98dabb8dfcf816899ada480ecbf7e357 (diff) |
Replaced kebab-case with snake_case for naming convention.
Diffstat (limited to '')
118 files changed, 3953 insertions, 3952 deletions
diff --git a/stdlib/source/test/aedifex/artifact.lux b/stdlib/source/test/aedifex/artifact.lux index a718d51f6..fc8bb2dae 100644 --- a/stdlib/source/test/aedifex/artifact.lux +++ b/stdlib/source/test/aedifex/artifact.lux @@ -46,7 +46,7 @@ (file.mock (\ file.default separator)))]] (_.cover [/.uri /.path] (|> (/.path fs sample) - (text.replace-all uri.separator (\ fs separator)) + (text.replace_all uri.separator (\ fs separator)) (text\= (/.uri sample))))) /type.test diff --git a/stdlib/source/test/aedifex/artifact/extension.lux b/stdlib/source/test/aedifex/artifact/extension.lux index cd695ae93..2a3f3f564 100644 --- a/stdlib/source/test/aedifex/artifact/extension.lux +++ b/stdlib/source/test/aedifex/artifact/extension.lux @@ -22,10 +22,10 @@ (<| (_.covering /._) (_.for [/.Extension] ($_ _.and - (_.cover [/.lux-library /.jvm-library /.pom + (_.cover [/.lux_library /.jvm_library /.pom /.sha-1 /.md5] - (let [options (list /.lux-library /.jvm-library /.pom /.sha-1 /.md5) - uniques (set.from-list text.hash options)] + (let [options (list /.lux_library /.jvm_library /.pom /.sha-1 /.md5) + uniques (set.from_list text.hash options)] (n.= (list.size options) (set.size uniques)))) (_.cover [/.extension] @@ -33,8 +33,8 @@ [(text\= <extension> (/.extension <type>))] - [//.lux-library /.lux-library] - [//.jvm-library /.jvm-library] + [//.lux_library /.lux_library] + [//.jvm_library /.jvm_library] [//.pom /.pom] ))))) )))) diff --git a/stdlib/source/test/aedifex/artifact/type.lux b/stdlib/source/test/aedifex/artifact/type.lux index 5dc1b9caa..7f153b2a9 100644 --- a/stdlib/source/test/aedifex/artifact/type.lux +++ b/stdlib/source/test/aedifex/artifact/type.lux @@ -19,8 +19,8 @@ (Random /.Type) ($_ random.either ($_ random.either - (random\wrap /.lux-library) - (random\wrap /.jvm-library)) + (random\wrap /.lux_library) + (random\wrap /.jvm_library)) ($_ random.either (random\wrap /.pom) (random\wrap /.md5) @@ -32,11 +32,11 @@ (<| (_.covering /._) (_.for [/.Type] ($_ _.and - (_.cover [/.lux-library /.jvm-library + (_.cover [/.lux_library /.jvm_library /.pom /.md5 /.sha-1] - (let [options (list /.lux-library /.jvm-library + (let [options (list /.lux_library /.jvm_library /.pom /.md5 /.sha-1) - uniques (set.from-list text.hash options)] + uniques (set.from_list text.hash options)] (n.= (list.size options) (set.size uniques)))) )))) diff --git a/stdlib/source/test/aedifex/cache.lux b/stdlib/source/test/aedifex/cache.lux index 0bb0aea68..c4c2d044f 100644 --- a/stdlib/source/test/aedifex/cache.lux +++ b/stdlib/source/test/aedifex/cache.lux @@ -45,24 +45,24 @@ (def: type (Random Type) ($_ random.either - (random\wrap //artifact/type.lux-library) - (random\wrap //artifact/type.jvm-library))) + (random\wrap //artifact/type.lux_library) + (random\wrap //artifact/type.jvm_library))) (def: profile (Random [Artifact Profile XML]) (random.one (function (_ profile) - (try.to-maybe + (try.to_maybe (do try.monad [pom (//pom.write profile) - identity (try.from-maybe (get@ #//.identity profile))] + identity (try.from_maybe (get@ #//.identity profile))] (wrap [identity profile pom])))) @profile.random)) (def: content (Random Binary) (do {! random.monad} - [content-size (\ ! map (n.% 100) random.nat)] - (_binary.random content-size))) + [content_size (\ ! map (n.% 100) random.nat)] + (_binary.random content_size))) (def: package (Random [Dependency Package]) @@ -77,9 +77,9 @@ (def: resolution (Random Resolution) (do {! random.monad} - [[main-dependency main-package] ..package - dependencies (|> (//package.dependencies main-package) - (\ try.monad map set.to-list) + [[main_dependency main_package] ..package + dependencies (|> (//package.dependencies main_package) + (\ try.monad map set.to_list) (try.default (list)) (monad.map ! (function (_ dependency) (do ! @@ -88,47 +88,47 @@ (set@ #//.dependencies (set.new //dependency.hash)) (set@ #//.identity (#.Some (get@ #//dependency.artifact dependency))) //pom.write - try.to-maybe)) + try.to_maybe)) ..profile) content ..content] (wrap [dependency (set@ #//package.origin #//package.Remote (//package.local pom content))])))))] - (wrap (dictionary.from-list //dependency.hash (list& [main-dependency main-package] dependencies))))) + (wrap (dictionary.from_list //dependency.hash (list& [main_dependency main_package] dependencies))))) (def: singular Test (do {! random.monad} - [[dependency expected-package] ..package + [[dependency expected_package] ..package home (random.ascii/alpha 5) - working-directory (random.ascii/alpha 5) + working_directory (random.ascii/alpha 5) #let [fs (: (file.System Promise) (file.mock (\ file.default separator))) - program (program.async (program.mock environment.empty home working-directory))]] + program (program.async (program.mock environment.empty home working_directory))]] (wrap (do promise.monad - [wrote! (/.write-one program fs dependency expected-package) - read! (/.read-one program fs dependency)] - (_.cover' [/.write-one /.read-one] + [wrote! (/.write_one program fs dependency expected_package) + read! (/.read_one program fs dependency)] + (_.cover' [/.write_one /.read_one] (<| (try.default false) (do try.monad [_ wrote! - actual-package read!] + actual_package read!] (wrap (\ //package.equivalence = - (set@ #//package.origin #//package.Local expected-package) - actual-package))))))))) + (set@ #//package.origin #//package.Local expected_package) + actual_package))))))))) (def: plural Test (do {! random.monad} [expected ..resolution home (random.ascii/alpha 5) - working-directory (random.ascii/alpha 5) + working_directory (random.ascii/alpha 5) #let [fs (: (file.System Promise) (file.mock (\ file.default separator))) - program (program.async (program.mock environment.empty home working-directory))]] + program (program.async (program.mock environment.empty home working_directory))]] (wrap (do promise.monad - [wrote! (/.write-all program fs expected) - read! (/.read-all program fs (dictionary.keys expected) //dependency/resolution.empty)] - (_.cover' [/.write-all /.read-all] + [wrote! (/.write_all program fs expected) + read! (/.read_all program fs (dictionary.keys expected) //dependency/resolution.empty)] + (_.cover' [/.write_all /.read_all] (<| (try.default false) (do try.monad [_ wrote! diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index c43d8642f..817b4db5f 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -47,26 +47,26 @@ ["#." dependency ["#/." resolution (#+ Resolution)]]]]]}) -(def: (command end-signal dummy-files) +(def: (command end_signal dummy_files) (-> Text (List Path) [(Atom [Nat (List Path)]) (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command Any))]) (let [@runs (: (Atom [Nat (List Path)]) - (atom.atom [0 dummy-files]))] + (atom.atom [0 dummy_files]))] [@runs (function (_ console program fs shell resolution profile) (do {! promise.monad} - [[runs remaining-files] (promise.future - (atom.update (function (_ [runs remaining-files]) - [(inc runs) remaining-files]) + [[runs remaining_files] (promise.future + (atom.update (function (_ [runs remaining_files]) + [(inc runs) remaining_files]) @runs))] - (case remaining-files + (case remaining_files #.Nil - (wrap (#try.Failure end-signal)) + (wrap (#try.Failure end_signal)) (#.Cons head tail) (do (try.with !) - [_ (!.use (\ fs create-file) [head])] + [_ (!.use (\ fs create_file) [head])] (do ! [_ (promise.future (atom.write [runs tail] @runs))] (wrap (#try.Success [])))))))])) @@ -77,47 +77,47 @@ (do {! random.monad} [#let [/ (\ file.default separator) [fs watcher] (watch.mock /)] - end-signal (random.ascii/alpha 5) + end_signal (random.ascii/alpha 5) program (random.ascii/alpha 5) target (random.ascii/alpha 5) home (random.ascii/alpha 5) - working-directory (random.ascii/alpha 5) - expected-runs (\ ! map (|>> (n.% 10) (n.max 2)) random.nat) + working_directory (random.ascii/alpha 5) + expected_runs (\ ! map (|>> (n.% 10) (n.max 2)) random.nat) source (random.ascii/alpha 5) - dummy-files (|> (random.ascii/alpha 5) - (random.set text.hash (dec expected-runs)) - (\ ! map (|>> set.to-list (list\map (|>> (format source /)))))) - #let [empty-profile (: Profile + dummy_files (|> (random.ascii/alpha 5) + (random.set text.hash (dec expected_runs)) + (\ ! map (|>> set.to_list (list\map (|>> (format source /)))))) + #let [empty_profile (: Profile (\ ///.monoid identity)) - with-target (: (-> Profile Profile) + with_target (: (-> Profile Profile) (set@ #///.target (#.Some target))) - with-program (: (-> Profile Profile) + with_program (: (-> Profile Profile) (set@ #///.program (#.Some program))) - profile (|> empty-profile - with-program - with-target - (set@ #///.sources (set.from-list text.hash (list source))))] + profile (|> empty_profile + with_program + with_target + (set@ #///.sources (set.from_list text.hash (list source))))] resolution @build.resolution] ($_ _.and (wrap (do promise.monad [verdict (do ///action.monad - [#let [[@runs command] (..command end-signal dummy-files)] - _ (!.use (\ fs create-directory) [source]) + [#let [[@runs command] (..command end_signal dummy_files)] + _ (!.use (\ fs create_directory) [source]) _ (\ watcher poll [])] (do promise.monad [outcome ((/.do! watcher command) (@version.echo "") - (program.async (program.mock environment.empty home working-directory)) + (program.async (program.mock environment.empty home working_directory)) fs - (@build.good-shell []) + (@build.good_shell []) resolution profile) - [actual-runs _] (promise.future (atom.read @runs))] - (wrap (#try.Success (and (n.= expected-runs actual-runs) + [actual_runs _] (promise.future (atom.read @runs))] + (wrap (#try.Success (and (n.= expected_runs actual_runs) (case outcome (#try.Failure error) - (is? end-signal error) + (is? end_signal error) (#try.Success _) false))))))] diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index 025d01c0b..8a4df9a7e 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -36,55 +36,55 @@ ["#." dependency ["#/." resolution]]]]}) -(def: #export good-shell +(def: #export good_shell (-> Any (Shell Promise)) (shell.mock - (function (_ [actual-environment actual-working-directory actual-command actual-arguments]) + (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) (#try.Success (: (shell.Simulation []) (structure - (def: (on-read state) - (#try.Failure "on-read")) - (def: (on-error state) - (#try.Failure "on-error")) - (def: (on-write input state) - (#try.Failure "on-write")) - (def: (on-destroy state) - (#try.Failure "on-destroy")) - (def: (on-await state) + (def: (on_read state) + (#try.Failure "on_read")) + (def: (on_error state) + (#try.Failure "on_error")) + (def: (on_write input state) + (#try.Failure "on_write")) + (def: (on_destroy state) + (#try.Failure "on_destroy")) + (def: (on_await state) (#try.Success [state shell.normal])))))))) -(def: #export bad-shell +(def: #export bad_shell (-> Any (Shell Promise)) (shell.mock - (function (_ [actual-environment actual-working-directory actual-command actual-arguments]) + (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) (#try.Success (: (shell.Simulation []) (structure - (def: (on-read state) - (#try.Failure "on-read")) - (def: (on-error state) - (#try.Failure "on-error")) - (def: (on-write input state) - (#try.Failure "on-write")) - (def: (on-destroy state) - (#try.Failure "on-destroy")) - (def: (on-await state) + (def: (on_read state) + (#try.Failure "on_read")) + (def: (on_error state) + (#try.Failure "on_error")) + (def: (on_write input state) + (#try.Failure "on_write")) + (def: (on_destroy state) + (#try.Failure "on_destroy")) + (def: (on_await state) (#try.Success [state shell.error])))))))) (def: compiler (do random.monad - [lux-version (random.ascii/alpha 5) - #let [jvm-compiler {#///dependency.artifact {#///artifact.group /.lux-group - #///artifact.name /.jvm-compiler-name - #///artifact.version lux-version} - #///dependency.type ///artifact/type.lux-library} - js-compiler {#///dependency.artifact {#///artifact.group /.lux-group - #///artifact.name /.js-compiler-name - #///artifact.version lux-version} - #///dependency.type ///artifact/type.lux-library}]] - (random.either (wrap jvm-compiler) - (wrap js-compiler)))) + [lux_version (random.ascii/alpha 5) + #let [jvm_compiler {#///dependency.artifact {#///artifact.group /.lux_group + #///artifact.name /.jvm_compiler_name + #///artifact.version lux_version} + #///dependency.type ///artifact/type.lux_library} + js_compiler {#///dependency.artifact {#///artifact.group /.lux_group + #///artifact.name /.js_compiler_name + #///artifact.version lux_version} + #///dependency.type ///artifact/type.lux_library}]] + (random.either (wrap jvm_compiler) + (wrap js_compiler)))) (def: #export resolution (do random.monad @@ -98,63 +98,63 @@ (<| (_.covering /._) (do {! random.monad} [#let [fs (file.mock (\ file.default separator)) - shell (..good-shell [])] + shell (..good_shell [])] program (random.ascii/alpha 5) target (random.ascii/alpha 5) home (random.ascii/alpha 5) - working-directory (random.ascii/alpha 5) - #let [empty-profile (: Profile + working_directory (random.ascii/alpha 5) + #let [empty_profile (: Profile (\ ///.monoid identity)) - with-target (: (-> Profile Profile) + with_target (: (-> Profile Profile) (set@ #///.target (#.Some target))) - with-program (: (-> Profile Profile) + with_program (: (-> Profile Profile) (set@ #///.program (#.Some program))) - profile (|> empty-profile - with-program - with-target)]] + profile (|> empty_profile + with_program + with_target)]] ($_ _.and (wrap (do promise.monad - [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working-directory)) fs shell ///dependency/resolution.empty - (with-target empty-profile))] - (_.cover' [/.no-specified-program] + [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working_directory)) fs shell ///dependency/resolution.empty + (with_target empty_profile))] + (_.cover' [/.no_specified_program] (case outcome (#try.Success _) false (#try.Failure error) - (exception.match? /.no-specified-program error))))) + (exception.match? /.no_specified_program error))))) (wrap (do promise.monad - [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working-directory)) fs shell ///dependency/resolution.empty - (with-program empty-profile))] - (_.cover' [/.no-specified-target] + [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working_directory)) fs shell ///dependency/resolution.empty + (with_program empty_profile))] + (_.cover' [/.no_specified_target] (case outcome (#try.Success _) false (#try.Failure error) - (exception.match? /.no-specified-target error))))) + (exception.match? /.no_specified_target error))))) (wrap (do promise.monad - [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working-directory)) fs shell ///dependency/resolution.empty profile)] - (_.cover' [/.Compiler /.no-available-compiler] + [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working_directory)) fs shell ///dependency/resolution.empty profile)] + (_.cover' [/.Compiler /.no_available_compiler] (case outcome (#try.Success _) false (#try.Failure error) - (exception.match? /.no-available-compiler error))))) + (exception.match? /.no_available_compiler error))))) (do ! [#let [console (@version.echo "")] resolution ..resolution] (wrap (do promise.monad [verdict (do ///action.monad - [_ (/.do! console (program.async (program.mock environment.empty home working-directory)) fs shell resolution profile) - start (!.use (\ console read-line) []) - end (!.use (\ console read-line) [])] + [_ (/.do! console (program.async (program.mock environment.empty home working_directory)) fs shell resolution profile) + start (!.use (\ console read_line) []) + end (!.use (\ console read_line) [])] (wrap (and (text\= /.start start) (text\= /.success end))))] (_.cover' [/.do! - /.lux-group /.jvm-compiler-name /.js-compiler-name + /.lux_group /.jvm_compiler_name /.js_compiler_name /.start /.success] (try.default false verdict))))) (do ! @@ -162,9 +162,9 @@ resolution ..resolution] (wrap (do promise.monad [verdict (do ///action.monad - [_ (/.do! console (program.async (program.mock environment.empty home working-directory)) fs (..bad-shell []) resolution profile) - start (!.use (\ console read-line) []) - end (!.use (\ console read-line) [])] + [_ (/.do! console (program.async (program.mock environment.empty home working_directory)) fs (..bad_shell []) resolution profile) + start (!.use (\ console read_line) []) + end (!.use (\ console read_line) [])] (wrap (and (text\= /.start start) (text\= /.failure end))))] (_.cover' [/.failure] diff --git a/stdlib/source/test/aedifex/command/clean.lux b/stdlib/source/test/aedifex/command/clean.lux index 739bd1a34..c429f34fb 100644 --- a/stdlib/source/test/aedifex/command/clean.lux +++ b/stdlib/source/test/aedifex/command/clean.lux @@ -37,7 +37,7 @@ ["#" profile] ["#." action (#+ Action)]]]}) -(def: node-name +(def: node_name (Random Text) (random.ascii/alpha 10)) @@ -45,58 +45,58 @@ (-> Path (Random (List [Path Binary]))) (do {! random.monad} [count (\ ! map (n.% 10) random.nat) - names (random.set text.hash count ..node-name) + names (random.set text.hash count ..node_name) contents (random.list count (_binary.random 100))] - (wrap (list.zip/2 (list\map (|>> (format prefix)) (set.to-list names)) + (wrap (list.zip/2 (list\map (|>> (format prefix)) (set.to_list names)) contents)))) -(def: (create-file! fs [path content]) +(def: (create_file! fs [path content]) (-> (file.System Promise) [Path Binary] (Promise (Try Any))) (do {! (try.with promise.monad)} [file (: (Promise (Try (File Promise))) - (file.get-file promise.monad fs path))] - (!.use (\ file over-write) content))) + (file.get_file promise.monad fs path))] + (!.use (\ file over_write) content))) -(def: (create-directory! fs path files) +(def: (create_directory! fs path files) (-> (file.System Promise) Path (List [Path Binary]) (Promise (Try Any))) (do {! (try.with promise.monad)} [_ (: (Promise (Try Path)) - (file.make-directories promise.monad fs path)) - _ (monad.map ! (..create-file! fs) files)] + (file.make_directories promise.monad fs path)) + _ (monad.map ! (..create_file! fs) files)] (wrap []))) -(def: (directory-exists? fs) +(def: (directory_exists? fs) (-> (file.System Promise) Path (Promise (Try Bit))) - (|>> (file.directory-exists? promise.monad fs) (try.lift promise.monad))) + (|>> (file.directory_exists? promise.monad fs) (try.lift promise.monad))) -(def: (file-exists? fs) +(def: (file_exists? fs) (-> (file.System Promise) Path (Promise (Try Bit))) - (|>> (file.file-exists? promise.monad fs) (try.lift promise.monad))) + (|>> (file.file_exists? promise.monad fs) (try.lift promise.monad))) -(def: (assets-exist? fs directory-path files) +(def: (assets_exist? fs directory_path files) (-> (file.System Promise) Path (List [Path Binary]) (Promise (Try Bit))) (do {! (try.with promise.monad)} - [directory-exists? (..directory-exists? fs directory-path) - files-exist? (: (Action (List Bit)) + [directory_exists? (..directory_exists? fs directory_path) + files_exist? (: (Action (List Bit)) (|> files (list\map product.left) - (monad.map ///action.monad (..file-exists? fs))))] - (wrap (and directory-exists? - (list.every? (|>>) files-exist?))))) + (monad.map ///action.monad (..file_exists? fs))))] + (wrap (and directory_exists? + (list.every? (|>>) files_exist?))))) (def: #export test Test (<| (_.covering /._) (do {! random.monad} - [context ..node-name - target ..node-name - sub ..node-name + [context ..node_name + target ..node_name + sub ..node_name #let [fs (file.mock (\ file.default separator)) / (\ fs separator) - target-path (format context / target) - sub-path (format target-path / sub)] - direct-files (..files (format target-path /)) - sub-files (..files (format sub-path /)) + target_path (format context / target) + sub_path (format target_path / sub)] + direct_files (..files (format target_path /)) + sub_files (..files (format sub_path /)) dummy @profile.random] ($_ _.and @@ -105,28 +105,28 @@ verdict (do {! (try.with promise.monad)} [_ (/.do! console fs (set@ #///.target #.None dummy))] (\ ! map (text\= /.failure) - (!.use (\ console read-line) [])))] + (!.use (\ console read_line) [])))] (_.cover' [/.failure] (try.default false verdict)))) (wrap (do promise.monad [#let [console (@version.echo "")] verdict (do {! (try.with promise.monad)} - [_ (..create-directory! fs target-path direct-files) - _ (..create-directory! fs sub-path sub-files) - context-exists!/pre (..directory-exists? fs context) - target-exists!/pre (..assets-exist? fs target-path direct-files) - sub-exists!/pre (..assets-exist? fs sub-path sub-files) - _ (/.do! console fs (set@ #///.target (#.Some target-path) dummy)) - context-exists!/post (..directory-exists? fs context) - target-exists!/post (..assets-exist? fs target-path direct-files) - sub-exists!/post (..assets-exist? fs sub-path sub-files) - logging (!.use (\ console read-line) [])] - (wrap (and (and context-exists!/pre - context-exists!/post) - (and target-exists!/pre - (not target-exists!/post)) - (and sub-exists!/pre - (not sub-exists!/post)) + [_ (..create_directory! fs target_path direct_files) + _ (..create_directory! fs sub_path sub_files) + context_exists!/pre (..directory_exists? fs context) + target_exists!/pre (..assets_exist? fs target_path direct_files) + sub_exists!/pre (..assets_exist? fs sub_path sub_files) + _ (/.do! console fs (set@ #///.target (#.Some target_path) dummy)) + context_exists!/post (..directory_exists? fs context) + target_exists!/post (..assets_exist? fs target_path direct_files) + sub_exists!/post (..assets_exist? fs sub_path sub_files) + logging (!.use (\ console read_line) [])] + (wrap (and (and context_exists!/pre + context_exists!/post) + (and target_exists!/pre + (not target_exists!/post)) + (and sub_exists!/pre + (not sub_exists!/post)) (text\= /.success logging))))] (_.cover' [/.do! /.success] (try.default false verdict)))) diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index 86f3e0dbb..b6cd89469 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -53,9 +53,9 @@ ["#." artifact (#+ Artifact) ["#/." extension]]]]]}) -(def: (make-sources! fs sources) +(def: (make_sources! fs sources) (-> (file.System Promise) (Set Path) (Promise (Try Any))) - (loop [sources (set.to-list sources)] + (loop [sources (set.to_list sources)] (case sources #.Nil (|> [] @@ -65,9 +65,9 @@ (#.Cons head tail) (do (try.with promise.monad) [_ (: (Promise (Try Path)) - (file.make-directories promise.monad fs head)) + (file.make_directories promise.monad fs head)) _ (: (Promise (Try (File Promise))) - (file.get-file promise.monad fs (format head (\ fs separator) head ".lux")))] + (file.get_file promise.monad fs (format head (\ fs separator) head ".lux")))] (recur tail))))) (def: (execute! program repository fs artifact profile) @@ -78,67 +78,67 @@ [home (\ program home [])] (do ///action.monad [#let [console (@version.echo "")] - _ (..make-sources! fs (get@ #///.sources profile)) + _ (..make_sources! fs (get@ #///.sources profile)) _ (: (Promise (Try Path)) - (file.make-directories promise.monad fs (///local.repository fs home))) + (file.make_directories promise.monad fs (///local.repository fs home))) _ (/.do! console repository fs artifact profile)] - (!.use (\ console read-line) [])))) + (!.use (\ console read_line) [])))) (def: #export test Test (<| (_.covering /._) (do {! random.monad} - [[artifact expected-pom profile] + [[artifact expected_pom profile] (random.one (function (_ profile) (do maybe.monad [artifact (get@ #///.identity profile) - expected-pom (try.to-maybe (///pom.write profile))] - (wrap [artifact expected-pom profile]))) + expected_pom (try.to_maybe (///pom.write profile))] + (wrap [artifact expected_pom profile]))) @profile.random) home (random.ascii/alpha 5) - working-directory (random.ascii/alpha 5) + working_directory (random.ascii/alpha 5) #let [repository (///repository.mock @repository.simulation @repository.empty) fs (file.mock (\ file.default separator)) - program (program.async (program.mock environment.empty home working-directory))]] + program (program.async (program.mock environment.empty home working_directory))]] (wrap (do {! promise.monad} [verdict (do {! ///action.monad} [logging (..execute! program repository fs artifact profile) - expected-library (|> profile + expected_library (|> profile (get@ #///.sources) - set.to-list + set.to_list (export.library fs) (\ ! map (format.run tar.writer))) - actual-pom (\ repository download (///repository.uri artifact ///artifact/extension.pom)) - actual-library (\ repository download (///repository.uri artifact ///artifact/extension.lux-library)) - actual-sha-1 (\ repository download (///repository.uri artifact (format ///artifact/extension.lux-library ///artifact/extension.sha-1))) - actual-md5 (\ repository download (///repository.uri artifact (format ///artifact/extension.lux-library ///artifact/extension.md5))) + actual_pom (\ repository download (///repository.uri artifact ///artifact/extension.pom)) + actual_library (\ repository download (///repository.uri artifact ///artifact/extension.lux_library)) + actual_sha-1 (\ repository download (///repository.uri artifact (format ///artifact/extension.lux_library ///artifact/extension.sha-1))) + actual_md5 (\ repository download (///repository.uri artifact (format ///artifact/extension.lux_library ///artifact/extension.md5))) - #let [deployed-library! + #let [deployed_library! (\ binary.equivalence = - expected-library - actual-library) + expected_library + actual_library) - deployed-pom! + deployed_pom! (\ binary.equivalence = - (|> expected-pom (\ xml.codec encode) (\ encoding.utf8 encode)) - actual-pom) + (|> expected_pom (\ xml.codec encode) (\ encoding.utf8 encode)) + actual_pom) - deployed-sha-1! + deployed_sha-1! (\ binary.equivalence = - (///hash.data (///hash.sha-1 expected-library)) - actual-sha-1) + (///hash.data (///hash.sha-1 expected_library)) + actual_sha-1) - deployed-md5! + deployed_md5! (\ binary.equivalence = - (///hash.data (///hash.md5 expected-library)) - actual-md5)]] + (///hash.data (///hash.md5 expected_library)) + actual_md5)]] (wrap (and (text\= //clean.success logging) - deployed-library! - deployed-pom! - deployed-sha-1! - deployed-md5!)))] + deployed_library! + deployed_pom! + deployed_sha-1! + deployed_md5!)))] (_.cover' [/.do!] (try.default false verdict))))))) diff --git a/stdlib/source/test/aedifex/command/deps.lux b/stdlib/source/test/aedifex/command/deps.lux index 84c51dc93..7002238e7 100644 --- a/stdlib/source/test/aedifex/command/deps.lux +++ b/stdlib/source/test/aedifex/command/deps.lux @@ -52,55 +52,55 @@ (<| (_.covering /._) (do random.monad [home (random.ascii/alpha 5) - working-directory (random.ascii/alpha 5) + working_directory (random.ascii/alpha 5) - dependee-artifact $///artifact.random - depender-artifact (random.filter (predicate.complement - (\ ///artifact.equivalence = dependee-artifact)) + dependee_artifact $///artifact.random + depender_artifact (random.filter (predicate.complement + (\ ///artifact.equivalence = dependee_artifact)) $///artifact.random) - [_ dependee-package] $///package.random - [_ depender-package] $///package.random + [_ dependee_package] $///package.random + [_ depender_package] $///package.random - #let [dependee {#///dependency.artifact dependee-artifact - #///dependency.type ///artifact/type.lux-library} - depender {#///dependency.artifact depender-artifact - #///dependency.type ///artifact/type.lux-library} + #let [dependee {#///dependency.artifact dependee_artifact + #///dependency.type ///artifact/type.lux_library} + depender {#///dependency.artifact depender_artifact + #///dependency.type ///artifact/type.lux_library} - dependee-pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some dependee-artifact)) + dependee_pom (|> (\ ///.monoid identity) + (set@ #///.identity (#.Some dependee_artifact)) ///pom.write try.assume) - depender-pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some depender-artifact)) - (set@ #///.dependencies (set.from-list ///dependency.hash (list dependee))) + depender_pom (|> (\ ///.monoid identity) + (set@ #///.identity (#.Some depender_artifact)) + (set@ #///.dependencies (set.from_list ///dependency.hash (list dependee))) ///pom.write try.assume) - dependee-package (|> dependee-package + dependee_package (|> dependee_package (set@ #///package.origin #///package.Remote) - (set@ #///package.pom [dependee-pom #///dependency/status.Unverified])) - depender-package (|> depender-package + (set@ #///package.pom [dependee_pom #///dependency/status.Unverified])) + depender_package (|> depender_package (set@ #///package.origin #///package.Remote) - (set@ #///package.pom [depender-pom #///dependency/status.Unverified])) + (set@ #///package.pom [depender_pom #///dependency/status.Unverified])) fs (file.mock (\ file.default separator)) - program (program.async (program.mock environment.empty home working-directory))]] + program (program.async (program.mock environment.empty home working_directory))]] (wrap (do promise.monad [verdict (do ///action.monad [#let [console (@version.echo "")] pre (|> ///dependency/resolution.empty - (dictionary.put dependee dependee-package) - (///cache.write-all program fs)) + (dictionary.put dependee dependee_package) + (///cache.write_all program fs)) post (|> (\ ///.monoid identity) - (set@ #///.dependencies (set.from-list ///dependency.hash (list dependee depender))) - (/.do! program console fs (list (///repository.mock ($///dependency/resolution.single depender-artifact depender-package) [])))) + (set@ #///.dependencies (set.from_list ///dependency.hash (list dependee depender))) + (/.do! program console fs (list (///repository.mock ($///dependency/resolution.single depender_artifact depender_package) [])))) logging! (\ ///action.monad map (text\= //clean.success) - (!.use (\ console read-line) []))] + (!.use (\ console read_line) []))] (wrap (and logging! - (and (set.member? pre dependee-artifact) - (not (set.member? pre depender-artifact))) + (and (set.member? pre dependee_artifact) + (not (set.member? pre depender_artifact))) (and (dictionary.key? post dependee) (dictionary.key? post depender)))))] (_.cover' [/.do!] diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux index 9ffa65bab..9df49efa4 100644 --- a/stdlib/source/test/aedifex/command/install.lux +++ b/stdlib/source/test/aedifex/command/install.lux @@ -44,9 +44,9 @@ ["#." artifact ["#/." extension]]]]]}) -(def: (make-sources! fs sources) +(def: (make_sources! fs sources) (-> (file.System Promise) (Set Path) (Promise (Try Any))) - (loop [sources (set.to-list sources)] + (loop [sources (set.to_list sources)] (case sources #.Nil (|> [] @@ -56,9 +56,9 @@ (#.Cons head tail) (do (try.with promise.monad) [_ (: (Promise (Try Path)) - (file.make-directories promise.monad fs head)) + (file.make_directories promise.monad fs head)) _ (: (Promise (Try (File Promise))) - (file.get-file promise.monad fs (format head (\ fs separator) head ".lux")))] + (file.get_file promise.monad fs (format head (\ fs separator) head ".lux")))] (recur tail))))) (def: (execute! program fs sample) @@ -67,11 +67,11 @@ [home (\ program home [])] (do ///action.monad [#let [console (@version.echo "")] - _ (..make-sources! fs (get@ #///.sources sample)) + _ (..make_sources! fs (get@ #///.sources sample)) _ (: (Promise (Try Path)) - (file.make-directories promise.monad fs (///local.repository fs home))) + (file.make_directories promise.monad fs (///local.repository fs home))) _ (/.do! program console fs sample)] - (!.use (\ console read-line) [])))) + (!.use (\ console read_line) [])))) (def: #export test Test @@ -81,33 +81,33 @@ sample (\ ! map (set@ #///.identity (#.Some identity)) @profile.random) home (random.ascii/alpha 5) - working-directory (random.ascii/alpha 5)] + working_directory (random.ascii/alpha 5)] ($_ _.and (wrap (do {! promise.monad} [#let [fs (file.mock (\ file.default separator)) - program (program.async (program.mock environment.empty home working-directory))] + program (program.async (program.mock environment.empty home working_directory))] verdict (do ///action.monad [logging (..execute! program fs sample) - #let [artifact-path (format (///local.path fs home identity) + #let [artifact_path (format (///local.path fs home identity) (\ fs separator) (///artifact.identity identity)) - library-path (format artifact-path ///artifact/extension.lux-library) - pom-path (format artifact-path ///artifact/extension.pom)] + library_path (format artifact_path ///artifact/extension.lux_library) + pom_path (format artifact_path ///artifact/extension.pom)] - library-exists! (\ promise.monad map + library_exists! (\ promise.monad map exception.return - (file.file-exists? promise.monad fs library-path)) - pom-exists! (\ promise.monad map + (file.file_exists? promise.monad fs library_path)) + pom_exists! (\ promise.monad map exception.return - (file.file-exists? promise.monad fs pom-path))] + (file.file_exists? promise.monad fs pom_path))] (wrap (and (text\= //clean.success logging) - library-exists! - pom-exists!)))] + library_exists! + pom_exists!)))] (_.cover' [/.do!] (try.default false verdict)))) (wrap (do {! promise.monad} [#let [fs (file.mock (\ file.default separator)) - program (program.async (program.mock environment.empty home working-directory))] + program (program.async (program.mock environment.empty home working_directory))] logging (..execute! program fs (set@ #///.identity #.None sample))] (_.cover' [/.failure] (|> logging diff --git a/stdlib/source/test/aedifex/command/pom.lux b/stdlib/source/test/aedifex/command/pom.lux index d179031ea..33c102926 100644 --- a/stdlib/source/test/aedifex/command/pom.lux +++ b/stdlib/source/test/aedifex/command/pom.lux @@ -49,21 +49,21 @@ (try\map (|>> (\ xml.codec encode) (\ encoding.utf8 encode))) (\ ! wrap)) file (: (Promise (Try (File Promise))) - (file.get-file promise.monad fs path)) + (file.get_file promise.monad fs path)) actual (!.use (\ file content) []) logging! (\ ///action.monad map (text\= //clean.success) - (!.use (\ console read-line) [])) + (!.use (\ console read_line) [])) - #let [expected-path! + #let [expected_path! (text\= ///pom.file path) - expected-content! + expected_content! (\ binary.equivalence = expected actual)]] (wrap (and logging! - expected-path! - expected-content!)))] + expected_path! + expected_content!)))] (_.cover' [/.do!] (try.default false verdict))) diff --git a/stdlib/source/test/aedifex/command/test.lux b/stdlib/source/test/aedifex/command/test.lux index b63662bc0..2d077ab87 100644 --- a/stdlib/source/test/aedifex/command/test.lux +++ b/stdlib/source/test/aedifex/command/test.lux @@ -45,32 +45,32 @@ [program (random.ascii/alpha 5) target (random.ascii/alpha 5) home (random.ascii/alpha 5) - working-directory (random.ascii/alpha 5) - #let [empty-profile (: Profile + working_directory (random.ascii/alpha 5) + #let [empty_profile (: Profile (\ ///.monoid identity)) - with-target (: (-> Profile Profile) + with_target (: (-> Profile Profile) (set@ #///.target (#.Some target))) - with-program (: (-> Profile Profile) + with_program (: (-> Profile Profile) (set@ #///.program (#.Some program))) - profile (|> empty-profile - with-program - with-target)] + profile (|> empty_profile + with_program + with_target)] resolution @build.resolution] ($_ _.and (let [fs (file.mock (\ file.default separator)) console (@version.echo "")] (wrap (do promise.monad [verdict (do ///action.monad - [_ (/.do! console (program.async (program.mock environment.empty home working-directory)) fs (@build.good-shell []) resolution profile) - build-start (!.use (\ console read-line) []) - build-end (!.use (\ console read-line) []) - test-start (!.use (\ console read-line) []) - test-end (!.use (\ console read-line) [])] - (wrap (and (and (text\= //build.start build-start) - (text\= //build.success build-end)) - (and (text\= /.start test-start) - (text\= /.success test-end)))))] + [_ (/.do! console (program.async (program.mock environment.empty home working_directory)) fs (@build.good_shell []) resolution profile) + build_start (!.use (\ console read_line) []) + build_end (!.use (\ console read_line) []) + test_start (!.use (\ console read_line) []) + test_end (!.use (\ console read_line) [])] + (wrap (and (and (text\= //build.start build_start) + (text\= //build.success build_end)) + (and (text\= /.start test_start) + (text\= /.success test_end)))))] (_.cover' [/.do! /.start /.success] (try.default false verdict))))) @@ -78,33 +78,33 @@ console (@version.echo "")] (wrap (do promise.monad [verdict (do ///action.monad - [#let [bad-shell (shell.mock - (function (_ [actual-environment actual-working-directory actual-command actual-arguments]) + [#let [bad_shell (shell.mock + (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) (#try.Success (: (shell.Simulation []) (structure - (def: (on-read state) - (#try.Failure "on-read")) - (def: (on-error state) - (#try.Failure "on-error")) - (def: (on-write input state) - (#try.Failure "on-write")) - (def: (on-destroy state) - (#try.Failure "on-destroy")) - (def: (on-await state) - (#try.Success [state (if (text.ends-with? " build" actual-command) + (def: (on_read state) + (#try.Failure "on_read")) + (def: (on_error state) + (#try.Failure "on_error")) + (def: (on_write input state) + (#try.Failure "on_write")) + (def: (on_destroy state) + (#try.Failure "on_destroy")) + (def: (on_await state) + (#try.Success [state (if (text.ends_with? " build" actual_command) shell.normal shell.error)])))))) [])] - _ (/.do! console (program.async (program.mock environment.empty home working-directory)) fs bad-shell resolution profile) - build-start (!.use (\ console read-line) []) - build-end (!.use (\ console read-line) []) - test-start (!.use (\ console read-line) []) - test-end (!.use (\ console read-line) [])] - (wrap (and (and (text\= //build.start build-start) - (text\= //build.success build-end)) - (and (text\= /.start test-start) - (text\= /.failure test-end)))))] + _ (/.do! console (program.async (program.mock environment.empty home working_directory)) fs bad_shell resolution profile) + build_start (!.use (\ console read_line) []) + build_end (!.use (\ console read_line) []) + test_start (!.use (\ console read_line) []) + test_end (!.use (\ console read_line) [])] + (wrap (and (and (text\= //build.start build_start) + (text\= //build.success build_end)) + (and (text\= /.start test_start) + (text\= /.failure test_end)))))] (_.cover' [/.failure] (try.default false verdict))))) )))) diff --git a/stdlib/source/test/aedifex/command/version.lux b/stdlib/source/test/aedifex/command/version.lux index 5e60f6b9b..ee26b3b5d 100644 --- a/stdlib/source/test/aedifex/command/version.lux +++ b/stdlib/source/test/aedifex/command/version.lux @@ -29,34 +29,34 @@ {#program ["." /]}) -(exception: #export console-is-closed!) +(exception: #export console_is_closed!) (structure: simulation (Simulation [Bit Text]) - (def: (on-read [open? state]) + (def: (on_read [open? state]) (if open? - (try.from-maybe + (try.from_maybe (do maybe.monad [head (text.nth 0 state) [_ tail] (text.split 1 state)] (wrap [[open? tail] head]))) - (exception.throw ..console-is-closed! []))) - (def: (on-read-line [open? state]) + (exception.throw ..console_is_closed! []))) + (def: (on_read_line [open? state]) (if open? - (try.from-maybe + (try.from_maybe (do maybe.monad - [[output state] (text.split-with text.new-line state)] + [[output state] (text.split_with text.new_line state)] (wrap [[open? state] output]))) - (exception.throw ..console-is-closed! []))) - (def: (on-write input [open? state]) + (exception.throw ..console_is_closed! []))) + (def: (on_write input [open? state]) (if open? (#try.Success [open? (format state input)]) - (exception.throw ..console-is-closed! []))) - (def: (on-close [open? buffer]) + (exception.throw ..console_is_closed! []))) + (def: (on_close [open? buffer]) (if open? (#try.Success [false buffer]) - (exception.throw ..console-is-closed! [])))) + (exception.throw ..console_is_closed! [])))) (def: #export echo (-> Text (Console Promise)) @@ -71,7 +71,7 @@ [#let [console (..echo "")] verdict (do (try.with promise.monad) [_ (/.do! console profile) - logging (!.use (\ console read-line) [])] + logging (!.use (\ console read_line) [])] (wrap (text\= (version.format language/lux.version) logging)))] (_.cover' [/.do!] diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index 92ced9e74..5f262bce4 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -52,260 +52,260 @@ [artifact $///artifact.random [_ package] $///package.random] (wrap (dictionary.put {#///dependency.artifact artifact - #///dependency.type ///artifact/type.lux-library} + #///dependency.type ///artifact/type.lux_library} package /.empty)))) (def: #export (single artifact package) (-> Artifact Package (Simulation Any)) (structure - (def: (on-download uri state) + (def: (on_download uri state) (if (text.contains? (///artifact.uri artifact) uri) - (cond (text.ends-with? ///artifact/extension.lux-library uri) + (cond (text.ends_with? ///artifact/extension.lux_library uri) (#try.Success [state (|> package (get@ #///package.library) product.left)]) - (text.ends-with? ///artifact/extension.pom uri) + (text.ends_with? ///artifact/extension.pom uri) (#try.Success [state (|> package (get@ #///package.pom) product.left (\ xml.codec encode) (\ encoding.utf8 encode))]) - ## (text.ends-with? ///artifact/extension.sha-1 uri) + ## (text.ends_with? ///artifact/extension.sha-1 uri) ## (#try.Success [state (|> package ## (get@ #///package.sha-1) - ## (\ ///hash.sha-1-codec encode) + ## (\ ///hash.sha-1_codec encode) ## (\ encoding.utf8 encode))]) - ## (text.ends-with? ///artifact/extension.md5 uri) + ## (text.ends_with? ///artifact/extension.md5 uri) ## (#try.Success [state (|> package ## (get@ #///package.md5) - ## (\ ///hash.md5-codec encode) + ## (\ ///hash.md5_codec encode) ## (\ encoding.utf8 encode))]) ## else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) - (def: (on-upload uri binary state) + (def: (on_upload uri binary state) (#try.Failure "NOPE")))) (def: one Test (do {! random.monad} - [expected-artifact $///artifact.random - [_ expected-package] $///package.random - [_ dummy-package] (random.filter (|>> product.right - (set@ #///package.pom (get@ #///package.pom expected-package)) - (\ ///package.equivalence = expected-package) + [expected_artifact $///artifact.random + [_ expected_package] $///package.random + [_ dummy_package] (random.filter (|>> product.right + (set@ #///package.pom (get@ #///package.pom expected_package)) + (\ ///package.equivalence = expected_package) not) $///package.random) - #let [good (..single expected-artifact expected-package) - bad-sha-1 (: (Simulation Any) + #let [good (..single expected_artifact expected_package) + bad_sha-1 (: (Simulation Any) (structure - (def: (on-download uri state) - (if (text.contains? (///artifact.uri expected-artifact) uri) - (cond (text.ends-with? ///artifact/extension.lux-library uri) - (#try.Success [state (|> expected-package + (def: (on_download uri state) + (if (text.contains? (///artifact.uri expected_artifact) uri) + (cond (text.ends_with? ///artifact/extension.lux_library uri) + (#try.Success [state (|> expected_package (get@ #///package.library) product.left)]) - (text.ends-with? ///artifact/extension.pom uri) - (#try.Success [state (|> expected-package + (text.ends_with? ///artifact/extension.pom uri) + (#try.Success [state (|> expected_package (get@ #///package.pom) product.left (\ xml.codec encode) (\ encoding.utf8 encode))]) ## (text\= extension ///artifact/extension.sha-1) - ## (#try.Success [state (|> dummy-package + ## (#try.Success [state (|> dummy_package ## (get@ #///package.sha-1) - ## (\ ///hash.sha-1-codec encode) + ## (\ ///hash.sha-1_codec encode) ## (\ encoding.utf8 encode))]) ## (text\= extension ///artifact/extension.md5) - ## (#try.Success [state (|> expected-package + ## (#try.Success [state (|> expected_package ## (get@ #///package.md5) - ## (\ ///hash.md5-codec encode) + ## (\ ///hash.md5_codec encode) ## (\ encoding.utf8 encode))]) ## else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) - (def: (on-upload uri binary state) + (def: (on_upload uri binary state) (#try.Failure "NOPE")))) - bad-md5 (: (Simulation Any) + bad_md5 (: (Simulation Any) (structure - (def: (on-download uri state) - (if (text.contains? (///artifact.uri expected-artifact) uri) - (cond (text.ends-with? ///artifact/extension.lux-library uri) - (#try.Success [state (|> expected-package + (def: (on_download uri state) + (if (text.contains? (///artifact.uri expected_artifact) uri) + (cond (text.ends_with? ///artifact/extension.lux_library uri) + (#try.Success [state (|> expected_package (get@ #///package.library) product.left)]) - (text.ends-with? ///artifact/extension.pom uri) - (#try.Success [state (|> expected-package + (text.ends_with? ///artifact/extension.pom uri) + (#try.Success [state (|> expected_package (get@ #///package.pom) product.left (\ xml.codec encode) (\ encoding.utf8 encode))]) ## (text\= extension ///artifact/extension.sha-1) - ## (#try.Success [state (|> expected-package + ## (#try.Success [state (|> expected_package ## (get@ #///package.sha-1) - ## (\ ///hash.sha-1-codec encode) + ## (\ ///hash.sha-1_codec encode) ## (\ encoding.utf8 encode))]) ## (text\= extension ///artifact/extension.md5) - ## (#try.Success [state (|> dummy-package + ## (#try.Success [state (|> dummy_package ## (get@ #///package.md5) - ## (\ ///hash.md5-codec encode) + ## (\ ///hash.md5_codec encode) ## (\ encoding.utf8 encode))]) ## else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) - (def: (on-upload uri binary state) + (def: (on_upload uri binary state) (#try.Failure "NOPE"))))]] (`` ($_ _.and (wrap (do promise.monad - [actual-package (/.one (///repository.mock good []) - {#///dependency.artifact expected-artifact - #///dependency.type ///artifact/type.lux-library})] + [actual_package (/.one (///repository.mock good []) + {#///dependency.artifact expected_artifact + #///dependency.type ///artifact/type.lux_library})] (_.cover' [/.one] - (case actual-package - (#try.Success actual-package) + (case actual_package + (#try.Success actual_package) (\ ///package.equivalence = - (set@ #///package.origin #///package.Remote expected-package) - actual-package) + (set@ #///package.origin #///package.Remote expected_package) + actual_package) (#try.Failure _) false)))) (~~ (template [<exception> <bad>] [(wrap (do promise.monad - [actual-package (/.one (///repository.mock <bad> []) - {#///dependency.artifact expected-artifact - #///dependency.type ///artifact/type.lux-library})] + [actual_package (/.one (///repository.mock <bad> []) + {#///dependency.artifact expected_artifact + #///dependency.type ///artifact/type.lux_library})] (_.cover' [<exception>] - (case actual-package + (case actual_package (#try.Failure error) (exception.match? <exception> error) (#try.Success _) false))))] - [/.sha-1-does-not-match bad-sha-1] - [/.md5-does-not-match bad-md5] + [/.sha-1_does_not_match bad_sha-1] + [/.md5_does_not_match bad_md5] )) )))) (def: any Test (do {! random.monad} - [expected-artifact $///artifact.random - [_ expected-package] $///package.random - [_ dummy-package] (random.filter (|>> product.right - (set@ #///package.pom (get@ #///package.pom expected-package)) - (\ ///package.equivalence = expected-package) + [expected_artifact $///artifact.random + [_ expected_package] $///package.random + [_ dummy_package] (random.filter (|>> product.right + (set@ #///package.pom (get@ #///package.pom expected_package)) + (\ ///package.equivalence = expected_package) not) $///package.random) - #let [good (..single expected-artifact expected-package) - bad-sha-1 (: (Simulation Any) + #let [good (..single expected_artifact expected_package) + bad_sha-1 (: (Simulation Any) (structure - (def: (on-download uri state) - (if (text.contains? (///artifact.uri expected-artifact) uri) - (cond (text.ends-with? ///artifact/extension.lux-library uri) - (#try.Success [state (|> expected-package + (def: (on_download uri state) + (if (text.contains? (///artifact.uri expected_artifact) uri) + (cond (text.ends_with? ///artifact/extension.lux_library uri) + (#try.Success [state (|> expected_package (get@ #///package.library) product.left)]) - (text.ends-with? ///artifact/extension.pom uri) - (#try.Success [state (|> expected-package + (text.ends_with? ///artifact/extension.pom uri) + (#try.Success [state (|> expected_package (get@ #///package.pom) product.left (\ xml.codec encode) (\ encoding.utf8 encode))]) ## (text\= extension ///artifact/extension.sha-1) - ## (#try.Success [state (|> dummy-package + ## (#try.Success [state (|> dummy_package ## (get@ #///package.sha-1) - ## (\ ///hash.sha-1-codec encode) + ## (\ ///hash.sha-1_codec encode) ## (\ encoding.utf8 encode))]) ## (text\= extension ///artifact/extension.md5) - ## (#try.Success [state (|> expected-package + ## (#try.Success [state (|> expected_package ## (get@ #///package.md5) - ## (\ ///hash.md5-codec encode) + ## (\ ///hash.md5_codec encode) ## (\ encoding.utf8 encode))]) ## else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) - (def: (on-upload uri binary state) + (def: (on_upload uri binary state) (#try.Failure "NOPE")))) - bad-md5 (: (Simulation Any) + bad_md5 (: (Simulation Any) (structure - (def: (on-download uri state) - (if (text.contains? (///artifact.uri expected-artifact) uri) - (cond (text.ends-with? ///artifact/extension.lux-library uri) - (#try.Success [state (|> expected-package + (def: (on_download uri state) + (if (text.contains? (///artifact.uri expected_artifact) uri) + (cond (text.ends_with? ///artifact/extension.lux_library uri) + (#try.Success [state (|> expected_package (get@ #///package.library) product.left)]) - (text.ends-with? ///artifact/extension.pom uri) - (#try.Success [state (|> expected-package + (text.ends_with? ///artifact/extension.pom uri) + (#try.Success [state (|> expected_package (get@ #///package.pom) product.left (\ xml.codec encode) (\ encoding.utf8 encode))]) ## (text\= extension ///artifact/extension.sha-1) - ## (#try.Success [state (|> expected-package + ## (#try.Success [state (|> expected_package ## (get@ #///package.sha-1) - ## (\ ///hash.sha-1-codec encode) + ## (\ ///hash.sha-1_codec encode) ## (\ encoding.utf8 encode))]) ## (text\= extension ///artifact/extension.md5) - ## (#try.Success [state (|> dummy-package + ## (#try.Success [state (|> dummy_package ## (get@ #///package.md5) - ## (\ ///hash.md5-codec encode) + ## (\ ///hash.md5_codec encode) ## (\ encoding.utf8 encode))]) ## else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) - (def: (on-upload uri binary state) + (def: (on_upload uri binary state) (#try.Failure "NOPE"))))]] ($_ _.and (wrap (do promise.monad - [actual-package (/.any (list (///repository.mock bad-sha-1 []) - (///repository.mock bad-md5 []) + [actual_package (/.any (list (///repository.mock bad_sha-1 []) + (///repository.mock bad_md5 []) (///repository.mock good [])) - {#///dependency.artifact expected-artifact - #///dependency.type ///artifact/type.lux-library})] + {#///dependency.artifact expected_artifact + #///dependency.type ///artifact/type.lux_library})] (_.cover' [/.any] - (case actual-package - (#try.Success actual-package) + (case actual_package + (#try.Success actual_package) (\ ///package.equivalence = - (set@ #///package.origin #///package.Remote expected-package) - actual-package) + (set@ #///package.origin #///package.Remote expected_package) + actual_package) (#try.Failure _) false)))) (wrap (do promise.monad - [actual-package (/.any (list (///repository.mock bad-sha-1 []) - (///repository.mock bad-md5 [])) - {#///dependency.artifact expected-artifact - #///dependency.type ///artifact/type.lux-library})] - (_.cover' [/.cannot-resolve] - (case actual-package + [actual_package (/.any (list (///repository.mock bad_sha-1 []) + (///repository.mock bad_md5 [])) + {#///dependency.artifact expected_artifact + #///dependency.type ///artifact/type.lux_library})] + (_.cover' [/.cannot_resolve] + (case actual_package (#try.Failure error) - (exception.match? /.cannot-resolve error) + (exception.match? /.cannot_resolve error) (#try.Success _) false)))) @@ -314,49 +314,49 @@ (def: all Test (do {! random.monad} - [dependee-artifact $///artifact.random - depender-artifact (random.filter (predicate.complement - (\ ///artifact.equivalence = dependee-artifact)) + [dependee_artifact $///artifact.random + depender_artifact (random.filter (predicate.complement + (\ ///artifact.equivalence = dependee_artifact)) $///artifact.random) - ignored-artifact (random.filter (predicate.complement - (predicate.unite (\ ///artifact.equivalence = dependee-artifact) - (\ ///artifact.equivalence = depender-artifact))) + ignored_artifact (random.filter (predicate.complement + (predicate.unite (\ ///artifact.equivalence = dependee_artifact) + (\ ///artifact.equivalence = depender_artifact))) $///artifact.random) - [_ dependee-package] $///package.random - [_ depender-package] $///package.random - [_ ignored-package] $///package.random + [_ dependee_package] $///package.random + [_ depender_package] $///package.random + [_ ignored_package] $///package.random - #let [dependee {#///dependency.artifact dependee-artifact - #///dependency.type ///artifact/type.lux-library} - depender {#///dependency.artifact depender-artifact - #///dependency.type ///artifact/type.lux-library} - ignored {#///dependency.artifact ignored-artifact - #///dependency.type ///artifact/type.lux-library} + #let [dependee {#///dependency.artifact dependee_artifact + #///dependency.type ///artifact/type.lux_library} + depender {#///dependency.artifact depender_artifact + #///dependency.type ///artifact/type.lux_library} + ignored {#///dependency.artifact ignored_artifact + #///dependency.type ///artifact/type.lux_library} - dependee-pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some dependee-artifact)) + dependee_pom (|> (\ ///.monoid identity) + (set@ #///.identity (#.Some dependee_artifact)) ///pom.write try.assume) - depender-pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some depender-artifact)) - (set@ #///.dependencies (set.from-list ///dependency.hash (list dependee))) + depender_pom (|> (\ ///.monoid identity) + (set@ #///.identity (#.Some depender_artifact)) + (set@ #///.dependencies (set.from_list ///dependency.hash (list dependee))) ///pom.write try.assume) - ignored-pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some ignored-artifact)) + ignored_pom (|> (\ ///.monoid identity) + (set@ #///.identity (#.Some ignored_artifact)) ///pom.write try.assume) - dependee-package (set@ #///package.pom [dependee-pom #///dependency/status.Unverified] dependee-package) - depender-package (set@ #///package.pom [depender-pom #///dependency/status.Unverified] depender-package) - ignored-package (set@ #///package.pom [ignored-pom #///dependency/status.Unverified] ignored-package)]] + dependee_package (set@ #///package.pom [dependee_pom #///dependency/status.Unverified] dependee_package) + depender_package (set@ #///package.pom [depender_pom #///dependency/status.Unverified] depender_package) + ignored_package (set@ #///package.pom [ignored_pom #///dependency/status.Unverified] ignored_package)]] ($_ _.and (wrap (do promise.monad - [resolution (/.all (list (///repository.mock (..single dependee-artifact dependee-package) []) - (///repository.mock (..single depender-artifact depender-package) []) - (///repository.mock (..single ignored-artifact ignored-package) [])) + [resolution (/.all (list (///repository.mock (..single dependee_artifact dependee_package) []) + (///repository.mock (..single depender_artifact depender_package) []) + (///repository.mock (..single ignored_artifact ignored_package) [])) (list depender) /.empty)] (_.cover' [/.all] diff --git a/stdlib/source/test/aedifex/hash.lux b/stdlib/source/test/aedifex/hash.lux index 455835b84..502130970 100644 --- a/stdlib/source/test/aedifex/hash.lux +++ b/stdlib/source/test/aedifex/hash.lux @@ -64,17 +64,17 @@ (#try.Failure error) (exception.match? <exception> error)))))] - [/.sha-1 /.as-sha-1 /.not-a-sha-1] - [/.md5 /.as-md5 /.not-a-md5] + [/.sha-1 /.as_sha-1 /.not_a_sha-1] + [/.md5 /.as_md5 /.not_a_md5] )))) (~~ (template [<codec> <hash>] [(_.for [<codec>] ($codec.spec /.equivalence <codec> (..random <hash>)))] - [/.sha-1-codec /.sha-1] - [/.md5-codec /.md5] + [/.sha-1_codec /.sha-1] + [/.md5_codec /.md5] )) - (_.for [/.not-a-hash] + (_.for [/.not_a_hash] ($_ _.and (~~ (template [<codec> <hash>] [(do random.monad @@ -87,9 +87,9 @@ false (#try.Failure error) - (exception.match? /.not-a-hash error))))] + (exception.match? /.not_a_hash error))))] - [/.sha-1-codec /.sha-1] - [/.md5-codec /.md5] + [/.sha-1_codec /.sha-1] + [/.md5_codec /.md5] )))) )))) diff --git a/stdlib/source/test/aedifex/input.lux b/stdlib/source/test/aedifex/input.lux index a0db21ba6..e2751381a 100644 --- a/stdlib/source/test/aedifex/input.lux +++ b/stdlib/source/test/aedifex/input.lux @@ -30,10 +30,10 @@ ["#." action] ["#." format]]]}) -(def: (with-default-source sources) +(def: (with_default_source sources) (-> (Set //.Source) (Set //.Source)) (if (set.empty? sources) - (set.add //.default-source sources) + (set.add //.default_source sources) sources)) (def: #export test @@ -46,16 +46,16 @@ (wrap (do promise.monad [verdict (do //action.monad [file (: (Promise (Try (File Promise))) - (file.get-file promise.monad fs //project.file)) + (file.get_file promise.monad fs //project.file)) _ (|> expected //format.profile %.code (\ encoding.utf8 encode) - (!.use (\ file over-write))) + (!.use (\ file over_write))) actual (: (Promise (Try Profile)) (/.read promise.monad fs //.default))] (wrap (\ //.equivalence = - (update@ #//.sources ..with-default-source expected) + (update@ #//.sources ..with_default_source expected) actual)))] (_.cover' [/.read] (try.default false verdict))))))) diff --git a/stdlib/source/test/aedifex/local.lux b/stdlib/source/test/aedifex/local.lux index b95bf2e19..7d0492815 100644 --- a/stdlib/source/test/aedifex/local.lux +++ b/stdlib/source/test/aedifex/local.lux @@ -30,8 +30,8 @@ ($_ _.and (_.cover [/.repository /.path] (let [path (/.path fs home sample)] - (and (text.starts-with? (/.repository fs home) + (and (text.starts_with? (/.repository fs home) path) - (text.ends-with? (//artifact.path fs sample) + (text.ends_with? (//artifact.path fs sample) path)))) )))) diff --git a/stdlib/source/test/aedifex/metadata.lux b/stdlib/source/test/aedifex/metadata.lux index 9dd3fac22..0cac022f8 100644 --- a/stdlib/source/test/aedifex/metadata.lux +++ b/stdlib/source/test/aedifex/metadata.lux @@ -24,9 +24,9 @@ [sample @artifact.random] ($_ _.and (_.cover [/.project] - (text.ends-with? /.file (/.project sample))) + (text.ends_with? /.file (/.project sample))) (_.cover [/.version] - (text.ends-with? /.file (/.version sample))) + (text.ends_with? /.file (/.version sample))) ))) /artifact.test diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux index bb105f305..3177c6ff2 100644 --- a/stdlib/source/test/aedifex/metadata/artifact.lux +++ b/stdlib/source/test/aedifex/metadata/artifact.lux @@ -35,21 +35,21 @@ (do {! random.monad} [year (\ ! map (|>> (n.% 10,000) .int) random.nat) month (\ ! map (n.% 13) random.nat) - day-of-month (\ ! map (n.% 29) random.nat) + day_of_month (\ ! map (n.% 29) random.nat) hour (\ ! map (n.% 24) random.nat) minute (\ ! map (n.% 60) random.nat) second (\ ! map (n.% 60) random.nat)] (wrap (try.assume (do try.monad [year (year.year year) - month (month.by-number month) - date (date.date year month day-of-month) + month (month.by_number month) + date (date.date year month day_of_month) time (time.time {#time.hour hour #time.minute minute #time.second second - #time.milli-second 0})] - (wrap (instant.from-date-time date time)))))))) + #time.milli_second 0})] + (wrap (instant.from_date_time date time)))))))) (def: #export test Test diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux index e17765038..e9e42be9a 100644 --- a/stdlib/source/test/aedifex/metadata/snapshot.lux +++ b/stdlib/source/test/aedifex/metadata/snapshot.lux @@ -29,31 +29,31 @@ {#program ["." /]}) -(def: random-instant +(def: random_instant (Random Instant) (do {! random.monad} [year (\ ! map (|>> (n.% 10,000) .int) random.nat) month (\ ! map (n.% 13) random.nat) - day-of-month (\ ! map (n.% 29) random.nat) + day_of_month (\ ! map (n.% 29) random.nat) hour (\ ! map (n.% 24) random.nat) minute (\ ! map (n.% 60) random.nat) second (\ ! map (n.% 60) random.nat)] (wrap (try.assume (do try.monad [year (year.year year) - month (month.by-number month) - date (date.date year month day-of-month) + month (month.by_number month) + date (date.date year month day_of_month) time (time.time {#time.hour hour #time.minute minute #time.second second - #time.milli-second 0})] - (wrap (instant.from-date-time date time))))))) + #time.milli_second 0})] + (wrap (instant.from_date_time date time))))))) -(def: random-versioning +(def: random_versioning (Random /.Versioning) ($_ random.and - ..random-instant + ..random_instant random.nat (random.list 5 $///type.random) )) @@ -64,7 +64,7 @@ (random.ascii/alpha 5) (random.ascii/alpha 5) (random.ascii/alpha 5) - ..random-versioning)) + ..random_versioning)) (def: #export test Test diff --git a/stdlib/source/test/aedifex/package.lux b/stdlib/source/test/aedifex/package.lux index 56169a766..7562547df 100644 --- a/stdlib/source/test/aedifex/package.lux +++ b/stdlib/source/test/aedifex/package.lux @@ -34,10 +34,10 @@ (def: #export random (Random [//.Profile /.Package]) (do {! random.monad} - [content-size (\ ! map (n.% 100) random.nat) - content (_binary.random content-size) + [content_size (\ ! map (n.% 100) random.nat) + content (_binary.random content_size) [profile pom] (random.one (function (_ profile) - (try.to-maybe + (try.to_maybe (do try.monad [pom (//pom.write profile)] (wrap [profile pom])))) diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux index 7aeff7a18..1eb62b75d 100644 --- a/stdlib/source/test/aedifex/parser.lux +++ b/stdlib/source/test/aedifex/parser.lux @@ -36,32 +36,32 @@ (Random //.Name) (random.ascii/alpha 1)) -(def: (list-of random) +(def: (list_of random) (All [a] (-> (Random a) (Random (List a)))) (do {! random.monad} [size (\ ! map (n.% 5) random.nat)] (random.list size random))) -(def: (dictionary-of key-hash key-random value-random) +(def: (dictionary_of key_hash key_random value_random) (All [k v] (-> (Hash k) (Random k) (Random v) (Random (Dictionary k v)))) (\ random.functor map - (dictionary.from-list key-hash) - (..list-of (random.and key-random value-random)))) + (dictionary.from_list key_hash) + (..list_of (random.and key_random value_random)))) (def: random (Random Project) - (..dictionary-of text.hash ..name @profile.random)) + (..dictionary_of text.hash ..name @profile.random)) -(def: with-default-sources +(def: with_default_sources (-> //.Profile //.Profile) (update@ #//.sources (: (-> (Set //.Source) (Set //.Source)) (function (_ sources) (if (set.empty? sources) - (set.from-list text.hash (list //.default-source)) + (set.from_list text.hash (list //.default_source)) sources))))) -(def: single-profile +(def: single_profile Test (do random.monad [expected @profile.random] @@ -72,20 +72,20 @@ (<c>.run /.project) (case> (#try.Success actual) (|> expected - ..with-default-sources + ..with_default_sources (//project.project //.default) (\ //project.equivalence = actual)) (#try.Failure error) false))))) -(def: (with-empty-profile project) +(def: (with_empty_profile project) (-> Project Project) (if (dictionary.empty? project) (//project.project //.default (\ //.monoid identity)) project)) -(def: multiple-profiles +(def: multiple_profiles Test (do random.monad [expected ..random] @@ -96,11 +96,11 @@ (<c>.run /.project) (case> (#try.Success actual) (|> expected - ..with-empty-profile + ..with_empty_profile dictionary.entries (list\map (function (_ [name profile]) - [name (..with-default-sources profile)])) - (dictionary.from-list text.hash) + [name (..with_default_sources profile)])) + (dictionary.from_list text.hash) (\ //project.equivalence = actual)) (#try.Failure error) @@ -113,6 +113,6 @@ (_.for [/.project //format.Format //format.profile //format.project] ($_ _.and - ..single-profile - ..multiple-profiles + ..single_profile + ..multiple_profiles )))) diff --git a/stdlib/source/test/aedifex/pom.lux b/stdlib/source/test/aedifex/pom.lux index fefdfb7bb..c87ff0590 100644 --- a/stdlib/source/test/aedifex/pom.lux +++ b/stdlib/source/test/aedifex/pom.lux @@ -42,7 +42,7 @@ [(#try.Failure error) #.None] - (exception.match? //.no-identity error) + (exception.match? //.no_identity error) _ false))))) diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index 1743a243a..9316fae66 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -69,23 +69,23 @@ (Random /.Contributor) ..developer) -(def: (list-of random) +(def: (list_of random) (All [a] (-> (Random a) (Random (List a)))) (do {! random.monad} [size (\ ! map (n.% 5) random.nat)] (random.list size random))) -(def: (set-of hash random) +(def: (set_of hash random) (All [a] (-> (Hash a) (Random a) (Random (Set a)))) (\ random.functor map - (set.from-list hash) - (..list-of random))) + (set.from_list hash) + (..list_of random))) -(def: (dictionary-of key-hash key-random value-random) +(def: (dictionary_of key_hash key_random value_random) (All [k v] (-> (Hash k) (Random k) (Random v) (Random (Dictionary k v)))) (\ random.functor map - (dictionary.from-list key-hash) - (..list-of (random.and key-random value-random)))) + (dictionary.from_list key_hash) + (..list_of (random.and key_random value_random)))) (def: info (Random /.Info) @@ -93,10 +93,10 @@ (random.maybe (random.ascii/alpha 1)) (random.maybe ..scm) (random.maybe (random.ascii/alpha 1)) - (..list-of ..license) + (..list_of ..license) (random.maybe ..organization) - (..list-of ..developer) - (..list-of ..contributor) + (..list_of ..developer) + (..list_of ..contributor) )) (def: name @@ -118,16 +118,16 @@ (def: #export random (Random /.Profile) ($_ random.and - (..list-of ..name) + (..list_of ..name) (random.maybe @artifact.random) (random.maybe ..info) - (..set-of text.hash ..repository) - (..set-of //dependency.hash @dependency.random) - (..set-of text.hash ..source) + (..set_of text.hash ..repository) + (..set_of //dependency.hash @dependency.random) + (..set_of text.hash ..source) (random.maybe ..target) (random.maybe (random.ascii/alpha 1)) (random.maybe (random.ascii/alpha 1)) - (..dictionary-of text.hash (random.ascii/alpha 1) ..repository) + (..dictionary_of text.hash (random.ascii/alpha 1) ..repository) )) (def: #export test diff --git a/stdlib/source/test/aedifex/project.lux b/stdlib/source/test/aedifex/project.lux index 4ea00a3c4..cec9c0cae 100644 --- a/stdlib/source/test/aedifex/project.lux +++ b/stdlib/source/test/aedifex/project.lux @@ -47,50 +47,50 @@ ($monoid.spec /.equivalence /.monoid ..random)) (do random.monad - [[super-name super-profile] ..profile - [dummy-name dummy-profile] (random.filter (|>> product.left (text\= super-name) not) + [[super_name super_profile] ..profile + [dummy_name dummy_profile] (random.filter (|>> product.left (text\= super_name) not) ..profile) - [sub-name sub-profile] (random.filter (function (_ [name profile]) - (and (not (text\= super-name name)) - (not (text\= dummy-name name)))) + [sub_name sub_profile] (random.filter (function (_ [name profile]) + (and (not (text\= super_name name)) + (not (text\= dummy_name name)))) ..profile) - fake-name (random.filter (function (_ name) - (and (not (text\= super-name name)) - (not (text\= dummy-name name)) - (not (text\= sub-name name)))) + fake_name (random.filter (function (_ name) + (and (not (text\= super_name name)) + (not (text\= dummy_name name)) + (not (text\= sub_name name)))) (random.ascii/alpha 1)) #let [project ($_ (\ /.monoid compose) - (/.project super-name super-profile) - (/.project dummy-name dummy-profile) - (/.project sub-name (set@ #//.parents (list super-name) sub-profile))) + (/.project super_name super_profile) + (/.project dummy_name dummy_profile) + (/.project sub_name (set@ #//.parents (list super_name) sub_profile))) circular ($_ (\ /.monoid compose) - (/.project super-name (set@ #//.parents (list sub-name) super-profile)) - (/.project dummy-name dummy-profile) - (/.project sub-name (set@ #//.parents (list super-name) sub-profile)))]] + (/.project super_name (set@ #//.parents (list sub_name) super_profile)) + (/.project dummy_name dummy_profile) + (/.project sub_name (set@ #//.parents (list super_name) sub_profile)))]] ($_ _.and (_.cover [/.profile] - (and (|> (/.profile super-name project) - (try\map (\ //.equivalence = super-profile)) + (and (|> (/.profile super_name project) + (try\map (\ //.equivalence = super_profile)) (try.default false)) - (|> (/.profile dummy-name project) - (try\map (\ //.equivalence = dummy-profile)) + (|> (/.profile dummy_name project) + (try\map (\ //.equivalence = dummy_profile)) (try.default false)) - (|> (/.profile sub-name project) - (try\map (\ //.equivalence = (\ //.monoid compose sub-profile super-profile))) + (|> (/.profile sub_name project) + (try\map (\ //.equivalence = (\ //.monoid compose sub_profile super_profile))) (try.default false)))) - (_.cover [/.unknown-profile] - (case (/.profile fake-name project) + (_.cover [/.unknown_profile] + (case (/.profile fake_name project) (#try.Success _) false (#try.Failure error) - (exception.match? /.unknown-profile error))) - (_.cover [/.circular-dependency] - (case (/.profile sub-name circular) + (exception.match? /.unknown_profile error))) + (_.cover [/.circular_dependency] + (case (/.profile sub_name circular) (#try.Success _) false (#try.Failure error) - (exception.match? /.circular-dependency error))) + (exception.match? /.circular_dependency error))) )) )))) diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index af96bc572..7b99d080f 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -37,7 +37,7 @@ (-> Version Artifact) (|>> ["com.github.luxlang" "test-artifact"])) -(exception: (not-found {uri URI}) +(exception: (not_found {uri URI}) (exception.report ["URI" (%.text uri)])) @@ -51,14 +51,14 @@ (structure: #export simulation (/.Simulation Store) - (def: (on-download uri state) + (def: (on_download uri state) (case (dictionary.get uri state) (#.Some content) (exception.return [state content]) #.None - (exception.throw ..not-found [uri]))) - (def: (on-upload uri content state) + (exception.throw ..not_found [uri]))) + (def: (on_upload uri content state) (exception.return (dictionary.put uri content state)))) (def: #export test diff --git a/stdlib/source/test/aedifex/runtime.lux b/stdlib/source/test/aedifex/runtime.lux index e1c0a77c1..17b3428d2 100644 --- a/stdlib/source/test/aedifex/runtime.lux +++ b/stdlib/source/test/aedifex/runtime.lux @@ -19,8 +19,8 @@ (~~ (template [<command>] [(_.cover [<command>] (let [command (<command> path)] - (and (text.starts-with? (<command> "") command) - (text.ends-with? path command))))] + (and (text.starts_with? (<command> "") command) + (text.ends_with? path command))))] [/.java] [/.node] diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 7caf3eba1..c00ef0964 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -60,7 +60,7 @@ (not (is? self other)))) ))) -(def: increment-and-decrement +(def: increment_and_decrement Test (do random.monad [value random.i64] @@ -72,15 +72,15 @@ (and (|> (inc value) (n.- value) (n.= 1)) (|> value (n.- (dec value)) (n.= 1))))))) -(def: (check-neighbors has-property? value) +(def: (check_neighbors has_property? value) (All [a] (-> (Predicate (I64 a)) (I64 a) Bit)) - (and (|> value inc has-property?) - (|> value dec has-property?))) + (and (|> value inc has_property?) + (|> value dec has_property?))) -(def: (even-or-odd rand-gen even? odd?) +(def: (even_or_odd rand_gen even? odd?) (All [a] (-> (Random (I64 a)) (Predicate (I64 a)) (Predicate (I64 a)) Test)) (do random.monad - [value rand-gen] + [value rand_gen] ($_ _.and (_.test "Every number is either even or odd." (if (even? value) @@ -88,8 +88,8 @@ (odd? value))) (_.test "Every odd/even number is surrounded by two of the other kind." (if (even? value) - (check-neighbors odd? value) - (check-neighbors even? value)))))) + (check_neighbors odd? value) + (check_neighbors even? value)))))) (type: (Choice a) (-> a a a)) @@ -100,11 +100,11 @@ (type: (Equivalence a) (-> a a Bit)) -(def: (choice rand-gen = [< choose]) +(def: (choice rand_gen = [< choose]) (All [a] (-> (Random a) (Equivalence a) [(Order a) (Choice a)] Test)) (do random.monad - [left rand-gen - right rand-gen + [left rand_gen + right rand_gen #let [choice (choose left right)]] ($_ _.and (_.test "The choice between 2 values is one of them." @@ -115,27 +115,27 @@ (< right choice) (< left choice)))))) -(def: (minimum-and-maximum rand-gen = min' max') +(def: (minimum_and_maximum rand_gen = min' max') (All [a] (-> (Random a) (Equivalence a) [(Order a) (Choice a)] [(Order a) (Choice a)] Test)) ($_ _.and (<| (_.context "Minimum.") - (choice rand-gen = min')) + (choice rand_gen = min')) (<| (_.context "Maximum.") - (choice rand-gen = max')))) + (choice rand_gen = max')))) -(def: (conversion rand-gen forward backward =) +(def: (conversion rand_gen forward backward =) (All [a b] (-> (Random a) (-> a b) (-> b a) (Equivalence a) Test)) (do random.monad - [value rand-gen] + [value rand_gen] (_.test "Can convert between types in a lossless way." (|> value forward backward (= value))))) -(def: frac-rev +(def: frac_rev (Random Rev) - (let [bits-to-ignore 11] - (\ random.functor map (i64.left-shift bits-to-ignore) random.rev))) + (let [bits_to_ignore 11] + (\ random.functor map (i64.left_shift bits_to_ignore) random.rev))) -(def: prelude-macros +(def: prelude_macros Test ($_ _.and (do random.monad @@ -193,27 +193,27 @@ (n.= (n.+ (n.* cat0 cat0) (n.* cat1 cat1)) (quadrance cat0 cat1))))) -(def: cross-platform-support +(def: cross_platform_support Test (do random.monad - [on-default random.nat - on-fake-host random.nat - on-valid-host random.nat] + [on_default random.nat + on_fake_host random.nat + on_valid_host random.nat] ($_ _.and (_.test "Can provide default in case there is no particular host/platform support." - (n.= on-default - (for {"" on-fake-host} - on-default))) + (n.= on_default + (for {"" on_fake_host} + on_default))) (_.test "Can pick code depending on the host/platform being targeted." - (n.= on-valid-host - (for {@.old on-valid-host - @.jvm on-valid-host - @.js on-valid-host} - on-default)))))) + (n.= on_valid_host + (for {@.old on_valid_host + @.jvm on_valid_host + @.js on_valid_host} + on_default)))))) -(def: sub-tests +(def: sub_tests Test - (_.in-parallel (list& /abstract.test + (_.in_parallel (list& /abstract.test /control.test /data.test /locale.test @@ -231,50 +231,50 @@ ))) (def: test - (<| (_.context (name.module (name-of /._))) - (_.in-parallel + (<| (_.context (name.module (name_of /._))) + (_.in_parallel (list (!bundle ($_ _.and (<| (_.context "Identity.") ..identity) (<| (_.context "Increment & decrement.") - ..increment-and-decrement) + ..increment_and_decrement) (<| (_.context "Even or odd.") ($_ _.and (<| (_.context "Natural numbers.") - (..even-or-odd random.nat n.even? n.odd?)) + (..even_or_odd random.nat n.even? n.odd?)) (<| (_.context "Integers.") - (..even-or-odd random.int i.even? i.odd?)))) + (..even_or_odd random.int i.even? i.odd?)))) (<| (_.context "Minimum and maximum.") (`` ($_ _.and (~~ (template [<=> <lt> <min> <gt> <max> <gen> <context>] [(<| (_.context <context>) - (..minimum-and-maximum <gen> <=> [<lt> <min>] [<gt> <max>]))] + (..minimum_and_maximum <gen> <=> [<lt> <min>] [<gt> <max>]))] [i.= i.< i.min i.> i.max random.int "Integers."] [n.= n.< n.min n.> n.max random.nat "Natural numbers."] [r.= r.< r.min r.> r.max random.rev "Revolutions."] - [f.= f.< f.min f.> f.max random.safe-frac "Fractions."] + [f.= f.< f.min f.> f.max random.safe_frac "Fractions."] ))))) (<| (_.context "Conversion.") (`` ($_ _.and (~~ (template [<=> <forward> <backward> <gen>] - [(<| (_.context (format (%.name (name-of <forward>)) - " " (%.name (name-of <backward>)))) + [(<| (_.context (format (%.name (name_of <forward>)) + " " (%.name (name_of <backward>)))) (..conversion <gen> <forward> <backward> <=>))] [i.= .nat .int (random\map (i.% +1,000,000) random.int)] [n.= .int .nat (random\map (n.% 1,000,000) random.nat)] [i.= i.frac f.int (random\map (i.% +1,000,000) random.int)] [f.= f.int i.frac (random\map (|>> (i.% +1,000,000) i.frac) random.int)] - [r.= r.frac f.rev frac-rev] + [r.= r.frac f.rev frac_rev] ))))) (<| (_.context "Prelude macros.") - ..prelude-macros) + ..prelude_macros) (<| (_.context "Templates.") ..templates) (<| (_.context "Cross-platform support.") - ..cross-platform-support))) - ..sub-tests + ..cross_platform_support))) + ..sub_tests )))) (program: args diff --git a/stdlib/source/test/lux/abstract/codec.lux b/stdlib/source/test/lux/abstract/codec.lux index 8c68f4cc6..1bbbcf460 100644 --- a/stdlib/source/test/lux/abstract/codec.lux +++ b/stdlib/source/test/lux/abstract/codec.lux @@ -26,7 +26,7 @@ list json.object)) (def: decode - (json.get-boolean field))))) + (json.get_boolean field))))) (def: codec (Codec Text Bit) diff --git a/stdlib/source/test/lux/abstract/functor/contravariant.lux b/stdlib/source/test/lux/abstract/functor/contravariant.lux index 93d1f18ad..e6791756f 100644 --- a/stdlib/source/test/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/test/lux/abstract/functor/contravariant.lux @@ -7,4 +7,4 @@ (def: #export test Test (<| (_.covering /._) - (_.in-parallel (list)))) + (_.in_parallel (list)))) diff --git a/stdlib/source/test/lux/abstract/interval.lux b/stdlib/source/test/lux/abstract/interval.lux index a4e06fa3a..66d607ab8 100644 --- a/stdlib/source/test/lux/abstract/interval.lux +++ b/stdlib/source/test/lux/abstract/interval.lux @@ -73,10 +73,10 @@ (_.cover [/.between /.within?] (and (/.within? interval bottom) (/.within? interval top))) - (_.cover [/.starts-with?] - (/.starts-with? bottom interval)) - (_.cover [/.ends-with?] - (/.ends-with? top interval)) + (_.cover [/.starts_with?] + (/.starts_with? bottom interval)) + (_.cover [/.ends_with?] + (/.ends_with? top interval)) (_.cover [/.borders?] (and (/.borders? interval bottom) (/.borders? interval top))) @@ -85,61 +85,61 @@ (def: union Test (do random.monad - [some-interval ..interval - left-inner ..inner - right-inner ..inner - left-singleton ..singleton - right-singleton ..singleton - left-outer ..outer - right-outer ..outer] + [some_interval ..interval + left_inner ..inner + right_inner ..inner + left_singleton ..singleton + right_singleton ..singleton + left_outer ..outer + right_outer ..outer] ($_ _.and (_.test "The union of an interval to itself yields the same interval." - (\= some-interval (/.union some-interval some-interval))) + (\= some_interval (/.union some_interval some_interval))) (_.test "The union of 2 inner intervals is another inner interval." - (/.inner? (/.union left-inner right-inner))) + (/.inner? (/.union left_inner right_inner))) (_.test "The union of 2 outer intervals yields an inner interval when their complements don't overlap, and an outer when they do." - (if (/.overlaps? (/.complement left-outer) (/.complement right-outer)) - (/.outer? (/.union left-outer right-outer)) - (/.inner? (/.union left-outer right-outer)))) + (if (/.overlaps? (/.complement left_outer) (/.complement right_outer)) + (/.outer? (/.union left_outer right_outer)) + (/.inner? (/.union left_outer right_outer)))) ))) (def: intersection Test (do random.monad - [some-interval ..interval - left-inner ..inner - right-inner ..inner - left-singleton ..singleton - right-singleton ..singleton - left-outer ..outer - right-outer ..outer] + [some_interval ..interval + left_inner ..inner + right_inner ..inner + left_singleton ..singleton + right_singleton ..singleton + left_outer ..outer + right_outer ..outer] ($_ _.and (_.test "The intersection of an interval to itself yields the same interval." - (\= some-interval (/.intersection some-interval some-interval))) + (\= some_interval (/.intersection some_interval some_interval))) (_.test "The intersection of 2 inner intervals yields an inner interval when they overlap, and an outer when they don't." - (if (/.overlaps? left-inner right-inner) - (/.inner? (/.intersection left-inner right-inner)) - (/.outer? (/.intersection left-inner right-inner)))) + (if (/.overlaps? left_inner right_inner) + (/.inner? (/.intersection left_inner right_inner)) + (/.outer? (/.intersection left_inner right_inner)))) (_.test "The intersection of 2 outer intervals is another outer interval." - (/.outer? (/.intersection left-outer right-outer))) + (/.outer? (/.intersection left_outer right_outer))) ))) (def: complement Test (do random.monad - [some-interval ..interval] + [some_interval ..interval] ($_ _.and (_.test "The complement of a complement is the same as the original." - (\= some-interval (|> some-interval /.complement /.complement))) + (\= some_interval (|> some_interval /.complement /.complement))) (_.test "The complement of an interval does not overlap it." - (not (/.overlaps? some-interval (/.complement some-interval)))) + (not (/.overlaps? some_interval (/.complement some_interval)))) ))) (def: location Test (do {! random.monad} [[l m r] (|> (random.set n.hash 3 random.nat) - (\ ! map (|>> set.to-list + (\ ! map (|>> set.to_list (list.sort n.<) (case> (^ (list b t1 t2)) [b t1 t2] @@ -161,20 +161,20 @@ Test (do {! random.monad} [[b t1 t2] (|> (random.set n.hash 3 random.nat) - (\ ! map (|>> set.to-list + (\ ! map (|>> set.to_list (list.sort n.<) (case> (^ (list b t1 t2)) [b t1 t2] _ (undefined))))) - #let [int-left (/.between n.enum t1 t2) - int-right (/.between n.enum b t1)]] + #let [int_left (/.between n.enum t1 t2) + int_right (/.between n.enum b t1)]] ($_ _.and (_.cover [/.meets?] - (/.meets? int-left int-right)) + (/.meets? int_left int_right)) (_.cover [/.touches?] - (/.touches? int-left int-right)) + (/.touches? int_left int_right)) (_.cover [/.starts?] (/.starts? (/.between n.enum b t2) (/.between n.enum b t1))) @@ -186,9 +186,9 @@ (def: nested Test (do {! random.monad} - [some-interval ..interval + [some_interval ..interval [x0 x1 x2 x3] (|> (random.set n.hash 4 random.nat) - (\ ! map (|>> set.to-list + (\ ! map (|>> set.to_list (list.sort n.<) (case> (^ (list x0 x1 x2 x3)) [x0 x1 x2 x3] @@ -197,31 +197,31 @@ (undefined)))))] ($_ _.and (_.test "Every interval is nested into itself." - (/.nested? some-interval some-interval)) - (let [small-inner (/.between n.enum x1 x2) - large-inner (/.between n.enum x0 x3)] + (/.nested? some_interval some_interval)) + (let [small_inner (/.between n.enum x1 x2) + large_inner (/.between n.enum x0 x3)] (_.test "Inner intervals can be nested inside one another." - (and (/.nested? large-inner small-inner) - (not (/.nested? small-inner large-inner))))) - (let [small-outer (/.between n.enum x2 x1) - large-outer (/.between n.enum x3 x0)] + (and (/.nested? large_inner small_inner) + (not (/.nested? small_inner large_inner))))) + (let [small_outer (/.between n.enum x2 x1) + large_outer (/.between n.enum x3 x0)] (_.test "Outer intervals can be nested inside one another." - (and (/.nested? small-outer large-outer) - (not (/.nested? large-outer small-outer))))) - (let [left-inner (/.between n.enum x0 x1) - right-inner (/.between n.enum x2 x3) + (and (/.nested? small_outer large_outer) + (not (/.nested? large_outer small_outer))))) + (let [left_inner (/.between n.enum x0 x1) + right_inner (/.between n.enum x2 x3) outer (/.between n.enum x0 x3)] (_.test "Inners can be nested inside outers." - (and (/.nested? outer left-inner) - (/.nested? outer right-inner)))) + (and (/.nested? outer left_inner) + (/.nested? outer right_inner)))) ))) (def: overlap Test (do {! random.monad} - [some-interval ..interval + [some_interval ..interval [x0 x1 x2 x3] (|> (random.set n.hash 4 random.nat) - (\ ! map (|>> set.to-list + (\ ! map (|>> set.to_list (list.sort n.<) (case> (^ (list x0 x1 x2 x3)) [x0 x1 x2 x3] @@ -230,18 +230,18 @@ (undefined)))))] ($_ _.and (_.test "No interval overlaps with itself." - (not (/.overlaps? some-interval some-interval))) - (let [left-inner (/.between n.enum x0 x2) - right-inner (/.between n.enum x1 x3)] + (not (/.overlaps? some_interval some_interval))) + (let [left_inner (/.between n.enum x0 x2) + right_inner (/.between n.enum x1 x3)] (_.test "Inner intervals can overlap one another." - (and (/.overlaps? left-inner right-inner) - (/.overlaps? right-inner left-inner)))) - (let [left-inner (/.between n.enum x0 x2) - right-inner (/.between n.enum x1 x3) + (and (/.overlaps? left_inner right_inner) + (/.overlaps? right_inner left_inner)))) + (let [left_inner (/.between n.enum x0 x2) + right_inner (/.between n.enum x1 x3) outer (/.between n.enum x1 x2)] (_.test "Inners can overlap outers." - (and (/.overlaps? outer left-inner) - (/.overlaps? outer right-inner)))) + (and (/.overlaps? outer left_inner) + (/.overlaps? outer right_inner)))) ))) (def: #export test diff --git a/stdlib/source/test/lux/control/concatenative.lux b/stdlib/source/test/lux/control/concatenative.lux index 8d6ed4e87..b01981730 100644 --- a/stdlib/source/test/lux/control/concatenative.lux +++ b/stdlib/source/test/lux/control/concatenative.lux @@ -21,7 +21,7 @@ {1 ["." / (#+ word: => ||>)]}) -(def: stack-shuffling +(def: stack_shuffling Test (do random.monad [sample random.nat @@ -95,7 +95,7 @@ (template: (!numerical <=> <generator> <filter> <arithmetic> <order>) (: Test - (with-expansions [<arithmetic>' (template.splice <arithmetic>) + (with_expansions [<arithmetic>' (template.splice <arithmetic>) <order>' (template.splice <order>)] (do random.monad [parameter (|> <generator> (random.filter <filter>)) @@ -131,12 +131,12 @@ (!numerical r.= random.rev (|>> (r.= .0) not) [[/.r/+ r.+] [/.r/- r.-] [/.r/* r.*] [/.r// r./] [/.r/% r.%]] [[/.r/= r.=] [/.r/< r.<] [/.r/<= r.<=] [/.r/> r.>] [/.r/>= r.>=]]) - (!numerical f.= random.safe-frac (|>> (f.= +0.0) not) + (!numerical f.= random.safe_frac (|>> (f.= +0.0) not) [[/.f/+ f.+] [/.f/- f.-] [/.f/* f.*] [/.f// f./] [/.f/% f.%]] [[/.f/= f.=] [/.f/< f.<] [/.f/<= f.<=] [/.f/> f.>] [/.f/>= f.>=]]) )) -(def: control-flow +(def: control_flow Test (do random.monad [choice random.bit @@ -311,8 +311,8 @@ Test (<| (_.covering /._) ($_ _.and - ..stack-shuffling + ..stack_shuffling ..numerical - ..control-flow + ..control_flow ..definition ))) diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index 0b750b9cc..7a94c72aa 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -24,15 +24,15 @@ ["." promise (#+ Promise Resolver) ("#\." monad)] ["." frp]]]}) -(exception: got-wrecked) +(exception: got_wrecked) (actor: counter Nat - ((on-mail message state self) + ((on_mail message state self) (message state self)) - ((on-stop cause state) + ((on_stop cause state) (promise\wrap [])) (message: (count! {increment Nat} state self Nat) @@ -49,13 +49,13 @@ (def: #export test Test (do {! random.monad} - [initial-state random.nat - #let [as-mail (: (All [a] (-> (-> a a) (/.Mail a))) + [initial_state random.nat + #let [as_mail (: (All [a] (-> (-> a a) (/.Mail a))) (function (_ transform) (function (_ state actor) (|> state transform #try.Success promise\wrap)))) - inc! (: (/.Mail Nat) (as-mail inc)) - dec! (: (/.Mail Nat) (as-mail dec))]] + inc! (: (/.Mail Nat) (as_mail inc)) + dec! (: (/.Mail Nat) (as_mail dec))]] (<| (_.covering /._) (_.for [/.Actor]) ($_ _.and @@ -65,7 +65,7 @@ (/.alive? actor)))) (_.cover [/.poison!] - (let [poisoned-actors-die! + (let [poisoned_actors_die! (io.run (do io.monad [actor (/.spawn! /.default 0) poisoned? (/.poison! actor) @@ -73,25 +73,25 @@ (wrap (and (..mailed? poisoned?) (not alive?))))) - cannot-poison-more-than-once! + cannot_poison_more_than_once! (io.run (do io.monad [actor (/.spawn! /.default 0) - first-time? (/.poison! actor) - second-time? (/.poison! actor)] - (wrap (and (..mailed? first-time?) - (not (..mailed? second-time?))))))] - (and poisoned-actors-die! - cannot-poison-more-than-once!))) + first_time? (/.poison! actor) + second_time? (/.poison! actor)] + (wrap (and (..mailed? first_time?) + (not (..mailed? second_time?))))))] + (and poisoned_actors_die! + cannot_poison_more_than_once!))) (let [[read write] (: [(Promise Text) (Resolver Text)] (promise.promise []))] (wrap (do promise.monad [_ (promise.future (do io.monad [actor (/.spawn! (: (/.Behavior Any Any) - {#/.on-init (|>>) - #/.on-mail (function (_ message state self) + {#/.on_init (|>>) + #/.on_mail (function (_ message state self) (message state self)) - #/.on-stop (function (_ cause state) + #/.on_stop (function (_ cause state) (promise.future (write cause)))}) [])] (/.poison! actor))) @@ -129,22 +129,22 @@ (let [die! (: (/.Mail Nat) (function (_ state actor) - (promise\wrap (exception.throw ..got-wrecked []))))] + (promise\wrap (exception.throw ..got_wrecked []))))] (wrap (do promise.monad [result (promise.future (do io.monad - [actor (/.spawn! /.default initial-state) + [actor (/.spawn! /.default initial_state) sent? (/.mail! die! actor) alive? (/.alive? actor) obituary (/.obituary actor)] (wrap (#try.Success [actor sent? alive? obituary]))))] (_.cover' [/.Obituary /.obituary] (case result - (^ (#try.Success [actor sent? alive? (#.Some [error state (list single-pending-message)])])) + (^ (#try.Success [actor sent? alive? (#.Some [error state (list single_pending_message)])])) (and (..mailed? sent?) (not alive?) - (exception.match? ..got-wrecked error) - (n.= initial-state state) - (is? die! single-pending-message)) + (exception.match? ..got_wrecked error) + (n.= initial_state state) + (is? die! single_pending_message)) _ false))))) @@ -152,12 +152,12 @@ (wrap (do promise.monad [counter (promise.future (/.spawn! ..counter 0)) result (do (try.with promise.monad) - [output-1 (/.tell! (count! 1) counter) - output-2 (/.tell! (count! 1) counter) - output-3 (/.tell! (count! 1) counter)] - (wrap (and (n.= 1 output-1) - (n.= 2 output-2) - (n.= 3 output-3))))] + [output_1 (/.tell! (count! 1) counter) + output_2 (/.tell! (count! 1) counter) + output_3 (/.tell! (count! 1) counter)] + (wrap (and (n.= 1 output_1) + (n.= 2 output_2) + (n.= 3 output_3))))] (_.cover' [/.Message /.actor: /.message: /.tell!] (case result (#try.Success outcome) @@ -170,11 +170,11 @@ [verdict (promise.future (do io.monad [anonymous (/.actor {Nat - initial-state} - ((on-mail message state self) + initial_state} + ((on_mail message state self) (message (inc state) self)) - ((on-stop cause state) + ((on_stop cause state) (promise\wrap (exec (%.nat state) [])))) sent/inc? (/.mail! inc! anonymous) @@ -185,10 +185,10 @@ (..mailed? sent/dec?) (..mailed? poisoned?) (case obituary - (^ (#.Some [error final-state (list poison-pill)])) + (^ (#.Some [error final_state (list poison_pill)])) (and (exception.match? /.poisoned error) - (n.= (inc (inc initial-state)) - final-state)) + (n.= (inc (inc initial_state)) + final_state)) _ false)))))] @@ -196,10 +196,10 @@ verdict))) (do ! - [num-events (\ ! map (|>> (n.% 10) inc) random.nat) - events (random.list num-events random.nat) - num-observations (\ ! map (n.% num-events) random.nat) - #let [expected (list.take num-observations events) + [num_events (\ ! map (|>> (n.% 10) inc) random.nat) + events (random.list num_events random.nat) + num_observations (\ ! map (n.% num_events) random.nat) + #let [expected (list.take num_observations events) sink (: (Atom (Row Nat)) (atom.atom row.empty))]] (wrap (do promise.monad @@ -207,12 +207,12 @@ (do {! io.monad} [agent (/.actor {Nat 0}) _ (/.observe (function (_ event stop) - (function (_ events-seen self) + (function (_ events_seen self) (promise.future - (if (n.< num-observations events-seen) + (if (n.< num_observations events_seen) (do ! [_ (atom.update (row.add event) sink)] - (wrap (#try.Success (inc events-seen)))) + (wrap (#try.Success (inc events_seen)))) (do ! [_ stop] (wrap (#try.Failure "YOLO"))))))) @@ -222,5 +222,5 @@ _ (/.await agent) actual (promise.future (atom.read sink))] (_.cover' [/.Stop /.observe /.await] - (\ (list.equivalence n.equivalence) = expected (row.to-list actual)))))) + (\ (list.equivalence n.equivalence) = expected (row.to_list actual)))))) )))) diff --git a/stdlib/source/test/lux/control/concurrency/atom.lux b/stdlib/source/test/lux/control/concurrency/atom.lux index 8902f0a8f..bdc56521a 100644 --- a/stdlib/source/test/lux/control/concurrency/atom.lux +++ b/stdlib/source/test/lux/control/concurrency/atom.lux @@ -18,23 +18,23 @@ (<| (_.covering /._) (do random.monad [value random.nat - swap-value random.nat - set-value random.nat + swap_value random.nat + set_value random.nat #let [box (/.atom value)]] ($_ _.and (_.cover [/.Atom /.atom /.read] (n.= value (io.run (/.read box)))) - (_.cover [/.compare-and-swap] - (and (io.run (/.compare-and-swap value swap-value box)) - (n.= swap-value + (_.cover [/.compare_and_swap] + (and (io.run (/.compare_and_swap value swap_value box)) + (n.= swap_value (io.run (/.read box))))) (_.cover [/.update] (exec (io.run (/.update inc box)) - (n.= (inc swap-value) + (n.= (inc swap_value) (io.run (/.read box))))) (_.cover [/.write] - (exec (io.run (/.write set-value box)) - (n.= set-value + (exec (io.run (/.write set_value box)) + (n.= set_value (io.run (/.read box))))) )))) diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux index 03cc9613d..2652be103 100644 --- a/stdlib/source/test/lux/control/concurrency/frp.lux +++ b/stdlib/source/test/lux/control/concurrency/frp.lux @@ -32,7 +32,7 @@ (def: injection (Injection /.Channel) (|>> promise.resolved - /.from-promise)) + /.from_promise)) (def: comparison (Comparison /.Channel) @@ -90,7 +90,7 @@ (#try.Failure error) false)) - (_.cover [/.channel-is-already-closed] + (_.cover [/.channel_is_already_closed] (case (io.run (do (try.with io.monad) [#let [[channel sink] (/.channel [])] @@ -100,13 +100,13 @@ false (#try.Failure error) - (exception.match? /.channel-is-already-closed error))) + (exception.match? /.channel_is_already_closed error))) (wrap (do promise.monad [output (|> sample promise.resolved - /.from-promise + /.from_promise /.consume)] - (_.cover' [/.from-promise /.consume] + (_.cover' [/.from_promise /.consume] (list\= (list sample) output)))) (wrap (do promise.monad @@ -141,7 +141,7 @@ listened (|> sink atom.read promise.future - (\ ! map row.to-list))] + (\ ! map row.to_list))] (_.cover' [/.Subscriber /.subscribe] (list\= inputs listened)))) (wrap (do promise.monad @@ -172,48 +172,48 @@ (_.cover' [/.distinct] (list\= (list distint/0 distint/1 distint/2) actual)))) - (let [polling-delay 1 - amount-of-polls 5 - wiggle-room ($_ n.* - (i64.left-shift 6 1) - amount-of-polls - polling-delay) - total-delay (|> polling-delay - (n.* amount-of-polls) - (n.+ wiggle-room))] + (let [polling_delay 1 + amount_of_polls 5 + wiggle_room ($_ n.* + (i64.left_shift 6 1) + amount_of_polls + polling_delay) + total_delay (|> polling_delay + (n.* amount_of_polls) + (n.+ wiggle_room))] ($_ _.and (wrap (do promise.monad - [#let [[channel sink] (/.poll polling-delay (: (IO Nat) (io.io sample)))] - _ (promise.delay total-delay []) + [#let [[channel sink] (/.poll polling_delay (: (IO Nat) (io.io sample)))] + _ (promise.delay total_delay []) _ (promise.future (\ sink close)) actual (/.consume channel) - #let [correct-values! + #let [correct_values! (list.every? (n.= sample) actual) - enough-polls! - (n.>= amount-of-polls (list.size actual))]] + enough_polls! + (n.>= amount_of_polls (list.size actual))]] (_.cover' [/.poll] - (and correct-values! - enough-polls!)))) + (and correct_values! + enough_polls!)))) (wrap (do promise.monad - [#let [[channel sink] (/.periodic polling-delay)] - _ (promise.delay total-delay []) + [#let [[channel sink] (/.periodic polling_delay)] + _ (promise.delay total_delay []) _ (promise.future (\ sink close)) actual (/.consume channel)] (_.cover' [/.periodic] - (n.>= amount-of-polls (list.size actual))))))) + (n.>= amount_of_polls (list.size actual))))))) (wrap (do promise.monad - [#let [max-iterations 10] + [#let [max_iterations 10] actual (|> [0 sample] (/.iterate (function (_ [iterations current]) (promise.resolved - (if (n.< max-iterations iterations) + (if (n.< max_iterations iterations) (#.Some [[(inc iterations) (n.+ shift current)] current]) #.None)))) /.consume)] (_.cover' [/.iterate] - (and (n.= max-iterations (list.size actual)) - (list\= (list.folds n.+ sample (list.repeat (dec max-iterations) shift)) + (and (n.= max_iterations (list.size actual)) + (list\= (list.folds n.+ sample (list.repeat (dec max_iterations) shift)) actual))))) ))))) diff --git a/stdlib/source/test/lux/control/concurrency/promise.lux b/stdlib/source/test/lux/control/concurrency/promise.lux index 51908a257..21633f293 100644 --- a/stdlib/source/test/lux/control/concurrency/promise.lux +++ b/stdlib/source/test/lux/control/concurrency/promise.lux @@ -48,12 +48,12 @@ Test (<| (_.covering /._) (do {! random.monad} - [to-wait (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) + [to_wait (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) expected random.nat dummy random.nat - #let [not-dummy (|> random.nat (random.filter (|>> (n.= dummy) not)))] - leftE not-dummy - rightE not-dummy] + #let [not_dummy (|> random.nat (random.filter (|>> (n.= dummy) not)))] + leftE not_dummy + rightE not_dummy] ($_ _.and (_.for [/.functor] ($functor.spec ..injection ..comparison /.functor)) @@ -80,19 +80,19 @@ (n.= expected actual)))) (wrap (do /.monad [pre (/.future instant.now) - actual (/.schedule to-wait (io.io expected)) + actual (/.schedule to_wait (io.io expected)) post (/.future instant.now)] (_.cover' [/.schedule] (and (n.= expected actual) - (i.>= (.int to-wait) - (duration.to-millis (instant.span pre post))))))) + (i.>= (.int to_wait) + (duration.to_millis (instant.span pre post))))))) (wrap (do /.monad [pre (/.future instant.now) - _ (/.wait to-wait) + _ (/.wait to_wait) post (/.future instant.now)] (_.cover' [/.wait] - (i.>= (.int to-wait) - (duration.to-millis (instant.span pre post)))))) + (i.>= (.int to_wait) + (duration.to_millis (instant.span pre post)))))) (wrap (do /.monad [[leftA rightA] (/.and (/.future (io.io leftE)) (/.future (io.io rightE)))] @@ -101,16 +101,16 @@ (n.+ leftA rightA))))) (wrap (do /.monad [pre (/.future instant.now) - actual (/.delay to-wait expected) + actual (/.delay to_wait expected) post (/.future instant.now)] (_.cover' [/.delay] (and (n.= expected actual) - (i.>= (.int to-wait) - (duration.to-millis (instant.span pre post))))))) + (i.>= (.int to_wait) + (duration.to_millis (instant.span pre post))))))) (wrap (do /.monad [?left (/.or (wrap leftE) - (/.delay to-wait dummy)) - ?right (/.or (/.delay to-wait dummy) + (/.delay to_wait dummy)) + ?right (/.or (/.delay to_wait dummy) (wrap rightE))] (_.cover' [/.or] (case [?left ?right] @@ -122,8 +122,8 @@ false)))) (wrap (do /.monad [leftA (/.either (wrap leftE) - (/.delay to-wait dummy)) - rightA (/.either (/.delay to-wait dummy) + (/.delay to_wait dummy)) + rightA (/.either (/.delay to_wait dummy) (wrap rightE))] (_.cover' [/.either] (n.= (n.+ leftE rightE) @@ -149,9 +149,9 @@ (and yep (not nope))))) (wrap (do /.monad - [?none (/.time-out 0 (/.delay to-wait dummy)) - ?actual (/.time-out to-wait (wrap expected))] - (_.cover' [/.time-out] + [?none (/.time_out 0 (/.delay to_wait dummy)) + ?actual (/.time_out to_wait (wrap expected))] + (_.cover' [/.time_out] (case [?none ?actual] [#.None (#.Some actual)] (n.= expected actual) diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index 7e632b8cb..e30a930ac 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -31,10 +31,10 @@ (_.for [/.Semaphore] ($_ _.and (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] + [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial_open_positions)]] (wrap (do promise.monad - [result (promise.time-out 10 (/.wait semaphore))] + [result (promise.time_out 10 (/.wait semaphore))] (_.cover' [/.semaphore] (case result (#.Some _) @@ -43,11 +43,11 @@ #.None false))))) (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] + [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial_open_positions)]] (wrap (do {! promise.monad} - [_ (monad.map ! /.wait (list.repeat initial-open-positions semaphore)) - result (promise.time-out 10 (/.wait semaphore))] + [_ (monad.map ! /.wait (list.repeat initial_open_positions semaphore)) + result (promise.time_out 10 (/.wait semaphore))] (_.cover' [/.wait] (case result (#.Some _) @@ -56,30 +56,30 @@ #.None true))))) (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] + [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial_open_positions)]] (wrap (do {! promise.monad} - [_ (monad.map ! /.wait (list.repeat initial-open-positions semaphore)) + [_ (monad.map ! /.wait (list.repeat initial_open_positions semaphore)) #let [block (/.wait semaphore)] - result/0 (promise.time-out 10 block) - open-positions (/.signal semaphore) - result/1 (promise.time-out 10 block)] + result/0 (promise.time_out 10 block) + open_positions (/.signal semaphore) + result/1 (promise.time_out 10 block)] (_.cover' [/.signal] - (case [result/0 result/1 open-positions] + (case [result/0 result/1 open_positions] [#.None (#.Some _) (#try.Success +0)] true _ false))))) (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] + [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial_open_positions)]] (wrap (do promise.monad [outcome (/.signal semaphore)] - (_.cover' [/.semaphore-is-maxed-out] + (_.cover' [/.semaphore_is_maxed_out] (case outcome (#try.Failure error) - (exception.match? /.semaphore-is-maxed-out error) + (exception.match? /.semaphore_is_maxed_out error) _ false))))) @@ -92,8 +92,8 @@ (do {! random.monad} [repetitions (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) #let [resource (atom.atom "") - expected-As (text.join-with "" (list.repeat repetitions "A")) - expected-Bs (text.join-with "" (list.repeat repetitions "B")) + expected_As (text.join_with "" (list.repeat repetitions "A")) + expected_Bs (text.join_with "" (list.repeat repetitions "B")) mutex (/.mutex []) processA (<| (/.synchronize mutex) io.io @@ -116,9 +116,9 @@ _ processB #let [outcome (io.run (atom.read resource))]] (_.cover' [/.mutex /.synchronize] - (or (text\= (format expected-As expected-Bs) + (or (text\= (format expected_As expected_Bs) outcome) - (text\= (format expected-Bs expected-As) + (text\= (format expected_Bs expected_As) outcome)))))) ))) @@ -142,7 +142,7 @@ [_ (#.Some limit)] (and (n.> 0 raw) - (n.= raw (refinement.un-refine limit))) + (n.= raw (refinement.un_refine limit))) _ false))) @@ -153,7 +153,7 @@ (wrap (do {! promise.monad} [#let [ending (|> "_" (list.repeat limit) - (text.join-with "")) + (text.join_with "")) ids (enum.range n.enum 0 (dec limit)) waiters (list\map (function (_ id) (exec (io.run (atom.update (|>> (format "_")) resource)) @@ -162,7 +162,7 @@ _ (monad.seq ! waiters) #let [outcome (io.run (atom.read resource))]] (_.cover' [/.barrier /.block] - (and (text.ends-with? ending outcome) + (and (text.ends_with? ending outcome) (list.every? (function (_ id) (text.contains? (%.nat id) outcome)) ids) diff --git a/stdlib/source/test/lux/control/concurrency/thread.lux b/stdlib/source/test/lux/control/concurrency/thread.lux index f8abf6a84..04da97f17 100644 --- a/stdlib/source/test/lux/control/concurrency/thread.lux +++ b/stdlib/source/test/lux/control/concurrency/thread.lux @@ -32,21 +32,21 @@ (_.cover [/.parallelism] (n.> 0 /.parallelism)) (wrap (do promise.monad - [reference-time (promise.future instant.now) - #let [box (atom.atom [reference-time dummy])] + [reference_time (promise.future instant.now) + #let [box (atom.atom [reference_time dummy])] _ (promise.future (/.schedule delay (do io.monad - [execution-time instant.now] - (atom.write [execution-time expected] box)))) + [execution_time instant.now] + (atom.write [execution_time expected] box)))) _ (promise.wait (n.* 2 delay)) - [execution-time actual] (promise.future (atom.read box))] + [execution_time actual] (promise.future (atom.read box))] (_.cover' [/.schedule] - (let [expected-delay! + (let [expected_delay! (i.>= (.int delay) - (duration.to-millis (instant.span reference-time execution-time))) + (duration.to_millis (instant.span reference_time execution_time))) - correct-value! + correct_value! (n.= expected actual)] - (and expected-delay! - correct-value!))))) + (and expected_delay! + correct_value!))))) )))) diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux index 66a0e13ef..8fad40d86 100644 --- a/stdlib/source/test/lux/control/function/memo.lux +++ b/stdlib/source/test/lux/control/function/memo.lux @@ -32,9 +32,9 @@ 0 (state\wrap 0) 1 (state\wrap 1) _ (do state.monad - [output-1 (recur (n.- 1 input)) - output-2 (recur (n.- 2 input))] - (wrap (n.+ output-1 output-2))))) + [output_1 (recur (n.- 1 input)) + output_2 (recur (n.- 2 input))] + (wrap (n.+ output_1 output_2))))) (def: (time function input) (All [i o] (-> (-> i o) i (IO [Duration o]))) @@ -45,15 +45,15 @@ (wrap [(instant.span before after) output]))) -(def: milli-seconds +(def: milli_seconds (-> Duration Nat) - (|>> (duration.query duration.milli-second) .nat)) + (|>> (duration.query duration.milli_second) .nat)) ## the wiggle room is there to account for GC pauses ## and other issues that might mess with duration -(def: wiggle-room +(def: wiggle_room Nat - (i64.left-shift 4 1)) + (i64.left_shift 4 1)) (def: #export test Test @@ -67,40 +67,40 @@ (do io.monad [#let [slow (/.none n.hash ..fibonacci) fast (/.closed n.hash fibonacci)] - [slow-time slow-output] (..time slow input) - [fast-time fast-output] (..time fast input) - #let [same-output! - (n.= slow-output - fast-output) + [slow_time slow_output] (..time slow input) + [fast_time fast_output] (..time fast input) + #let [same_output! + (n.= slow_output + fast_output) - memo-is-faster! - (n.< (n.+ ..wiggle-room (milli-seconds slow-time)) - (milli-seconds fast-time))]] - (wrap (and same-output! - memo-is-faster!))))) + memo_is_faster! + (n.< (n.+ ..wiggle_room (milli_seconds slow_time)) + (milli_seconds fast_time))]] + (wrap (and same_output! + memo_is_faster!))))) (_.cover [/.open] (io.run (do io.monad [#let [none (/.none n.hash ..fibonacci) memory (dictionary.new n.hash) open (/.open fibonacci)] - [none-time none-output] (..time none input) - [open-time [memory open-output]] (..time open [memory input]) - [open-time/+1 _] (..time open [memory (inc input)]) - #let [same-output! - (n.= none-output - open-output) + [none_time none_output] (..time none input) + [open_time [memory open_output]] (..time open [memory input]) + [open_time/+1 _] (..time open [memory (inc input)]) + #let [same_output! + (n.= none_output + open_output) - memo-is-faster! - (n.< (n.+ ..wiggle-room (milli-seconds none-time)) - (milli-seconds open-time)) + memo_is_faster! + (n.< (n.+ ..wiggle_room (milli_seconds none_time)) + (milli_seconds open_time)) - incrementalism-is-faster! - (n.< (n.+ ..wiggle-room (milli-seconds open-time)) - (milli-seconds open-time/+1))]] - (wrap (and same-output! - memo-is-faster! - incrementalism-is-faster!))))) + incrementalism_is_faster! + (n.< (n.+ ..wiggle_room (milli_seconds open_time)) + (milli_seconds open_time/+1))]] + (wrap (and same_output! + memo_is_faster! + incrementalism_is_faster!))))) (_.cover [/.memoization] (let [memo (<| //.mixin (//.inherit /.memoization) diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index 26cf4ebd1..6c2f739bb 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -40,7 +40,7 @@ ["#." type] ["#." xml]]) -(def: (should-fail expected input) +(def: (should_fail expected input) (All [a] (-> Text (Try a) Bit)) (case input (#try.Failure actual) @@ -84,7 +84,7 @@ (~' _) #0))))) -(def: combinators-0 +(def: combinators_0 Test (do {! random.monad} [expected0 random.nat @@ -175,7 +175,7 @@ (match [] #1)))) ))) -(def: combinators-1 +(def: combinators_1 Test (do {! random.monad} [variadic (\ ! map (|>> (n.max 1) (n.min 20)) random.nat) @@ -195,25 +195,25 @@ (|> (list\map code.nat expected+) (/.run (/.exactly (inc variadic) s.nat)) fails?))) - (_.cover [/.at-least] + (_.cover [/.at_least] (and (|> (list\map code.nat expected+) - (/.run (/.at-least times s.nat)) + (/.run (/.at_least times s.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual))) (|> (list\map code.nat expected+) - (/.run (/.at-least (inc variadic) s.nat)) + (/.run (/.at_least (inc variadic) s.nat)) fails?))) - (_.cover [/.at-most] + (_.cover [/.at_most] (and (|> (list\map code.nat expected+) - (/.run (/.at-most times s.nat)) + (/.run (/.at_most times s.nat)) (match actual (\ (list.equivalence n.equivalence) = (list.take times expected+) actual))) (|> (list\map code.nat expected+) - (/.run (/.at-most (inc variadic) s.nat)) + (/.run (/.at_most (inc variadic) s.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ @@ -231,9 +231,9 @@ (\ (list.equivalence n.equivalence) = (list.take times expected+) actual))))) - (_.cover [/.sep-by] + (_.cover [/.sep_by] (|> (list.interpose (code.text separator) (list\map code.nat expected+)) - (/.run (/.sep-by (s.this! (code.text separator)) s.nat)) + (/.run (/.sep_by (s.this! (code.text separator)) s.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ @@ -255,7 +255,7 @@ )) ))) -(def: combinators-2 +(def: combinators_2 Test (do random.monad [expected random.nat @@ -269,16 +269,16 @@ (let [parser (/.rec (function (_ self) (/.either s.nat (s.tuple self)))) - level-0 (code.nat expected) - level-up (: (-> Code Code) + level_0 (code.nat expected) + level_up (: (-> Code Code) (|>> list code.tuple))] - (and (|> (list level-0) + (and (|> (list level_0) (/.run parser) (match actual (n.= expected actual))) - (|> (list (level-up level-0)) + (|> (list (level_up level_0)) (/.run parser) (match actual (n.= expected actual))) - (|> (list (level-up (level-up level-0))) + (|> (list (level_up (level_up level_0))) (/.run parser) (match actual (n.= expected actual)))))) (_.cover [/.after] @@ -310,19 +310,19 @@ (list (code.nat odd))) fails?))) (_.cover [/.speculative] - (let [happy-path! + (let [happy_path! (|> (/.run (/.and (/.speculative even^) nat^) (list (code.nat even))) (match [speculation actual] (and (n.= speculation actual) (n.= even actual)))) - sad-path! + sad_path! (|> (/.run (/.and (/.speculative even^) nat^) (list (code.nat odd))) fails?)] - (and happy-path! - sad-path!))) + (and happy_path! + sad_path!))) (_.cover [/.codec] (|> (/.run (/.codec n.decimal s.text) (list (code.text (%.nat expected)))) @@ -365,14 +365,14 @@ (_.cover [/.fail] (|> (list) (/.run (/.fail failure)) - (should-fail failure))) + (should_fail failure))) (_.cover [/.lift] (and (|> (list) (/.run (/.lift (#try.Success expected))) (match actual (n.= expected actual))) (|> (list) (/.run (/.lift (#try.Failure failure))) - (should-fail failure)))) + (should_fail failure)))) (_.cover [/.assert] (and (|> (list (code.bit #1) (code.int +123)) (/.run (/.assert assertion #1)) @@ -380,9 +380,9 @@ (|> (list (code.bit #1) (code.int +123)) (/.run (/.assert assertion #0)) fails?))) - ..combinators-0 - ..combinators-1 - ..combinators-2 + ..combinators_0 + ..combinators_1 + ..combinators_2 /analysis.test /binary.test diff --git a/stdlib/source/test/lux/control/parser/analysis.lux b/stdlib/source/test/lux/control/parser/analysis.lux index e089fb4d2..daf3632d6 100644 --- a/stdlib/source/test/lux/control/parser/analysis.lux +++ b/stdlib/source/test/lux/control/parser/analysis.lux @@ -81,7 +81,7 @@ [/.bit /.bit! random.bit analysis.bit bit\=] [/.nat /.nat! random.nat analysis.nat n.=] [/.int /.int! random.int analysis.int i.=] - [/.frac /.frac! random.safe-frac analysis.frac f.=] + [/.frac /.frac! random.safe_frac analysis.frac f.=] [/.rev /.rev! random.rev analysis.rev r.=] [/.text /.text! (random.unicode 10) analysis.text text\=] [/.local /.local! random.nat analysis.variable/local n.=] @@ -118,29 +118,29 @@ (!expect (#try.Failure _)))))) (do {! random.monad} [expected random.bit] - (_.cover [/.cannot-parse] + (_.cover [/.cannot_parse] (and (|> (list (analysis.bit expected)) (/.run /.nat) (case> (#try.Success _) false (#try.Failure error) - (exception.match? /.cannot-parse error))) + (exception.match? /.cannot_parse error))) (|> (list) (/.run /.bit) (case> (#try.Success _) false (#try.Failure error) - (exception.match? /.cannot-parse error)))))) + (exception.match? /.cannot_parse error)))))) (do {! random.monad} [expected random.bit] - (_.cover [/.unconsumed-input] + (_.cover [/.unconsumed_input] (|> (list (analysis.bit expected) (analysis.bit expected)) (/.run /.bit) (case> (#try.Success _) false (#try.Failure error) - (exception.match? /.unconsumed-input error))))) + (exception.match? /.unconsumed_input error))))) ))))) diff --git a/stdlib/source/test/lux/control/parser/binary.lux b/stdlib/source/test/lux/control/parser/binary.lux index 88c4aafaa..2a29ba367 100644 --- a/stdlib/source/test/lux/control/parser/binary.lux +++ b/stdlib/source/test/lux/control/parser/binary.lux @@ -47,9 +47,9 @@ _ false)) -(def: segment-size 10) +(def: segment_size 10) -(def: (utf8-conversion-does-not-alter? value) +(def: (utf8_conversion_does_not_alter? value) (Predicate Text) (|> value (\ encoding.utf8 encode) @@ -60,58 +60,58 @@ (#try.Failure error) false))) -(def: random-text +(def: random_text (Random Text) - (random.filter ..utf8-conversion-does-not-alter? - (random.unicode ..segment-size))) + (random.filter ..utf8_conversion_does_not_alter? + (random.unicode ..segment_size))) -(def: random-name +(def: random_name (Random Name) - (random.and ..random-text ..random-text)) + (random.and ..random_text ..random_text)) -(structure: location-equivalence +(structure: location_equivalence (Equivalence Location) - (def: (= [expected-module expected-line expected-column] - [sample-module sample-line sample-column]) - (and (text\= expected-module sample-module) - (n.= expected-line sample-line) - (n.= expected-column sample-column)))) + (def: (= [expected_module expected_line expected_column] + [sample_module sample_line sample_column]) + (and (text\= expected_module sample_module) + (n.= expected_line sample_line) + (n.= expected_column sample_column)))) -(def: random-location +(def: random_location (Random Location) ($_ random.and - ..random-text + ..random_text random.nat random.nat)) -(def: random-code +(def: random_code (Random Code) (random.rec (function (_ recur) - (let [random-sequence (do {! random.monad} + (let [random_sequence (do {! random.monad} [size (\ ! map (n.% 2) random.nat)] (random.list size recur))] ($_ random.and - ..random-location + ..random_location (: (Random (Code' (Ann Location))) ($_ random.or random.bit random.nat random.int random.rev - random.safe-frac - ..random-text - ..random-name - ..random-name - random-sequence - random-sequence + random.safe_frac + ..random_text + ..random_name + ..random_name + random_sequence + random_sequence (do {! random.monad} [size (\ ! map (n.% 2) random.nat)] (random.list size (random.and recur recur))) ))))))) -(def: random-type +(def: random_type (Random Type) (let [(^open ".") random.monad] ($_ random.either @@ -146,7 +146,7 @@ (`` ($_ _.and (~~ (template [<parser> <format>] [(do {! random.monad} - [expected (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] + [expected (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] (_.cover [<parser> <format>] (|> (format.run <format> expected) (/.run <parser>) @@ -164,7 +164,7 @@ (`` ($_ _.and (~~ (template [<parser> <format>] [(do {! random.monad} - [expected (random.ascii ..segment-size)] + [expected (random.ascii ..segment_size)] (_.cover [<parser> <format>] (|> (format.run <format> expected) (/.run <parser>) @@ -183,7 +183,7 @@ (`` ($_ _.and (~~ (template [<parser> <format>] [(do {! random.monad} - [expected (random.row ..segment-size random.nat)] + [expected (random.row ..segment_size random.nat)] (_.cover [<parser> <format>] (|> expected (format.run (<format> format.nat)) @@ -222,18 +222,18 @@ (/.run /.frac) (!expect (^multi (#try.Success actual) (or (\ frac.equivalence = expected actual) - (and (frac.not-a-number? expected) - (frac.not-a-number? actual)))))))) + (and (frac.not_a_number? expected) + (frac.not_a_number? actual)))))))) (do {! random.monad} [expected (\ ! map (|>> (i64.and (i64.mask /.size/8)) (n.max 2)) random.nat)] - (_.cover [/.not-a-bit] + (_.cover [/.not_a_bit] (|> expected (format.run format.bits/8) (/.run /.bit) (!expect (^multi (#try.Failure error) - (exception.match? /.not-a-bit error)))))) + (exception.match? /.not_a_bit error)))))) ))) (def: complex @@ -249,14 +249,14 @@ (!expect (^multi (#try.Success actual) (\ <equivalence> = expected actual))))))] - [/.location format.location random-location location-equivalence] - [/.code format.code random-code code.equivalence] - [/.type format.type random-type type.equivalence] + [/.location format.location random_location location_equivalence] + [/.code format.code random_code code.equivalence] + [/.type format.type random_type type.equivalence] )) - (~~ (template [<parser-coverage> <parser> <format-coverage> <format> <random> <equivalence>] + (~~ (template [<parser_coverage> <parser> <format_coverage> <format> <random> <equivalence>] [(do {! random.monad} [expected <random>] - (_.cover [<parser-coverage> <format-coverage>] + (_.cover [<parser_coverage> <format_coverage>] (|> expected (format.run <format>) (/.run <parser>) @@ -264,17 +264,17 @@ (\ <equivalence> = expected actual))))))] [/.maybe (/.maybe /.nat) format.maybe (format.maybe format.nat) (random.maybe random.nat) (maybe.equivalence n.equivalence)] - [/.list (/.list /.nat) format.list (format.list format.nat) (random.list ..segment-size random.nat) (list.equivalence n.equivalence)] - [/.set (/.set n.hash /.nat) format.set (format.set format.nat) (random.set n.hash ..segment-size random.nat) set.equivalence] - [/.name /.name format.name format.name ..random-name name.equivalence])) + [/.list (/.list /.nat) format.list (format.list format.nat) (random.list ..segment_size random.nat) (list.equivalence n.equivalence)] + [/.set (/.set n.hash /.nat) format.set (format.set format.nat) (random.set n.hash ..segment_size random.nat) set.equivalence] + [/.name /.name format.name format.name ..random_name name.equivalence])) (do {! random.monad} - [expected (\ ! map (list.repeat ..segment-size) random.nat)] - (_.cover [/.set-elements-are-not-unique] + [expected (\ ! map (list.repeat ..segment_size) random.nat)] + (_.cover [/.set_elements_are_not_unique] (|> expected (format.run (format.list format.nat)) (/.run (/.set n.hash /.nat)) (!expect (^multi (#try.Failure error) - (exception.match? /.set-elements-are-not-unique error)))))) + (exception.match? /.set_elements_are_not_unique error)))))) (do {! random.monad} [expected (random.or random.bit random.nat)] (_.cover [/.or format.or] @@ -291,15 +291,15 @@ (n.max 2)) random.nat) value random.bit] - (_.cover [/.invalid-tag] + (_.cover [/.invalid_tag] (|> [tag value] (format.run (format.and format.bits/8 format.bit)) (/.run (: (/.Parser (Either Bit Nat)) (/.or /.bit /.nat))) (!expect (^multi (#try.Failure error) - (exception.match? /.invalid-tag error)))))) + (exception.match? /.invalid_tag error)))))) (do {! random.monad} - [expected (random.list ..segment-size random.nat)] + [expected (random.list ..segment_size random.nat)] (_.cover [/.rec format.rec format.and format.any] (|> expected (format.run (format.rec (|>> (format.and format.nat) @@ -322,64 +322,64 @@ (_.for [/.Parser]) (`` ($_ _.and (_.cover [/.run /.any - format.no-op format.instance] - (|> (format.instance format.no-op) + format.no_op format.instance] + (|> (format.instance format.no_op) (/.run /.any) (!expect (#try.Success _)))) (do {! random.monad} - [data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] - (_.cover [/.binary-was-not-fully-read] + [data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] + (_.cover [/.binary_was_not_fully_read] (|> data (/.run /.any) (!expect (^multi (#try.Failure error) - (exception.match? /.binary-was-not-fully-read error)))))) + (exception.match? /.binary_was_not_fully_read error)))))) (do {! random.monad} - [expected (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] + [expected (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] (_.cover [/.segment format.segment format.run] (|> expected - (format.run (format.segment ..segment-size)) - (/.run (/.segment ..segment-size)) + (format.run (format.segment ..segment_size)) + (/.run (/.segment ..segment_size)) (!expect (^multi (#try.Success actual) (\ binary.equivalence = expected actual)))))) (do {! random.monad} - [data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] + [data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] (_.cover [/.end?] (|> data (/.run (do <>.monad [pre /.end? - _ (/.segment ..segment-size) + _ (/.segment ..segment_size) post /.end?] (wrap (and (not pre) post)))) (!expect (#try.Success #1))))) (do {! random.monad} - [to-read (\ ! map (n.% (inc ..segment-size)) random.nat) - data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] + [to_read (\ ! map (n.% (inc ..segment_size)) random.nat) + data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] (_.cover [/.Offset /.offset] (|> data (/.run (do <>.monad [start /.offset - _ (/.segment to-read) + _ (/.segment to_read) offset /.offset - _ (/.segment (n.- to-read ..segment-size)) - nothing-left /.offset] + _ (/.segment (n.- to_read ..segment_size)) + nothing_left /.offset] (wrap (and (n.= 0 start) - (n.= to-read offset) - (n.= ..segment-size nothing-left))))) + (n.= to_read offset) + (n.= ..segment_size nothing_left))))) (!expect (#try.Success #1))))) (do {! random.monad} - [to-read (\ ! map (n.% (inc ..segment-size)) random.nat) - data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] + [to_read (\ ! map (n.% (inc ..segment_size)) random.nat) + data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] (_.cover [/.remaining] (|> data (/.run (do <>.monad - [_ (/.segment to-read) + [_ (/.segment to_read) remaining /.remaining - _ (/.segment (n.- to-read ..segment-size)) - nothing-left /.remaining] - (wrap (and (n.= ..segment-size - (n.+ to-read remaining)) - (n.= 0 nothing-left))))) + _ (/.segment (n.- to_read ..segment_size)) + nothing_left /.remaining] + (wrap (and (n.= ..segment_size + (n.+ to_read remaining)) + (n.= 0 nothing_left))))) (!expect (#try.Success #1))))) ..size ..binary diff --git a/stdlib/source/test/lux/control/parser/code.lux b/stdlib/source/test/lux/control/parser/code.lux index 0c2c42c8e..71aa8f39d 100644 --- a/stdlib/source/test/lux/control/parser/code.lux +++ b/stdlib/source/test/lux/control/parser/code.lux @@ -33,7 +33,7 @@ _ false)) -(def: random-name +(def: random_name (Random Name) (random.and (random.unicode 1) (random.unicode 1))) @@ -71,48 +71,48 @@ [/.nat /.nat! random.nat code.nat nat.equivalence] [/.int /.int! random.int code.int int.equivalence] [/.rev /.rev! random.rev code.rev rev.equivalence] - [/.frac /.frac! random.safe-frac code.frac frac.equivalence] + [/.frac /.frac! random.safe_frac code.frac frac.equivalence] [/.text /.text! (random.unicode 1) code.text text.equivalence] - [/.identifier /.identifier! ..random-name code.identifier name.equivalence] - [/.tag /.tag! ..random-name code.tag name.equivalence] - [/.local-identifier /.local-identifier! (random.unicode 1) code.local-identifier text.equivalence] - [/.local-tag /.local-tag! (random.unicode 1) code.local-tag text.equivalence] + [/.identifier /.identifier! ..random_name code.identifier name.equivalence] + [/.tag /.tag! ..random_name code.tag name.equivalence] + [/.local_identifier /.local_identifier! (random.unicode 1) code.local_identifier text.equivalence] + [/.local_tag /.local_tag! (random.unicode 1) code.local_tag text.equivalence] )) (~~ (template [<query> <code>] [(do {! random.monad} - [expected-left random.nat - expected-right random.int] + [expected_left random.nat + expected_right random.int] (_.cover [<query>] (|> (/.run (<query> (<>.and /.nat /.int)) - (list (<code> (list (code.nat expected-left) - (code.int expected-right))))) - (!expect (^multi (#try.Success [actual-left actual-right]) - (and (\ nat.equivalence = expected-left actual-left) - (\ int.equivalence = expected-right actual-right)))))))] + (list (<code> (list (code.nat expected_left) + (code.int expected_right))))) + (!expect (^multi (#try.Success [actual_left actual_right]) + (and (\ nat.equivalence = expected_left actual_left) + (\ int.equivalence = expected_right actual_right)))))))] [/.form code.form] [/.tuple code.tuple] )) (do {! random.monad} - [expected-left random.nat - expected-right random.int] + [expected_left random.nat + expected_right random.int] (_.cover [/.record] (|> (/.run (/.record (<>.and /.nat /.int)) - (list (code.record (list [(code.nat expected-left) - (code.int expected-right)])))) - (!expect (^multi (#try.Success [actual-left actual-right]) - (and (\ nat.equivalence = expected-left actual-left) - (\ int.equivalence = expected-right actual-right))))))) + (list (code.record (list [(code.nat expected_left) + (code.int expected_right)])))) + (!expect (^multi (#try.Success [actual_left actual_right]) + (and (\ nat.equivalence = expected_left actual_left) + (\ int.equivalence = expected_right actual_right))))))) (do {! random.monad} - [expected-local random.nat - expected-global random.int] + [expected_local random.nat + expected_global random.int] (_.cover [/.local] - (|> (/.run (<>.and (/.local (list (code.nat expected-local)) /.nat) + (|> (/.run (<>.and (/.local (list (code.nat expected_local)) /.nat) /.int) - (list (code.int expected-global))) - (!expect (^multi (#try.Success [actual-local actual-global]) - (and (\ nat.equivalence = expected-local actual-local) - (\ int.equivalence = expected-global actual-global))))))) + (list (code.int expected_global))) + (!expect (^multi (#try.Success [actual_local actual_global]) + (and (\ nat.equivalence = expected_local actual_local) + (\ int.equivalence = expected_global actual_global))))))) (do {! random.monad} [dummy (\ ! map code.bit random.bit)] (_.cover [/.end?] diff --git a/stdlib/source/test/lux/control/parser/json.lux b/stdlib/source/test/lux/control/parser/json.lux index cb6928062..b9d111eff 100644 --- a/stdlib/source/test/lux/control/parser/json.lux +++ b/stdlib/source/test/lux/control/parser/json.lux @@ -35,9 +35,9 @@ _ false)) -(def: safe-frac +(def: safe_frac (Random Frac) - (random.filter (|>> frac.not-a-number? not) random.frac)) + (random.filter (|>> frac.not_a_number? not) random.frac)) (def: #export test Test @@ -74,23 +74,23 @@ (!expect (#try.Failure _)))))))] [/.boolean /.boolean? /.boolean! random.bit #json.Boolean bit.equivalence] - [/.number /.number? /.number! ..safe-frac #json.Number frac.equivalence] + [/.number /.number? /.number! ..safe_frac #json.Number frac.equivalence] [/.string /.string? /.string! (random.unicode 1) #json.String text.equivalence] )) (do {! random.monad} [expected (random.unicode 1) dummy random.bit] - (_.cover [/.unexpected-value] + (_.cover [/.unexpected_value] (|> (/.run /.string (#json.Boolean dummy)) (!expect (^multi (#try.Failure error) - (exception.match? /.unexpected-value error)))))) + (exception.match? /.unexpected_value error)))))) (do {! random.monad} [expected (random.unicode 1) dummy (|> (random.unicode 1) (random.filter (|>> (\ text.equivalence = expected) not)))] - (_.cover [/.value-mismatch] + (_.cover [/.value_mismatch] (|> (/.run (/.string! expected) (#json.String dummy)) (!expect (^multi (#try.Failure error) - (exception.match? /.value-mismatch error)))))) + (exception.match? /.value_mismatch error)))))) (do {! random.monad} [expected (random.unicode 1)] (_.cover [/.nullable] @@ -104,59 +104,59 @@ [size (\ ! map (n.% 10) random.nat) expected (|> (random.unicode 1) (random.list size) - (\ ! map row.from-list))] + (\ ! map row.from_list))] (_.cover [/.array] (|> (/.run (/.array (<>.some /.string)) (#json.Array (row\map (|>> #json.String) expected))) (!expect (^multi (#try.Success actual) - (\ (row.equivalence text.equivalence) = expected (row.from-list actual))))))) + (\ (row.equivalence text.equivalence) = expected (row.from_list actual))))))) (do {! random.monad} [expected (\ ! map (|>> #json.String) (random.unicode 1))] - (_.cover [/.unconsumed-input] + (_.cover [/.unconsumed_input] (|> (/.run (/.array /.any) (#json.Array (row expected expected))) (!expect (^multi (#try.Failure error) - (exception.match? /.unconsumed-input error)))))) - (_.cover [/.empty-input] + (exception.match? /.unconsumed_input error)))))) + (_.cover [/.empty_input] (|> (/.run (/.array /.any) (#json.Array (row))) (!expect (^multi (#try.Failure error) - (exception.match? /.empty-input error))))) + (exception.match? /.empty_input error))))) (do {! random.monad} - [expected-boolean random.bit - expected-number ..safe-frac - expected-string (random.unicode 1) - [boolean-field number-field string-field] (|> (random.set text.hash 3 (random.unicode 3)) - (\ ! map (|>> set.to-list - (case> (^ (list boolean-field number-field string-field)) - [boolean-field number-field string-field] + [expected_boolean random.bit + expected_number ..safe_frac + expected_string (random.unicode 1) + [boolean_field number_field string_field] (|> (random.set text.hash 3 (random.unicode 3)) + (\ ! map (|>> set.to_list + (case> (^ (list boolean_field number_field string_field)) + [boolean_field number_field string_field] _ (undefined)))))] (_.cover [/.object /.field] (|> (/.run (/.object ($_ <>.and - (/.field boolean-field /.boolean) - (/.field number-field /.number) - (/.field string-field /.string))) + (/.field boolean_field /.boolean) + (/.field number_field /.number) + (/.field string_field /.string))) (#json.Object - (dictionary.from-list text.hash - (list [boolean-field (#json.Boolean expected-boolean)] - [number-field (#json.Number expected-number)] - [string-field (#json.String expected-string)])))) - (!expect (^multi (#try.Success [actual-boolean actual-number actual-string]) - (and (\ bit.equivalence = expected-boolean actual-boolean) - (\ frac.equivalence = expected-number actual-number) - (\ text.equivalence = expected-string actual-string))))))) + (dictionary.from_list text.hash + (list [boolean_field (#json.Boolean expected_boolean)] + [number_field (#json.Number expected_number)] + [string_field (#json.String expected_string)])))) + (!expect (^multi (#try.Success [actual_boolean actual_number actual_string]) + (and (\ bit.equivalence = expected_boolean actual_boolean) + (\ frac.equivalence = expected_number actual_number) + (\ text.equivalence = expected_string actual_string))))))) (do {! random.monad} [size (\ ! map (n.% 10) random.nat) keys (random.list size (random.unicode 1)) values (random.list size (random.unicode 1)) - #let [expected (dictionary.from-list text.hash (list.zip/2 keys values))]] + #let [expected (dictionary.from_list text.hash (list.zip/2 keys values))]] (_.cover [/.dictionary] (|> (/.run (/.dictionary /.string) (#json.Object (|> values (list\map (|>> #json.String)) (list.zip/2 keys) - (dictionary.from-list text.hash)))) + (dictionary.from_list text.hash)))) (!expect (^multi (#try.Success actual) (\ (dictionary.equivalence text.equivalence) = expected actual)))))) )))) diff --git a/stdlib/source/test/lux/control/parser/synthesis.lux b/stdlib/source/test/lux/control/parser/synthesis.lux index daf44e7ae..b47f8338c 100644 --- a/stdlib/source/test/lux/control/parser/synthesis.lux +++ b/stdlib/source/test/lux/control/parser/synthesis.lux @@ -39,21 +39,21 @@ _ false)) -(def: random-constant +(def: random_constant (Random Name) (random.and (random.unicode 1) (random.unicode 1))) -(def: random-variable +(def: random_variable (Random Variable) (random.or random.nat random.nat)) -(def: random-environment +(def: random_environment (Random (Environment Synthesis)) (do {! random.monad} [size (\ ! map (n.% 5) random.nat)] - (|> ..random-variable + (|> ..random_variable (\ ! map (|>> synthesis.variable)) (random.list size)))) @@ -74,15 +74,16 @@ (!expect (#try.Success _))) (|> (/.run (<check> expected) (list (<synthesis> dummy))) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-parse error))))))))] + (exception.match? /.cannot_parse error)))))) + ))] [/.bit /.bit! random.bit synthesis.bit bit.equivalence] [/.i64 /.i64! (\ ! map .i64 random.nat) synthesis.i64 i64.equivalence] - [/.f64 /.f64! random.safe-frac synthesis.f64 frac.equivalence] + [/.f64 /.f64! random.safe_frac synthesis.f64 frac.equivalence] [/.text /.text! (random.unicode 1) synthesis.text text.equivalence] [/.local /.local! random.nat synthesis.variable/local n.equivalence] [/.foreign /.foreign! random.nat synthesis.variable/foreign n.equivalence] - [/.constant /.constant! ..random-constant synthesis.constant name.equivalence] + [/.constant /.constant! ..random_constant synthesis.constant name.equivalence] )) ))) @@ -90,70 +91,70 @@ Test ($_ _.and (do {! random.monad} - [expected-bit random.bit - expected-i64 (\ ! map .i64 random.nat) - expected-f64 random.safe-frac - expected-text (random.unicode 1)] + [expected_bit random.bit + expected_i64 (\ ! map .i64 random.nat) + expected_f64 random.safe_frac + expected_text (random.unicode 1)] (_.cover [/.tuple] (and (|> (/.run (/.tuple ($_ <>.and /.bit /.i64 /.f64 /.text)) - (list (synthesis.tuple (list (synthesis.bit expected-bit) - (synthesis.i64 expected-i64) - (synthesis.f64 expected-f64) - (synthesis.text expected-text))))) - (!expect (^multi (#try.Success [actual-bit actual-i64 actual-f64 actual-text]) - (and (\ bit.equivalence = expected-bit actual-bit) - (\ i64.equivalence = expected-i64 actual-i64) - (\ frac.equivalence = expected-f64 actual-f64) - (\ text.equivalence = expected-text actual-text))))) + (list (synthesis.tuple (list (synthesis.bit expected_bit) + (synthesis.i64 expected_i64) + (synthesis.f64 expected_f64) + (synthesis.text expected_text))))) + (!expect (^multi (#try.Success [actual_bit actual_i64 actual_f64 actual_text]) + (and (\ bit.equivalence = expected_bit actual_bit) + (\ i64.equivalence = expected_i64 actual_i64) + (\ frac.equivalence = expected_f64 actual_f64) + (\ text.equivalence = expected_text actual_text))))) (|> (/.run (/.tuple ($_ <>.and /.bit /.i64 /.f64 /.text)) - (list (synthesis.text expected-text))) + (list (synthesis.text expected_text))) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-parse error))))))) + (exception.match? /.cannot_parse error))))))) (do {! random.monad} [arity random.nat - expected-environment ..random-environment - expected-body (random.unicode 1)] + expected_environment ..random_environment + expected_body (random.unicode 1)] (_.cover [/.function] (and (|> (/.run (/.function arity /.text) - (list (synthesis.function/abstraction [expected-environment arity (synthesis.text expected-body)]))) - (!expect (^multi (#try.Success [actual-environment actual-body]) + (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)]))) + (!expect (^multi (#try.Success [actual_environment actual_body]) (and (\ (list.equivalence synthesis.equivalence) = - expected-environment - actual-environment) - (\ text.equivalence = expected-body actual-body))))) + expected_environment + actual_environment) + (\ text.equivalence = expected_body actual_body))))) (|> (/.run (/.function arity /.text) - (list (synthesis.text expected-body))) + (list (synthesis.text expected_body))) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-parse error))))))) + (exception.match? /.cannot_parse error))))))) (do {! random.monad} [arity random.nat - expected-environment ..random-environment - expected-body (random.unicode 1)] - (_.cover [/.wrong-arity] + expected_environment ..random_environment + expected_body (random.unicode 1)] + (_.cover [/.wrong_arity] (|> (/.run (/.function (inc arity) /.text) - (list (synthesis.function/abstraction [expected-environment arity (synthesis.text expected-body)]))) + (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)]))) (!expect (^multi (#try.Failure error) - (exception.match? /.wrong-arity error)))))) + (exception.match? /.wrong_arity error)))))) (do {! random.monad} [arity (\ ! map (|>> (n.% 10) inc) random.nat) - expected-offset random.nat - expected-inits (random.list arity random.bit) - expected-body (random.unicode 1)] + expected_offset random.nat + expected_inits (random.list arity random.bit) + expected_body (random.unicode 1)] (_.cover [/.loop] (and (|> (/.run (/.loop (<>.many /.bit) /.text) - (list (synthesis.loop/scope [expected-offset - (list\map (|>> synthesis.bit) expected-inits) - (synthesis.text expected-body)]))) - (!expect (^multi (#try.Success [actual-offset actual-inits actual-body]) - (and (\ n.equivalence = expected-offset actual-offset) + (list (synthesis.loop/scope [expected_offset + (list\map (|>> synthesis.bit) expected_inits) + (synthesis.text expected_body)]))) + (!expect (^multi (#try.Success [actual_offset actual_inits actual_body]) + (and (\ n.equivalence = expected_offset actual_offset) (\ (list.equivalence bit.equivalence) = - expected-inits - actual-inits) - (\ text.equivalence = expected-body actual-body))))) + expected_inits + actual_inits) + (\ text.equivalence = expected_body actual_body))))) (|> (/.run (/.loop (<>.many /.bit) /.text) - (list (synthesis.text expected-body))) + (list (synthesis.text expected_body))) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-parse error))))))) + (exception.match? /.cannot_parse error))))))) )) (def: #export test @@ -167,24 +168,24 @@ (|> (/.run /.any (list expected)) (!expect (^multi (#try.Success actual) (\ synthesis.equivalence = expected actual)))))) - (_.cover [/.empty-input] + (_.cover [/.empty_input] (|> (/.run /.any (list)) (!expect (^multi (#try.Failure error) - (exception.match? /.empty-input error))))) + (exception.match? /.empty_input error))))) (do {! random.monad} [expected (\ ! map (|>> synthesis.i64) random.nat)] - (_.cover [/.unconsumed-input] + (_.cover [/.unconsumed_input] (|> (/.run /.any (list expected expected)) (!expect (^multi (#try.Failure error) - (exception.match? /.unconsumed-input error)))))) + (exception.match? /.unconsumed_input error)))))) (do {! random.monad} [dummy (\ ! map (|>> synthesis.i64) random.nat)] - (_.cover [/.end! /.expected-empty-input] + (_.cover [/.end! /.expected_empty_input] (and (|> (/.run /.end! (list)) (!expect (#try.Success _))) (|> (/.run /.end! (list dummy)) (!expect (^multi (#try.Failure error) - (exception.match? /.expected-empty-input error))))))) + (exception.match? /.expected_empty_input error))))))) (do {! random.monad} [dummy (\ ! map (|>> synthesis.i64) random.nat)] (_.cover [/.end?] @@ -192,7 +193,7 @@ (!expect (#try.Success #1))) (|> (/.run (<>.before /.any /.end?) (list dummy)) (!expect (#try.Success #0)))))) - (_.for [/.cannot-parse] + (_.for [/.cannot_parse] ($_ _.and ..simple ..complex diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux index 8436e30ca..8465393de 100644 --- a/stdlib/source/test/lux/control/parser/text.lux +++ b/stdlib/source/test/lux/control/parser/text.lux @@ -38,7 +38,7 @@ _ false)) -(def: (should-fail' sample parser exception) +(def: (should_fail' sample parser exception) (All [a e] (-> Text (/.Parser a) (Exception e) Bit)) (case (/.run parser sample) (#try.Failure error) @@ -47,7 +47,7 @@ _ false)) -(def: (should-fail sample parser) +(def: (should_fail sample parser) (All [a] (-> Text (/.Parser a) Bit)) (case (/.run parser sample) (#try.Failure _) @@ -56,157 +56,157 @@ _ false)) -(def: (should-pass expected parser) +(def: (should_pass expected parser) (-> Text (/.Parser Text) Bit) (|> expected (/.run parser) (\ try.functor map (text\= expected)) (try.default false))) -(def: (should-pass! expected parser) +(def: (should_pass! expected parser) (-> Text (/.Parser /.Slice) Bit) - (..should-pass expected (/.slice parser))) + (..should_pass expected (/.slice parser))) -(def: character-classes +(def: character_classes Test ($_ _.and (do {! random.monad} [offset (\ ! map (n.% 50) random.nat) range (\ ! map (|>> (n.% 50) (n.+ 10)) random.nat) #let [limit (n.+ offset range)] - expected (\ ! map (|>> (n.% range) (n.+ offset) text.from-code) random.nat) - out-of-range (case offset - 0 (\ ! map (|>> (n.% 10) inc (n.+ limit) text.from-code) random.nat) - _ (\ ! map (|>> (n.% offset) text.from-code) random.nat))] + expected (\ ! map (|>> (n.% range) (n.+ offset) text.from_code) random.nat) + out_of_range (case offset + 0 (\ ! map (|>> (n.% 10) inc (n.+ limit) text.from_code) random.nat) + _ (\ ! map (|>> (n.% offset) text.from_code) random.nat))] (_.cover [/.range] - (and (..should-pass expected (/.range offset limit)) - (..should-fail out-of-range (/.range offset limit))))) + (and (..should_pass expected (/.range offset limit)) + (..should_fail out_of_range (/.range offset limit))))) (do {! random.monad} - [expected (random.char unicode.ascii/upper-alpha) - invalid (random.filter (|>> (unicode/block.within? unicode/block.basic-latin/upper-alpha) not) + [expected (random.char unicode.ascii/upper_alpha) + invalid (random.filter (|>> (unicode/block.within? unicode/block.basic_latin/upper_alpha) not) (random.char unicode.character))] (_.cover [/.upper] - (and (..should-pass (text.from-code expected) /.upper) - (..should-fail (text.from-code invalid) /.upper)))) + (and (..should_pass (text.from_code expected) /.upper) + (..should_fail (text.from_code invalid) /.upper)))) (do {! random.monad} - [expected (random.char unicode.ascii/lower-alpha) - invalid (random.filter (|>> (unicode/block.within? unicode/block.basic-latin/lower-alpha) not) + [expected (random.char unicode.ascii/lower_alpha) + invalid (random.filter (|>> (unicode/block.within? unicode/block.basic_latin/lower_alpha) not) (random.char unicode.character))] (_.cover [/.lower] - (and (..should-pass (text.from-code expected) /.lower) - (..should-fail (text.from-code invalid) /.lower)))) + (and (..should_pass (text.from_code expected) /.lower) + (..should_fail (text.from_code invalid) /.lower)))) (do {! random.monad} [expected (\ ! map (n.% 10) random.nat) - invalid (random.char (unicode.set [unicode/block.number-forms (list)]))] + invalid (random.char (unicode.set [unicode/block.number_forms (list)]))] (_.cover [/.decimal] - (and (..should-pass (\ n.decimal encode expected) /.decimal) - (..should-fail (text.from-code invalid) /.decimal)))) + (and (..should_pass (\ n.decimal encode expected) /.decimal) + (..should_fail (text.from_code invalid) /.decimal)))) (do {! random.monad} [expected (\ ! map (n.% 8) random.nat) - invalid (random.char (unicode.set [unicode/block.number-forms (list)]))] + invalid (random.char (unicode.set [unicode/block.number_forms (list)]))] (_.cover [/.octal] - (and (..should-pass (\ n.octal encode expected) /.octal) - (..should-fail (text.from-code invalid) /.octal)))) + (and (..should_pass (\ n.octal encode expected) /.octal) + (..should_fail (text.from_code invalid) /.octal)))) (do {! random.monad} [expected (\ ! map (n.% 16) random.nat) - invalid (random.char (unicode.set [unicode/block.number-forms (list)]))] + invalid (random.char (unicode.set [unicode/block.number_forms (list)]))] (_.cover [/.hexadecimal] - (and (..should-pass (\ n.hex encode expected) /.hexadecimal) - (..should-fail (text.from-code invalid) /.hexadecimal)))) + (and (..should_pass (\ n.hex encode expected) /.hexadecimal) + (..should_fail (text.from_code invalid) /.hexadecimal)))) (do {! random.monad} [expected (random.char unicode.ascii/alpha) invalid (random.filter (function (_ char) - (not (or (unicode/block.within? unicode/block.basic-latin/upper-alpha char) - (unicode/block.within? unicode/block.basic-latin/lower-alpha char)))) + (not (or (unicode/block.within? unicode/block.basic_latin/upper_alpha char) + (unicode/block.within? unicode/block.basic_latin/lower_alpha char)))) (random.char unicode.character))] (_.cover [/.alpha] - (and (..should-pass (text.from-code expected) /.alpha) - (..should-fail (text.from-code invalid) /.alpha)))) + (and (..should_pass (text.from_code expected) /.alpha) + (..should_fail (text.from_code invalid) /.alpha)))) (do {! random.monad} - [expected (random.char unicode.ascii/alpha-num) + [expected (random.char unicode.ascii/alpha_num) invalid (random.filter (function (_ char) - (not (or (unicode/block.within? unicode/block.basic-latin/upper-alpha char) - (unicode/block.within? unicode/block.basic-latin/lower-alpha char) - (unicode/block.within? unicode/block.basic-latin/decimal char)))) + (not (or (unicode/block.within? unicode/block.basic_latin/upper_alpha char) + (unicode/block.within? unicode/block.basic_latin/lower_alpha char) + (unicode/block.within? unicode/block.basic_latin/decimal char)))) (random.char unicode.character))] - (_.cover [/.alpha-num] - (and (..should-pass (text.from-code expected) /.alpha-num) - (..should-fail (text.from-code invalid) /.alpha-num)))) + (_.cover [/.alpha_num] + (and (..should_pass (text.from_code expected) /.alpha_num) + (..should_fail (text.from_code invalid) /.alpha_num)))) (do {! random.monad} [expected ($_ random.either (wrap text.tab) - (wrap text.vertical-tab) + (wrap text.vertical_tab) (wrap text.space) - (wrap text.new-line) - (wrap text.carriage-return) - (wrap text.form-feed)) + (wrap text.new_line) + (wrap text.carriage_return) + (wrap text.form_feed)) invalid (|> (random.unicode 1) (random.filter (function (_ char) (not (or (text\= text.tab char) - (text\= text.vertical-tab char) + (text\= text.vertical_tab char) (text\= text.space char) - (text\= text.new-line char) - (text\= text.carriage-return char) - (text\= text.form-feed char))))))] + (text\= text.new_line char) + (text\= text.carriage_return char) + (text\= text.form_feed char))))))] (_.cover [/.space] - (and (..should-pass expected /.space) - (..should-fail invalid /.space)))) + (and (..should_pass expected /.space) + (..should_fail invalid /.space)))) (do {! random.monad} - [#let [num-options 3] + [#let [num_options 3] options (|> (random.char unicode.character) - (random.set n.hash num-options) - (\ ! map (|>> set.to-list - (list\map text.from-code) - (text.join-with "")))) + (random.set n.hash num_options) + (\ ! map (|>> set.to_list + (list\map text.from_code) + (text.join_with "")))) expected (\ ! map (function (_ value) (|> options - (text.nth (n.% num-options value)) + (text.nth (n.% num_options value)) maybe.assume)) random.nat) invalid (random.filter (function (_ char) - (not (text.contains? (text.from-code char) options))) + (not (text.contains? (text.from_code char) options))) (random.char unicode.character))] - (_.cover [/.one-of /.one-of! /.character-should-be] - (and (..should-pass (text.from-code expected) (/.one-of options)) - (..should-fail (text.from-code invalid) (/.one-of options)) - (..should-fail' (text.from-code invalid) (/.one-of options) - /.character-should-be) + (_.cover [/.one_of /.one_of! /.character_should_be] + (and (..should_pass (text.from_code expected) (/.one_of options)) + (..should_fail (text.from_code invalid) (/.one_of options)) + (..should_fail' (text.from_code invalid) (/.one_of options) + /.character_should_be) - (..should-pass! (text.from-code expected) (/.one-of! options)) - (..should-fail (text.from-code invalid) (/.one-of! options)) - (..should-fail' (text.from-code invalid) (/.one-of! options) - /.character-should-be) + (..should_pass! (text.from_code expected) (/.one_of! options)) + (..should_fail (text.from_code invalid) (/.one_of! options)) + (..should_fail' (text.from_code invalid) (/.one_of! options) + /.character_should_be) ))) (do {! random.monad} - [#let [num-options 3] + [#let [num_options 3] options (|> (random.char unicode.character) - (random.set n.hash num-options) - (\ ! map (|>> set.to-list - (list\map text.from-code) - (text.join-with "")))) + (random.set n.hash num_options) + (\ ! map (|>> set.to_list + (list\map text.from_code) + (text.join_with "")))) invalid (\ ! map (function (_ value) (|> options - (text.nth (n.% num-options value)) + (text.nth (n.% num_options value)) maybe.assume)) random.nat) expected (random.filter (function (_ char) - (not (text.contains? (text.from-code char) options))) + (not (text.contains? (text.from_code char) options))) (random.char unicode.character))] - (_.cover [/.none-of /.none-of! /.character-should-not-be] - (and (..should-pass (text.from-code expected) (/.none-of options)) - (..should-fail (text.from-code invalid) (/.none-of options)) - (..should-fail' (text.from-code invalid) (/.none-of options) - /.character-should-not-be) + (_.cover [/.none_of /.none_of! /.character_should_not_be] + (and (..should_pass (text.from_code expected) (/.none_of options)) + (..should_fail (text.from_code invalid) (/.none_of options)) + (..should_fail' (text.from_code invalid) (/.none_of options) + /.character_should_not_be) - (..should-pass! (text.from-code expected) (/.none-of! options)) - (..should-fail (text.from-code invalid) (/.none-of! options)) - (..should-fail' (text.from-code invalid) (/.none-of! options) - /.character-should-not-be) + (..should_pass! (text.from_code expected) (/.none_of! options)) + (..should_fail (text.from_code invalid) (/.none_of! options)) + (..should_fail' (text.from_code invalid) (/.none_of! options) + /.character_should_not_be) ))) )) (def: runs Test - (let [octal! (/.one-of! "01234567")] + (let [octal! (/.one_of! "01234567")] ($_ _.and (do {! random.monad} [left (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat) @@ -217,10 +217,10 @@ (random.filter (n.>= 8)) (\ ! map (\ n.hex encode)))] (_.cover [/.many /.many!] - (and (..should-pass expected (/.many /.octal)) - (..should-fail invalid (/.many /.octal)) + (and (..should_pass expected (/.many /.octal)) + (..should_fail invalid (/.many /.octal)) - (..should-pass! expected (/.many! octal!))))) + (..should_pass! expected (/.many! octal!))))) (do {! random.monad} [left (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat) right (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat) @@ -230,64 +230,64 @@ (random.filter (n.>= 8)) (\ ! map (\ n.hex encode)))] (_.cover [/.some /.some!] - (and (..should-pass expected (/.some /.octal)) - (..should-pass "" (/.some /.octal)) - (..should-fail invalid (/.some /.octal)) + (and (..should_pass expected (/.some /.octal)) + (..should_pass "" (/.some /.octal)) + (..should_fail invalid (/.some /.octal)) - (..should-pass! expected (/.some! octal!)) - (..should-pass! "" (/.some! octal!))))) + (..should_pass! expected (/.some! octal!)) + (..should_pass! "" (/.some! octal!))))) (do {! random.monad} [#let [octal (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat)] first octal second octal third octal] (_.cover [/.exactly /.exactly!] - (and (..should-pass (format first second) (/.exactly 2 /.octal)) - (..should-fail (format first second third) (/.exactly 2 /.octal)) - (..should-fail (format first) (/.exactly 2 /.octal)) + (and (..should_pass (format first second) (/.exactly 2 /.octal)) + (..should_fail (format first second third) (/.exactly 2 /.octal)) + (..should_fail (format first) (/.exactly 2 /.octal)) - (..should-pass! (format first second) (/.exactly! 2 octal!)) - (..should-fail (format first second third) (/.exactly! 2 octal!)) - (..should-fail (format first) (/.exactly! 2 octal!))))) + (..should_pass! (format first second) (/.exactly! 2 octal!)) + (..should_fail (format first second third) (/.exactly! 2 octal!)) + (..should_fail (format first) (/.exactly! 2 octal!))))) (do {! random.monad} [#let [octal (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat)] first octal second octal third octal] - (_.cover [/.at-most /.at-most!] - (and (..should-pass (format first second) (/.at-most 2 /.octal)) - (..should-pass (format first) (/.at-most 2 /.octal)) - (..should-fail (format first second third) (/.at-most 2 /.octal)) + (_.cover [/.at_most /.at_most!] + (and (..should_pass (format first second) (/.at_most 2 /.octal)) + (..should_pass (format first) (/.at_most 2 /.octal)) + (..should_fail (format first second third) (/.at_most 2 /.octal)) - (..should-pass! (format first second) (/.at-most! 2 octal!)) - (..should-pass! (format first) (/.at-most! 2 octal!)) - (..should-fail (format first second third) (/.at-most! 2 octal!))))) + (..should_pass! (format first second) (/.at_most! 2 octal!)) + (..should_pass! (format first) (/.at_most! 2 octal!)) + (..should_fail (format first second third) (/.at_most! 2 octal!))))) (do {! random.monad} [#let [octal (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat)] first octal second octal third octal] - (_.cover [/.at-least /.at-least!] - (and (..should-pass (format first second) (/.at-least 2 /.octal)) - (..should-pass (format first second third) (/.at-least 2 /.octal)) - (..should-fail (format first) (/.at-least 2 /.octal)) + (_.cover [/.at_least /.at_least!] + (and (..should_pass (format first second) (/.at_least 2 /.octal)) + (..should_pass (format first second third) (/.at_least 2 /.octal)) + (..should_fail (format first) (/.at_least 2 /.octal)) - (..should-pass! (format first second) (/.at-least! 2 octal!)) - (..should-pass! (format first second third) (/.at-least! 2 octal!)) - (..should-fail (format first) (/.at-least! 2 octal!))))) + (..should_pass! (format first second) (/.at_least! 2 octal!)) + (..should_pass! (format first second third) (/.at_least! 2 octal!)) + (..should_fail (format first) (/.at_least! 2 octal!))))) (do {! random.monad} [#let [octal (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat)] first octal second octal third octal] (_.cover [/.between /.between!] - (and (..should-pass (format first second) (/.between 2 3 /.octal)) - (..should-pass (format first second third) (/.between 2 3 /.octal)) - (..should-fail (format first) (/.between 2 3 /.octal)) + (and (..should_pass (format first second) (/.between 2 3 /.octal)) + (..should_pass (format first second third) (/.between 2 3 /.octal)) + (..should_fail (format first) (/.between 2 3 /.octal)) - (..should-pass! (format first second) (/.between! 2 3 octal!)) - (..should-pass! (format first second third) (/.between! 2 3 octal!)) - (..should-fail (format first) (/.between! 2 3 octal!))))) + (..should_pass! (format first second) (/.between! 2 3 octal!)) + (..should_pass! (format first second third) (/.between! 2 3 octal!)) + (..should_fail (format first) (/.between! 2 3 octal!))))) ))) (def: #export test @@ -309,42 +309,42 @@ expected (random.unicode size) dummy (|> (random.unicode size) (random.filter (|>> (text\= expected) not)))] - (_.cover [/.this /.cannot-match] + (_.cover [/.this /.cannot_match] (and (|> (/.run (/.this expected) expected) (!expect (#try.Success []))) (|> (/.run (/.this expected) dummy) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-match error))))))) - (_.cover [/.Slice /.slice /.cannot-slice] + (exception.match? /.cannot_match error))))))) + (_.cover [/.Slice /.slice /.cannot_slice] (|> "" (/.run (/.slice /.any!)) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-slice error))))) + (exception.match? /.cannot_slice error))))) (do {! random.monad} [expected (random.unicode 1)] (_.cover [/.any /.any!] - (and (..should-pass expected /.any) - (..should-fail "" /.any) + (and (..should_pass expected /.any) + (..should_fail "" /.any) - (..should-pass! expected /.any!) - (..should-fail "" /.any!)))) + (..should_pass! expected /.any!) + (..should_fail "" /.any!)))) (do {! random.monad} [expected (random.unicode 1)] - (_.cover [/.peek /.cannot-parse] - (and (..should-pass expected (<>.before /.any /.peek)) + (_.cover [/.peek /.cannot_parse] + (and (..should_pass expected (<>.before /.any /.peek)) (|> "" (/.run (<>.before /.any /.peek)) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-parse error))))))) + (exception.match? /.cannot_parse error))))))) (do {! random.monad} [dummy (random.unicode 1)] - (_.cover [/.unconsumed-input] + (_.cover [/.unconsumed_input] (|> (format dummy dummy) (/.run /.any) (!expect (^multi (#try.Failure error) - (exception.match? /.unconsumed-input error)))))) + (exception.match? /.unconsumed_input error)))))) (do {! random.monad} [sample (random.unicode 1)] (_.cover [/.Offset /.offset] @@ -359,12 +359,12 @@ [left (random.unicode 1) right (random.unicode 1) #let [input (format left right)]] - (_.cover [/.get-input] + (_.cover [/.get_input] (|> input (/.run (do <>.monad - [pre /.get-input + [pre /.get_input _ /.any - post /.get-input + post /.get_input _ /.any] (wrap (and (text\= input pre) (text\= right post))))) @@ -395,47 +395,47 @@ (!expect (^multi (#try.Success actual) (text\= expected actual)))))) (do {! random.monad} - [invalid (random.ascii/upper-alpha 1) - expected (random.filter (|>> (unicode/block.within? unicode/block.basic-latin/upper-alpha) + [invalid (random.ascii/upper_alpha 1) + expected (random.filter (|>> (unicode/block.within? unicode/block.basic_latin/upper_alpha) not) (random.char unicode.character)) - #let [upper! (/.one-of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]] - (_.cover [/.not /.not! /.expected-to-fail] - (and (..should-pass (text.from-code expected) (/.not /.upper)) + #let [upper! (/.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]] + (_.cover [/.not /.not! /.expected_to_fail] + (and (..should_pass (text.from_code expected) (/.not /.upper)) (|> invalid (/.run (/.not /.upper)) (!expect (^multi (#try.Failure error) - (exception.match? /.expected-to-fail error)))) + (exception.match? /.expected_to_fail error)))) - (..should-pass! (text.from-code expected) (/.not! upper!)) + (..should_pass! (text.from_code expected) (/.not! upper!)) (|> invalid (/.run (/.not! upper!)) (!expect (^multi (#try.Failure error) - (exception.match? /.expected-to-fail error))))))) + (exception.match? /.expected_to_fail error))))))) (do {! random.monad} - [upper (random.ascii/upper-alpha 1) - lower (random.ascii/lower-alpha 1) + [upper (random.ascii/upper_alpha 1) + lower (random.ascii/lower_alpha 1) invalid (random.filter (function (_ char) - (not (or (unicode/block.within? unicode/block.basic-latin/upper-alpha char) - (unicode/block.within? unicode/block.basic-latin/lower-alpha char)))) + (not (or (unicode/block.within? unicode/block.basic_latin/upper_alpha char) + (unicode/block.within? unicode/block.basic_latin/lower_alpha char)))) (random.char unicode.character)) - #let [upper! (/.one-of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ") - lower! (/.one-of! "abcdefghijklmnopqrstuvwxyz")]] + #let [upper! (/.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ") + lower! (/.one_of! "abcdefghijklmnopqrstuvwxyz")]] (_.cover [/.and /.and!] - (and (..should-pass (format upper lower) (/.and /.upper /.lower)) - (..should-fail (format (text.from-code invalid) lower) (/.and /.upper /.lower)) - (..should-fail (format upper (text.from-code invalid)) (/.and /.upper /.lower)) + (and (..should_pass (format upper lower) (/.and /.upper /.lower)) + (..should_fail (format (text.from_code invalid) lower) (/.and /.upper /.lower)) + (..should_fail (format upper (text.from_code invalid)) (/.and /.upper /.lower)) - (..should-pass! (format upper lower) (/.and! upper! lower!)) - (..should-fail (format (text.from-code invalid) lower) (/.and! upper! lower!)) - (..should-fail (format upper (text.from-code invalid)) (/.and! upper! lower!))))) + (..should_pass! (format upper lower) (/.and! upper! lower!)) + (..should_fail (format (text.from_code invalid) lower) (/.and! upper! lower!)) + (..should_fail (format upper (text.from_code invalid)) (/.and! upper! lower!))))) (do {! random.monad} [expected (random.unicode 1) invalid (random.unicode 1)] - (_.cover [/.satisfies /.character-does-not-satisfy-predicate] - (and (..should-pass expected (/.satisfies (function.constant true))) - (..should-fail' invalid (/.satisfies (function.constant false)) - /.character-does-not-satisfy-predicate)))) - ..character-classes + (_.cover [/.satisfies /.character_does_not_satisfy_predicate] + (and (..should_pass expected (/.satisfies (function.constant true))) + (..should_fail' invalid (/.satisfies (function.constant false)) + /.character_does_not_satisfy_predicate)))) + ..character_classes ..runs ))) diff --git a/stdlib/source/test/lux/control/parser/type.lux b/stdlib/source/test/lux/control/parser/type.lux index f703d38a7..47cdac08f 100644 --- a/stdlib/source/test/lux/control/parser/type.lux +++ b/stdlib/source/test/lux/control/parser/type.lux @@ -29,13 +29,13 @@ (def: primitive (Random Type) - (|> (random.ascii/alpha-num 1) + (|> (random.ascii/alpha_num 1) (\ random.monad map (function (_ name) (#.Primitive name (list)))))) (def: matches Test - (<| (_.for [/.types-do-not-match]) + (<| (_.for [/.types_do_not_match]) (do {! random.monad} [expected ..primitive dummy (random.filter (|>> (type\= expected) not) @@ -46,7 +46,7 @@ (!expect (#try.Success []))) (|> (/.run (/.exactly expected) dummy) (!expect (^multi (#try.Failure error) - (exception.match? /.types-do-not-match error)))))) + (exception.match? /.types_do_not_match error)))))) (_.cover [/.sub] (and (|> (/.run (/.sub expected) expected) (!expect (#try.Success []))) @@ -56,7 +56,7 @@ (!expect (#try.Success []))) (|> (/.run (/.sub expected) dummy) (!expect (^multi (#try.Failure error) - (exception.match? /.types-do-not-match error)))))) + (exception.match? /.types_do_not_match error)))))) (_.cover [/.super] (and (|> (/.run (/.super expected) expected) (!expect (#try.Success []))) @@ -66,55 +66,55 @@ (!expect (#try.Success []))) (|> (/.run (/.super expected) dummy) (!expect (^multi (#try.Failure error) - (exception.match? /.types-do-not-match error)))))) + (exception.match? /.types_do_not_match error)))))) ))) (def: aggregate Test (do {! random.monad} - [expected-left ..primitive - expected-middle ..primitive - expected-right ..primitive] + [expected_left ..primitive + expected_middle ..primitive + expected_right ..primitive] (`` ($_ _.and - (~~ (template [<parser> <exception> <good-constructor> <bad-constructor>] + (~~ (template [<parser> <exception> <good_constructor> <bad_constructor>] [(_.cover [<parser> <exception>] (and (|> (/.run (<parser> ($_ //.and /.any /.any /.any)) - (<good-constructor> (list expected-left expected-middle expected-right))) - (!expect (^multi (#try.Success [actual-left actual-middle actual-right]) - (and (type\= expected-left actual-left) - (type\= expected-middle actual-middle) - (type\= expected-right actual-right))))) + (<good_constructor> (list expected_left expected_middle expected_right))) + (!expect (^multi (#try.Success [actual_left actual_middle actual_right]) + (and (type\= expected_left actual_left) + (type\= expected_middle actual_middle) + (type\= expected_right actual_right))))) (|> (/.run (<parser> ($_ //.and /.any /.any /.any)) - (<bad-constructor> (list expected-left expected-middle expected-right))) + (<bad_constructor> (list expected_left expected_middle expected_right))) (!expect (^multi (#try.Failure error) (exception.match? <exception> error))))))] - [/.variant /.not-variant type.variant type.tuple] - [/.tuple /.not-tuple type.tuple type.variant] + [/.variant /.not_variant type.variant type.tuple] + [/.tuple /.not_tuple type.tuple type.variant] )) - (_.cover [/.function /.not-function] + (_.cover [/.function /.not_function] (and (|> (/.run (/.function ($_ //.and /.any /.any) /.any) - (type.function (list expected-left expected-middle) expected-right)) - (!expect (^multi (#try.Success [[actual-left actual-middle] actual-right]) - (and (type\= expected-left actual-left) - (type\= expected-middle actual-middle) - (type\= expected-right actual-right))))) + (type.function (list expected_left expected_middle) expected_right)) + (!expect (^multi (#try.Success [[actual_left actual_middle] actual_right]) + (and (type\= expected_left actual_left) + (type\= expected_middle actual_middle) + (type\= expected_right actual_right))))) (|> (/.run (/.function ($_ //.and /.any /.any) /.any) - (type.variant (list expected-left expected-middle expected-right))) + (type.variant (list expected_left expected_middle expected_right))) (!expect (^multi (#try.Failure error) - (exception.match? /.not-function error)))))) - (_.cover [/.apply /.not-application] + (exception.match? /.not_function error)))))) + (_.cover [/.apply /.not_application] (and (|> (/.run (/.apply ($_ //.and /.any /.any /.any)) - (type.application (list expected-middle expected-right) expected-left)) - (!expect (^multi (#try.Success [actual-left actual-middle actual-right]) - (and (type\= expected-left actual-left) - (type\= expected-middle actual-middle) - (type\= expected-right actual-right))))) + (type.application (list expected_middle expected_right) expected_left)) + (!expect (^multi (#try.Success [actual_left actual_middle actual_right]) + (and (type\= expected_left actual_left) + (type\= expected_middle actual_middle) + (type\= expected_right actual_right))))) (|> (/.run (/.apply ($_ //.and /.any /.any /.any)) - (type.variant (list expected-left expected-middle expected-right))) + (type.variant (list expected_left expected_middle expected_right))) (!expect (^multi (#try.Failure error) - (exception.match? /.not-application error)))))) + (exception.match? /.not_application error)))))) )))) (def: parameter @@ -122,40 +122,40 @@ (do random.monad [quantification ..primitive argument ..primitive - not-parameter ..primitive + not_parameter ..primitive parameter random.nat] ($_ _.and - (_.cover [/.not-parameter] - (|> (/.run /.parameter not-parameter) + (_.cover [/.not_parameter] + (|> (/.run /.parameter not_parameter) (!expect (^multi (#try.Failure error) - (exception.match? /.not-parameter error))))) - (_.cover [/.unknown-parameter] + (exception.match? /.not_parameter error))))) + (_.cover [/.unknown_parameter] (|> (/.run /.parameter (#.Parameter parameter)) (!expect (^multi (#try.Failure error) - (exception.match? /.unknown-parameter error))))) - (_.cover [/.with-extension] - (|> (/.run (<| (/.with-extension quantification) - (/.with-extension argument) + (exception.match? /.unknown_parameter error))))) + (_.cover [/.with_extension] + (|> (/.run (<| (/.with_extension quantification) + (/.with_extension argument) /.any) - not-parameter) + not_parameter) (!expect (^multi (#try.Success [quantification\\binding argument\\binding actual]) - (is? not-parameter actual))))) + (is? not_parameter actual))))) (_.cover [/.parameter] - (|> (/.run (<| (/.with-extension quantification) - (/.with-extension argument) + (|> (/.run (<| (/.with_extension quantification) + (/.with_extension argument) /.parameter) (#.Parameter 0)) (!expect (#try.Success [quantification\\binding argument\\binding _])))) - (_.cover [/.wrong-parameter] - (|> (/.run (<| (/.with-extension quantification) - (/.with-extension argument) + (_.cover [/.wrong_parameter] + (|> (/.run (<| (/.with_extension quantification) + (/.with_extension argument) (/.parameter! 1)) (#.Parameter 0)) (!expect (^multi (#try.Failure error) - (exception.match? /.wrong-parameter error))))) + (exception.match? /.wrong_parameter error))))) (_.cover [/.parameter!] - (|> (/.run (<| (/.with-extension quantification) - (/.with-extension argument) + (|> (/.run (<| (/.with_extension quantification) + (/.with_extension argument) (/.parameter! 0)) (#.Parameter 0)) (!expect (#try.Success [quantification\\binding argument\\binding _])))) @@ -164,24 +164,24 @@ (def: polymorphic Test (do {! random.monad} - [not-polymorphic ..primitive - expected-inputs (\ ! map (|>> (n.% 10) inc) random.nat)] + [not_polymorphic ..primitive + expected_inputs (\ ! map (|>> (n.% 10) inc) random.nat)] ($_ _.and - (_.cover [/.not-polymorphic] + (_.cover [/.not_polymorphic] (and (|> (/.run (/.polymorphic /.any) - not-polymorphic) + not_polymorphic) (!expect (^multi (#try.Failure error) - (exception.match? /.not-polymorphic error)))) + (exception.match? /.not_polymorphic error)))) (|> (/.run (/.polymorphic /.any) - (type.univ-q 0 not-polymorphic)) + (type.univ_q 0 not_polymorphic)) (!expect (^multi (#try.Failure error) - (exception.match? /.not-polymorphic error)))))) + (exception.match? /.not_polymorphic error)))))) (_.cover [/.polymorphic] (|> (/.run (/.polymorphic /.any) - (type.univ-q expected-inputs not-polymorphic)) - (!expect (^multi (#try.Success [g!poly actual-inputs bodyT]) - (and (n.= expected-inputs (list.size actual-inputs)) - (is? not-polymorphic bodyT)))))) + (type.univ_q expected_inputs not_polymorphic)) + (!expect (^multi (#try.Success [g!poly actual_inputs bodyT]) + (and (n.= expected_inputs (list.size actual_inputs)) + (is? not_polymorphic bodyT)))))) ))) (def: #export test @@ -197,7 +197,7 @@ (type\= expected actual)))))) (do {! random.monad} [expected ..primitive] - (_.cover [/.peek /.unconsumed-input] + (_.cover [/.peek /.unconsumed_input] (and (|> (/.run (do //.monad [actual /.peek _ /.any] @@ -207,17 +207,17 @@ (type\= expected actual)))) (|> (/.run /.peek expected) (!expect (^multi (#try.Failure error) - (exception.match? /.unconsumed-input error))))))) + (exception.match? /.unconsumed_input error))))))) (do {! random.monad} [expected ..primitive] - (_.cover [/.empty-input] + (_.cover [/.empty_input] (`` (and (~~ (template [<parser>] [(|> (/.run (do //.monad [_ /.any] <parser>) expected) (!expect (^multi (#try.Failure error) - (exception.match? /.empty-input error))))] + (exception.match? /.empty_input error))))] [/.any] [/.peek] @@ -246,21 +246,21 @@ (type\= expected actual)))))) (do {! random.monad} [expected random.nat] - (_.cover [/.existential /.not-existential] + (_.cover [/.existential /.not_existential] (|> (/.run /.existential (#.Ex expected)) (!expect (^multi (#try.Success actual) (n.= expected actual)))))) (do {! random.monad} - [expected-name (random.and (random.ascii/alpha-num 1) - (random.ascii/alpha-num 1)) - expected-type ..primitive] - (_.cover [/.named /.not-named] + [expected_name (random.and (random.ascii/alpha_num 1) + (random.ascii/alpha_num 1)) + expected_type ..primitive] + (_.cover [/.named /.not_named] (|> (/.run /.named - (#.Named expected-name expected-type)) - (!expect (^multi (#try.Success [actual-name actual-type]) - (and (name\= expected-name actual-name) - (type\= expected-type actual-type))))))) + (#.Named expected_name expected_type)) + (!expect (^multi (#try.Success [actual_name actual_type]) + (and (name\= expected_name actual_name) + (type\= expected_type actual_type))))))) ..aggregate ..matches ..parameter diff --git a/stdlib/source/test/lux/control/parser/xml.lux b/stdlib/source/test/lux/control/parser/xml.lux index c17faa6b0..6d6126e8f 100644 --- a/stdlib/source/test/lux/control/parser/xml.lux +++ b/stdlib/source/test/lux/control/parser/xml.lux @@ -34,7 +34,7 @@ false)) (template: (!failure <exception> <cases>) - (with-expansions [<<cases>> (template.splice <cases>)] + (with_expansions [<<cases>> (template.splice <cases>)] (do {! random.monad} [expected (random.ascii/alpha 1)] (_.cover [<exception>] @@ -45,13 +45,13 @@ <<cases>>)))))))) -(def: random-label +(def: random_label (Random Name) (random.and (random.ascii/alpha 1) (random.ascii/alpha 1))) -(def: random-tag ..random-label) -(def: random-attribute ..random-label) +(def: random_tag ..random_label) +(def: random_attribute ..random_label) (def: #export test Test @@ -64,7 +64,7 @@ (|> (/.run /.text (#xml.Text expected)) (!expect (^multi (#try.Success actual) (text\= expected actual)))))) - (!failure /.unconsumed-inputs + (!failure /.unconsumed_inputs [[(//\wrap expected) (#xml.Text expected)]]) (do {! random.monad} @@ -73,7 +73,7 @@ (|> (/.run /.ignore (#xml.Text expected)) (!expect (#try.Success []))))) (do {! random.monad} - [expected ..random-tag] + [expected ..random_tag] (_.cover [/.tag] (|> (/.run (do //.monad [actual /.tag @@ -82,31 +82,31 @@ (#xml.Node expected (dictionary.new name.hash) (list))) (!expect (#try.Success #1))))) (do {! random.monad} - [expected ..random-tag] + [expected ..random_tag] (_.cover [/.node] (|> (/.run (do //.monad [_ (/.node expected)] /.ignore) (#xml.Node expected (dictionary.new name.hash) (list))) (!expect (#try.Success []))))) - (!failure /.wrong-tag + (!failure /.wrong_tag [[(/.node ["" expected]) (#xml.Node [expected ""] (dictionary.new name.hash) (list))]]) (do {! random.monad} - [expected-tag ..random-tag - expected-attribute ..random-attribute - expected-value (random.ascii/alpha 1)] + [expected_tag ..random_tag + expected_attribute ..random_attribute + expected_value (random.ascii/alpha 1)] (_.cover [/.attribute] (|> (/.run (do //.monad - [_ (/.node expected-tag) - _ (/.attribute expected-attribute)] + [_ (/.node expected_tag) + _ (/.attribute expected_attribute)] /.ignore) - (#xml.Node expected-tag + (#xml.Node expected_tag (|> (dictionary.new name.hash) - (dictionary.put expected-attribute expected-value)) + (dictionary.put expected_attribute expected_value)) (list))) (!expect (#try.Success []))))) - (!failure /.unknown-attribute + (!failure /.unknown_attribute [[(do //.monad [_ (/.attribute ["" expected])] /.ignore) @@ -115,7 +115,7 @@ (dictionary.put [expected ""] expected)) (list))]]) (do {! random.monad} - [expected ..random-tag] + [expected ..random_tag] (_.cover [/.children] (|> (/.run (do {! //.monad} [_ (/.node expected)] @@ -129,7 +129,7 @@ (dictionary.new name.hash) (list))))) (!expect (#try.Success []))))) - (!failure /.empty-input + (!failure /.empty_input [[(do //.monad [_ /.ignore] /.ignore) @@ -160,7 +160,7 @@ (list (#xml.Node [expected expected] (dictionary.new name.hash) (list))))]]) - (!failure /.unexpected-input + (!failure /.unexpected_input [[/.text (#xml.Node [expected expected] (dictionary.new name.hash) (list))] [(do //.monad @@ -182,10 +182,10 @@ [#let [node (: (-> xml.Tag (List xml.XML) xml.XML) (function (_ tag children) (#xml.Node tag (dictionary.new name.hash) children)))] - parent ..random-tag - right ..random-tag + parent ..random_tag + right ..random_tag wrong (random.filter (|>> (name\= right) not) - ..random-tag) + ..random_tag) #let [parser (/.children (do //.monad [_ (/.somewhere (/.node right)) diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index cfdbf5148..b9389dbdf 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -79,7 +79,7 @@ (<| (_.covering /._) (_.for [/.Region]) (do {! random.monad} - [expected-clean-ups (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1))))] + [expected_clean_ups (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1))))] ($_ _.and (_.for [/.functor] ($functor.spec ..injection ..comparison (: (All [! r] @@ -97,90 +97,90 @@ (_.cover [/.run] (thread.run (do {! thread.monad} - [clean-up-counter (thread.box 0) + [clean_up_counter (thread.box 0) #let [//@ ! - count-clean-up (function (_ value) + count_clean_up (function (_ value) (do ! - [_ (thread.update inc clean-up-counter)] + [_ (thread.update inc clean_up_counter)] (wrap (#try.Success []))))] outcome (/.run ! (do {! (/.monad !)} - [_ (monad.map ! (/.acquire //@ count-clean-up) - (enum.range n.enum 1 expected-clean-ups))] + [_ (monad.map ! (/.acquire //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups))] (wrap []))) - actual-clean-ups (thread.read clean-up-counter)] + actual_clean_ups (thread.read clean_up_counter)] (wrap (and (..success? outcome) - (n.= expected-clean-ups - actual-clean-ups)))))) + (n.= expected_clean_ups + actual_clean_ups)))))) (_.cover [/.fail] (thread.run (do {! thread.monad} - [clean-up-counter (thread.box 0) + [clean_up_counter (thread.box 0) #let [//@ ! - count-clean-up (function (_ value) + count_clean_up (function (_ value) (do ! - [_ (thread.update inc clean-up-counter)] + [_ (thread.update inc clean_up_counter)] (wrap (#try.Success []))))] outcome (/.run ! (do {! (/.monad !)} - [_ (monad.map ! (/.acquire //@ count-clean-up) - (enum.range n.enum 1 expected-clean-ups)) + [_ (monad.map ! (/.acquire //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups)) _ (/.fail //@ (exception.construct ..oops []))] (wrap []))) - actual-clean-ups (thread.read clean-up-counter)] + actual_clean_ups (thread.read clean_up_counter)] (wrap (and (..throws? ..oops outcome) - (n.= expected-clean-ups - actual-clean-ups)))))) + (n.= expected_clean_ups + actual_clean_ups)))))) (_.cover [/.throw] (thread.run (do {! thread.monad} - [clean-up-counter (thread.box 0) + [clean_up_counter (thread.box 0) #let [//@ ! - count-clean-up (function (_ value) + count_clean_up (function (_ value) (do ! - [_ (thread.update inc clean-up-counter)] + [_ (thread.update inc clean_up_counter)] (wrap (#try.Success []))))] outcome (/.run ! (do {! (/.monad !)} - [_ (monad.map ! (/.acquire //@ count-clean-up) - (enum.range n.enum 1 expected-clean-ups)) + [_ (monad.map ! (/.acquire //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups)) _ (/.throw //@ ..oops [])] (wrap []))) - actual-clean-ups (thread.read clean-up-counter)] + actual_clean_ups (thread.read clean_up_counter)] (wrap (and (..throws? ..oops outcome) - (n.= expected-clean-ups - actual-clean-ups)))))) - (_.cover [/.acquire /.clean-up-error] + (n.= expected_clean_ups + actual_clean_ups)))))) + (_.cover [/.acquire /.clean_up_error] (thread.run (do {! thread.monad} - [clean-up-counter (thread.box 0) + [clean_up_counter (thread.box 0) #let [//@ ! - count-clean-up (function (_ value) + count_clean_up (function (_ value) (do ! - [_ (thread.update inc clean-up-counter)] + [_ (thread.update inc clean_up_counter)] (wrap (: (Try Any) (exception.throw ..oops [])))))] outcome (/.run ! (do {! (/.monad !)} - [_ (monad.map ! (/.acquire //@ count-clean-up) - (enum.range n.enum 1 expected-clean-ups))] + [_ (monad.map ! (/.acquire //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups))] (wrap []))) - actual-clean-ups (thread.read clean-up-counter)] - (wrap (and (or (n.= 0 expected-clean-ups) - (..throws? /.clean-up-error outcome)) - (n.= expected-clean-ups - actual-clean-ups)))))) + actual_clean_ups (thread.read clean_up_counter)] + (wrap (and (or (n.= 0 expected_clean_ups) + (..throws? /.clean_up_error outcome)) + (n.= expected_clean_ups + actual_clean_ups)))))) (_.cover [/.lift] (thread.run (do {! thread.monad} - [clean-up-counter (thread.box 0) + [clean_up_counter (thread.box 0) #let [//@ !] outcome (/.run ! (do (/.monad !) - [_ (/.lift //@ (thread.write expected-clean-ups clean-up-counter))] + [_ (/.lift //@ (thread.write expected_clean_ups clean_up_counter))] (wrap []))) - actual-clean-ups (thread.read clean-up-counter)] + actual_clean_ups (thread.read clean_up_counter)] (wrap (and (..success? outcome) - (n.= expected-clean-ups - actual-clean-ups)))))) + (n.= expected_clean_ups + actual_clean_ups)))))) )))) diff --git a/stdlib/source/test/lux/control/remember.lux b/stdlib/source/test/lux/control/remember.lux index 5de61eed9..19c8f44f9 100644 --- a/stdlib/source/test/lux/control/remember.lux +++ b/stdlib/source/test/lux/control/remember.lux @@ -28,9 +28,9 @@ (def: deadline (Random Date) random.date) (def: message (Random Text) (random\map %.nat random.nat)) -(def: focus (Random Code) (random\map code.text (random.ascii/upper-alpha 10))) +(def: focus (Random Code) (random\map code.text (random.ascii/upper_alpha 10))) -(def: (to-remember macro deadline message focus) +(def: (to_remember macro deadline message focus) (-> Name Date Text (Maybe Code) Code) (` ((~ (code.identifier macro)) (~ (code.text (%.date deadline))) @@ -49,7 +49,7 @@ (#try.Failure error) (#try.Success [compiler (#try.Failure error)])))) -(def: (test-failure deadline message focus failure) +(def: (test_failure deadline message focus failure) (-> Date Text (Maybe Code) Text Bit) (and (text.contains? (%.date deadline) failure) (text.contains? message failure) @@ -60,40 +60,40 @@ (#.Some focus) (text.contains? (%.code focus) failure)))) -(syntax: (test-macro {macro <c>.identifier} {extra <c>.text}) +(syntax: (test_macro {macro <c>.identifier} {extra <c>.text}) (let [now (io.run instant.now) today (instant.date now) yesterday (instant.date (instant.shift (duration.inverse duration.week) now)) tomorrow (instant.date (instant.shift duration.week now)) - prng (random.pcg-32 [123 (instant.to-millis now)]) + prng (random.pcg_32 [123 (instant.to_millis now)]) message (product.right (random.run prng ..message)) expected (product.right (random.run prng ..focus))] (do meta.monad - [should-fail0 (..try (meta.expand (to-remember macro yesterday message #.None))) - should-fail1 (..try (meta.expand (to-remember macro yesterday message (#.Some expected)))) - should-succeed0 (..try (meta.expand (to-remember macro tomorrow message #.None))) - should-succeed1 (..try (meta.expand (to-remember macro tomorrow message (#.Some expected))))] - (wrap (list (code.bit (and (case should-fail0 + [should_fail0 (..try (meta.expand (to_remember macro yesterday message #.None))) + should_fail1 (..try (meta.expand (to_remember macro yesterday message (#.Some expected)))) + should_succeed0 (..try (meta.expand (to_remember macro tomorrow message #.None))) + should_succeed1 (..try (meta.expand (to_remember macro tomorrow message (#.Some expected))))] + (wrap (list (code.bit (and (case should_fail0 (#try.Failure error) - (and (test-failure yesterday message #.None error) + (and (test_failure yesterday message #.None error) (text.contains? extra error)) _ false) - (case should-fail1 + (case should_fail1 (#try.Failure error) - (and (test-failure yesterday message (#.Some expected) error) + (and (test_failure yesterday message (#.Some expected) error) (text.contains? extra error)) _ false) - (case should-succeed0 + (case should_succeed0 (^ (#try.Success (list))) true _ false) - (case should-succeed1 + (case should_succeed1 (^ (#try.Success (list actual))) (is? expected actual) @@ -109,15 +109,15 @@ message ..message focus ..focus] ($_ _.and - (_.cover [/.must-remember] - (and (test-failure deadline message #.None - (exception.construct /.must-remember [deadline deadline message #.None])) - (test-failure deadline message (#.Some focus) - (exception.construct /.must-remember [deadline deadline message (#.Some focus)])))) + (_.cover [/.must_remember] + (and (test_failure deadline message #.None + (exception.construct /.must_remember [deadline deadline message #.None])) + (test_failure deadline message (#.Some focus) + (exception.construct /.must_remember [deadline deadline message (#.Some focus)])))) (_.cover [/.remember] - (..test-macro /.remember "")) - (_.cover [/.to-do] - (..test-macro /.to-do "TODO")) - (_.cover [/.fix-me] - (..test-macro /.fix-me "FIXME")) + (..test_macro /.remember "")) + (_.cover [/.to_do] + (..test_macro /.to_do "TODO")) + (_.cover [/.fix_me] + (..test_macro /.fix_me "FIXME")) )))) diff --git a/stdlib/source/test/lux/control/security/policy.lux b/stdlib/source/test/lux/control/security/policy.lux index b907e8e54..55e928d52 100644 --- a/stdlib/source/test/lux/control/security/policy.lux +++ b/stdlib/source/test/lux/control/security/policy.lux @@ -19,19 +19,19 @@ [math ["." random]]] {1 - ["." / (#+ Context Privacy Can-Conceal Can-Reveal Privilege Private)]}) + ["." / (#+ Context Privacy Can_Conceal Can_Reveal Privilege Private)]}) -(def: (injection can-conceal) +(def: (injection can_conceal) (All [label] - (-> (Can-Conceal label) (Injection (All [value] (Private value label))))) - (!.use can-conceal)) + (-> (Can_Conceal label) (Injection (All [value] (Private value label))))) + (!.use can_conceal)) -(def: (comparison can-reveal) +(def: (comparison can_reveal) (All [label] - (-> (Can-Reveal label) (Comparison (All [value] (Private value label))))) + (-> (Can_Reveal label) (Comparison (All [value] (Private value label))))) (function (_ == left right) - (== (!.use can-reveal left) - (!.use can-reveal right)))) + (== (!.use can_reveal left) + (!.use can_reveal right)))) (type: Password (Private Text)) @@ -47,7 +47,7 @@ (def: (policy _) (Ex [%] (-> Any (Policy %))) - (/.with-policy + (/.with_policy (: (Context Privacy Policy) (function (_ (^@ privilege (^open "%\."))) (structure @@ -55,14 +55,14 @@ (structure (def: &equivalence (structure (def: (= reference sample) - (text\= (!.use %\can-downgrade reference) - (!.use %\can-downgrade sample))))) + (text\= (!.use %\can_downgrade reference) + (!.use %\can_downgrade sample))))) (def: hash - (|>> (!.use %\can-downgrade) + (|>> (!.use %\can_downgrade) (\ text.hash hash))))) (def: password - (!.use %\can-upgrade)) + (!.use %\can_upgrade)) (def: privilege privilege)))))) @@ -71,28 +71,28 @@ Test (<| (_.covering /._) (_.for [/.Policy - /.Can-Upgrade /.Can-Downgrade]) + /.Can_Upgrade /.Can_Downgrade]) (do random.monad - [#let [policy-0 (policy [])] - raw-password (random.ascii 10) - #let [password (\ policy-0 password raw-password)]] + [#let [policy_0 (policy [])] + raw_password (random.ascii 10) + #let [password (\ policy_0 password raw_password)]] ($_ _.and - (_.for [/.Privacy /.Private /.Can-Conceal /.Can-Reveal - /.Safety /.Safe /.Can-Trust /.Can-Distrust] + (_.for [/.Privacy /.Private /.Can_Conceal /.Can_Reveal + /.Safety /.Safe /.Can_Trust /.Can_Distrust] ($_ _.and (_.for [/.functor] - ($functor.spec (..injection (\ policy-0 can-upgrade)) (..comparison (\ policy-0 can-downgrade)) /.functor)) + ($functor.spec (..injection (\ policy_0 can_upgrade)) (..comparison (\ policy_0 can_downgrade)) /.functor)) (_.for [/.apply] - ($apply.spec (..injection (\ policy-0 can-upgrade)) (..comparison (\ policy-0 can-downgrade)) /.apply)) + ($apply.spec (..injection (\ policy_0 can_upgrade)) (..comparison (\ policy_0 can_downgrade)) /.apply)) (_.for [/.monad] - ($monad.spec (..injection (\ policy-0 can-upgrade)) (..comparison (\ policy-0 can-downgrade)) /.monad)))) + ($monad.spec (..injection (\ policy_0 can_upgrade)) (..comparison (\ policy_0 can_downgrade)) /.monad)))) - (_.cover [/.Privilege /.Context /.with-policy] - (and (\ policy-0 = password password) - (n.= (\ text.hash hash raw-password) - (\ policy-0 hash password)))) - (let [policy-1 (policy []) - delegate (/.delegation (\ policy-0 can-downgrade) (\ policy-1 can-upgrade))] + (_.cover [/.Privilege /.Context /.with_policy] + (and (\ policy_0 = password password) + (n.= (\ text.hash hash raw_password) + (\ policy_0 hash password)))) + (let [policy_1 (policy []) + delegate (/.delegation (\ policy_0 can_downgrade) (\ policy_1 can_upgrade))] (_.cover [/.Delegation /.delegation] - (\ policy-1 = (delegate password) (delegate password)))) + (\ policy_1 = (delegate password) (delegate password)))) )))) diff --git a/stdlib/source/test/lux/control/try.lux b/stdlib/source/test/lux/control/try.lux index 4238980d9..9993a3f70 100644 --- a/stdlib/source/test/lux/control/try.lux +++ b/stdlib/source/test/lux/control/try.lux @@ -72,17 +72,17 @@ (_.cover [/.assume] (n.= expected (/.assume (/.succeed expected)))) - (_.cover [/.from-maybe] - (case [(/.from-maybe (#.Some expected)) - (/.from-maybe #.None)] + (_.cover [/.from_maybe] + (case [(/.from_maybe (#.Some expected)) + (/.from_maybe #.None)] [(#/.Success actual) (#/.Failure _)] (n.= expected actual) _ false)) - (_.cover [/.to-maybe] - (case [(/.to-maybe (/.succeed expected)) - (/.to-maybe (/.fail error))] + (_.cover [/.to_maybe] + (case [(/.to_maybe (/.succeed expected)) + (/.to_maybe (/.fail error))] [(#.Some actual) #.None] (n.= expected actual) diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index ce286a113..3d828dbb2 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -51,24 +51,24 @@ (#try.Success _) false)) -(def: (binary-io bytes read write value) +(def: (binary_io bytes read write value) (-> Nat (-> Nat Binary (Try Nat)) (-> Nat Nat Binary (Try Any)) Nat Bit) (let [binary (/.create bytes) cap (case bytes 8 (dec 0) - _ (|> 1 (i64.left-shift (n.* 8 bytes)) dec)) - capped-value (i64.and cap value)] + _ (|> 1 (i64.left_shift (n.* 8 bytes)) dec)) + capped_value (i64.and cap value)] (and (succeed (do try.monad [pre (read 0 binary) _ (write 0 value binary) post (read 0 binary)] (wrap (and (n.= 0 pre) - (n.= capped-value post))))) - (throws? /.index-out-of-bounds (read 1 binary)) - (throws? /.index-out-of-bounds (write 1 value binary))))) + (n.= capped_value post))))) + (throws? /.index_out_of_bounds (read 1 binary)) + (throws? /.index_out_of_bounds (write 1 value binary))))) -(def: as-list +(def: as_list (-> /.Binary (List Nat)) (/.fold (function (_ head tail) (#.Cons head tail)) @@ -78,12 +78,12 @@ Test (<| (_.covering /._) (do {! random.monad} - [#let [gen-size (|> random.nat (\ ! map (|>> (n.% 100) (n.max 8))))] - size gen-size + [#let [gen_size (|> random.nat (\ ! map (|>> (n.% 100) (n.max 8))))] + size gen_size sample (..random size) value random.nat - #let [gen-idx (|> random.nat (\ ! map (n.% size)))] - [from to] (random.and gen-idx gen-idx) + #let [gen_idx (|> random.nat (\ ! map (n.% size)))] + [from to] (random.and gen_idx gen_idx) #let [[from to] [(n.min from to) (n.max from to)]]] (_.for [/.Binary] ($_ _.and @@ -92,7 +92,7 @@ (_.for [/.monoid] ($monoid.spec /.equivalence /.monoid (..random size))) (_.cover [/.fold] - (n.= (\ list.fold fold n.+ 0 (..as-list sample)) + (n.= (\ list.fold fold n.+ 0 (..as_list sample)) (/.fold n.+ 0 sample))) (_.cover [/.create] @@ -101,39 +101,39 @@ (/.create size))) (_.cover [/.size] (|> (/.create size) /.size (n.= size))) - (_.for [/.index-out-of-bounds] + (_.for [/.index_out_of_bounds] ($_ _.and (_.cover [/.read/8 /.write/8] - (..binary-io 1 /.read/8 /.write/8 value)) + (..binary_io 1 /.read/8 /.write/8 value)) (_.cover [/.read/16 /.write/16] - (..binary-io 2 /.read/16 /.write/16 value)) + (..binary_io 2 /.read/16 /.write/16 value)) (_.cover [/.read/32 /.write/32] - (..binary-io 4 /.read/32 /.write/32 value)) + (..binary_io 4 /.read/32 /.write/32 value)) (_.cover [/.read/64 /.write/64] - (..binary-io 8 /.read/64 /.write/64 value)))) + (..binary_io 8 /.read/64 /.write/64 value)))) (_.cover [/.slice] - (let [slice-size (|> to (n.- from) inc) - random-slice (try.assume (/.slice from to sample)) - idxs (enum.range n.enum 0 (dec slice-size)) + (let [slice_size (|> to (n.- from) inc) + random_slice (try.assume (/.slice from to sample)) + idxs (enum.range n.enum 0 (dec slice_size)) reader (function (_ binary idx) (/.read/8 idx binary))] - (and (n.= slice-size (/.size random-slice)) - (case [(monad.map try.monad (reader random-slice) idxs) + (and (n.= slice_size (/.size random_slice)) + (case [(monad.map try.monad (reader random_slice) idxs) (monad.map try.monad (|>> (n.+ from) (reader sample)) idxs)] - [(#try.Success slice-vals) (#try.Success binary-vals)] - (\ (list.equivalence n.equivalence) = slice-vals binary-vals) + [(#try.Success slice_vals) (#try.Success binary_vals)] + (\ (list.equivalence n.equivalence) = slice_vals binary_vals) _ #0)))) - (_.cover [/.slice-out-of-bounds] - (and (throws? /.slice-out-of-bounds (/.slice size size sample)) - (throws? /.slice-out-of-bounds (/.slice from size sample)))) - (_.cover [/.inverted-slice] - (or (throws? /.inverted-slice (/.slice to from sample)) + (_.cover [/.slice_out_of_bounds] + (and (throws? /.slice_out_of_bounds (/.slice size size sample)) + (throws? /.slice_out_of_bounds (/.slice from size sample)))) + (_.cover [/.inverted_slice] + (or (throws? /.inverted_slice (/.slice to from sample)) (n.= to from))) (_.cover [/.drop] (and (\ /.equivalence = sample (/.drop 0 sample)) (\ /.equivalence = (/.create 0) (/.drop size sample)) - (case (list.reverse (..as-list sample)) + (case (list.reverse (..as_list sample)) #.Nil false diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index d47defeaf..ab1b1f04c 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -26,9 +26,9 @@ (def: injection (Injection Array) - (|>> list /.from-list)) + (|>> list /.from_list)) -(def: bounded-size +(def: bounded_size (Random Nat) (\ random.monad map (|>> (n.% 100) (n.+ 1)) random.nat)) @@ -36,7 +36,7 @@ (def: structures Test (do {! random.monad} - [size ..bounded-size] + [size ..bounded_size] ($_ _.and (_.for [/.equivalence] ($equivalence.spec (/.equivalence n.equivalence) (random.array size random.nat))) @@ -51,23 +51,23 @@ (def: search Test (do {! random.monad} - [size ..bounded-size + [size ..bounded_size base random.nat shift random.nat #let [expected (n.+ base shift)] - the-array (random.array size random.nat)] + the_array (random.array size random.nat)] ($_ _.and (_.cover [/.find] (\ (maybe.equivalence n.equivalence) = - (/.find n.even? the-array) - (list.find n.even? (/.to-list the-array)))) + (/.find n.even? the_array) + (list.find n.even? (/.to_list the_array)))) (_.cover [/.find+] - (case [(/.find n.even? the-array) + (case [(/.find n.even? the_array) (/.find+ (function (_ idx member) (n.even? member)) - the-array)] + the_array)] [(#.Some expected) (#.Some [idx actual])] - (case (/.read idx the-array) + (case (/.read idx the_array) (#.Some again) (and (n.= expected actual) (n.= actual again)) @@ -79,12 +79,12 @@ true)) (_.cover [/.every?] (\ bit.equivalence = - (list.every? n.even? (/.to-list the-array)) - (/.every? n.even? the-array))) + (list.every? n.even? (/.to_list the_array)) + (/.every? n.even? the_array))) (_.cover [/.any?] (\ bit.equivalence = - (list.any? n.even? (/.to-list the-array)) - (/.any? n.even? the-array))) + (list.any? n.even? (/.to_list the_array)) + (/.any? n.even? the_array))) ))) (def: #export test @@ -92,12 +92,12 @@ (<| (_.covering /._) (_.for [/.Array]) (do {! random.monad} - [size ..bounded-size + [size ..bounded_size base random.nat shift random.nat dummy (random.filter (|>> (n.= base) not) random.nat) #let [expected (n.+ base shift)] - the-array (random.array size random.nat)] + the_array (random.array size random.nat)] ($_ _.and ..structures ..search @@ -105,61 +105,61 @@ (_.cover [/.new /.size] (n.= size (/.size (: (Array Nat) (/.new size))))) - (_.cover [/.type-name] + (_.cover [/.type_name] (case (:of (/.new size)) - (^ (#.UnivQ _ (#.Apply _ (#.Named _ (#.UnivQ _ (#.Primitive nominal-type (list (#.Parameter 1)))))))) - (text\= /.type-name nominal-type) + (^ (#.UnivQ _ (#.Apply _ (#.Named _ (#.UnivQ _ (#.Primitive nominal_type (list (#.Parameter 1)))))))) + (text\= /.type_name nominal_type) _ false)) (_.cover [/.read /.write!] - (let [the-array (|> (/.new 2) + (let [the_array (|> (/.new 2) (: (Array Nat)) (/.write! 0 expected))] - (case [(/.read 0 the-array) - (/.read 1 the-array)] + (case [(/.read 0 the_array) + (/.read 1 the_array)] [(#.Some actual) #.None] (n.= expected actual) _ false))) (_.cover [/.delete!] - (let [the-array (|> (/.new 1) + (let [the_array (|> (/.new 1) (: (Array Nat)) (/.write! 0 expected))] - (case [(/.read 0 the-array) - (/.read 0 (/.delete! 0 the-array))] + (case [(/.read 0 the_array) + (/.read 0 (/.delete! 0 the_array))] [(#.Some actual) #.None] (n.= expected actual) _ false))) (_.cover [/.contains?] - (let [the-array (|> (/.new 2) + (let [the_array (|> (/.new 2) (: (Array Nat)) (/.write! 0 expected))] - (and (/.contains? 0 the-array) - (not (/.contains? 1 the-array))))) + (and (/.contains? 0 the_array) + (not (/.contains? 1 the_array))))) (_.cover [/.update!] - (let [the-array (|> (/.new 1) + (let [the_array (|> (/.new 1) (: (Array Nat)) (/.write! 0 base) (/.update! 0 (n.+ shift)))] - (case (/.read 0 the-array) + (case (/.read 0 the_array) (#.Some actual) (n.= expected actual) _ false))) (_.cover [/.upsert!] - (let [the-array (|> (/.new 2) + (let [the_array (|> (/.new 2) (: (Array Nat)) (/.write! 0 base) (/.upsert! 0 dummy (n.+ shift)) (/.upsert! 1 base (n.+ shift)))] - (case [(/.read 0 the-array) - (/.read 1 the-array)] + (case [(/.read 0 the_array) + (/.read 1 the_array)] [(#.Some actual/0) (#.Some actual/1)] (and (n.= expected actual/0) (n.= expected actual/1)) @@ -169,55 +169,55 @@ (do ! [occupancy (\ ! map (n.% (inc size)) random.nat)] (_.cover [/.occupancy /.vacancy] - (let [the-array (loop [output (: (Array Nat) + (let [the_array (loop [output (: (Array Nat) (/.new size)) idx 0] (if (n.< occupancy idx) (recur (/.write! idx expected output) (inc idx)) output))] - (and (n.= occupancy (/.occupancy the-array)) - (n.= size (n.+ (/.occupancy the-array) - (/.vacancy the-array))))))) + (and (n.= occupancy (/.occupancy the_array)) + (n.= size (n.+ (/.occupancy the_array) + (/.vacancy the_array))))))) (do ! - [the-list (random.list size random.nat)] - (_.cover [/.from-list /.to-list] - (and (|> the-list /.from-list /.to-list - (\ (list.equivalence n.equivalence) = the-list)) - (|> the-array /.to-list /.from-list - (\ (/.equivalence n.equivalence) = the-array))))) + [the_list (random.list size random.nat)] + (_.cover [/.from_list /.to_list] + (and (|> the_list /.from_list /.to_list + (\ (list.equivalence n.equivalence) = the_list)) + (|> the_array /.to_list /.from_list + (\ (/.equivalence n.equivalence) = the_array))))) (do ! [amount (\ ! map (n.% (inc size)) random.nat)] (_.cover [/.copy!] (let [copy (: (Array Nat) (/.new size))] - (exec (/.copy! amount 0 the-array 0 copy) + (exec (/.copy! amount 0 the_array 0 copy) (\ (list.equivalence n.equivalence) = - (list.take amount (/.to-list the-array)) - (/.to-list copy)))))) + (list.take amount (/.to_list the_array)) + (/.to_list copy)))))) (_.cover [/.clone] - (let [clone (/.clone the-array)] - (and (not (is? the-array clone)) - (\ (/.equivalence n.equivalence) = the-array clone)))) - (let [the-array (/.clone the-array) - evens (|> the-array /.to-list (list.filter n.even?)) - odds (|> the-array /.to-list (list.filter n.odd?))] + (let [clone (/.clone the_array)] + (and (not (is? the_array clone)) + (\ (/.equivalence n.equivalence) = the_array clone)))) + (let [the_array (/.clone the_array) + evens (|> the_array /.to_list (list.filter n.even?)) + odds (|> the_array /.to_list (list.filter n.odd?))] (_.cover [/.filter!] - (exec (/.filter! n.even? the-array) - (and (n.= (list.size evens) (/.occupancy the-array)) - (n.= (list.size odds) (/.vacancy the-array)) - (|> the-array /.to-list (\ (list.equivalence n.equivalence) = evens)))))) + (exec (/.filter! n.even? the_array) + (and (n.= (list.size evens) (/.occupancy the_array)) + (n.= (list.size odds) (/.vacancy the_array)) + (|> the_array /.to_list (\ (list.equivalence n.equivalence) = evens)))))) (do ! - [#let [the-array (/.clone the-array) - members (|> the-array /.to-list (set.from-list n.hash))] + [#let [the_array (/.clone the_array) + members (|> the_array /.to_list (set.from_list n.hash))] default (random.filter (function (_ value) (not (or (n.even? value) (set.member? members value)))) random.nat)] - (_.cover [/.to-list'] - (exec (/.filter! n.even? the-array) + (_.cover [/.to_list'] + (exec (/.filter! n.even? the_array) (list.every? (function (_ value) (or (n.even? value) (is? default value))) - (/.to-list' default the-array))))) + (/.to_list' default the_array))))) )))) diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux index 2080e387a..0de661e64 100644 --- a/stdlib/source/test/lux/data/collection/dictionary.lux +++ b/stdlib/source/test/lux/data/collection/dictionary.lux @@ -25,17 +25,17 @@ (def: injection (Injection (/.Dictionary Nat)) - (|>> [0] list (/.from-list n.hash))) + (|>> [0] list (/.from_list n.hash))) -(def: for-dictionaries +(def: for_dictionaries Test (do {! random.monad} - [#let [capped-nat (\ random.monad map (n.% 100) random.nat)] - size capped-nat - dict (random.dictionary n.hash size random.nat capped-nat) - non-key (random.filter (|>> (/.key? dict) not) + [#let [capped_nat (\ random.monad map (n.% 100) random.nat)] + size capped_nat + dict (random.dictionary n.hash size random.nat capped_nat) + non_key (random.filter (|>> (/.key? dict) not) random.nat) - test-val (random.filter (|>> (list.member? n.equivalence (/.values dict)) not) + test_val (random.filter (|>> (list.member? n.equivalence (/.values dict)) not) random.nat)] ($_ _.and (_.cover [/.size] @@ -58,8 +58,8 @@ (def: &equivalence n.equivalence) (def: (hash _) constant)))]] - (_.cover [/.key-hash] - (is? hash (/.key-hash (/.new hash))))) + (_.cover [/.key_hash] + (is? hash (/.key_hash (/.new hash))))) (_.cover [/.entries /.keys /.values] (\ (list.equivalence (product.equivalence n.equivalence n.equivalence)) = @@ -68,36 +68,36 @@ (/.values dict)))) (_.cover [/.merge] - (let [merging-with-oneself (let [(^open ".") (/.equivalence n.equivalence)] + (let [merging_with_oneself (let [(^open ".") (/.equivalence n.equivalence)] (= dict (/.merge dict dict))) - overwritting-keys (let [dict' (|> dict /.entries + overwritting_keys (let [dict' (|> dict /.entries (list\map (function (_ [k v]) [k (inc v)])) - (/.from-list n.hash)) + (/.from_list n.hash)) (^open ".") (/.equivalence n.equivalence)] (= dict' (/.merge dict' dict)))] - (and merging-with-oneself - overwritting-keys))) + (and merging_with_oneself + overwritting_keys))) - (_.cover [/.merge-with] + (_.cover [/.merge_with] (list.every? (function (_ [x x*2]) (n.= (n.* 2 x) x*2)) (list.zip/2 (/.values dict) - (/.values (/.merge-with n.+ dict dict))))) + (/.values (/.merge_with n.+ dict dict))))) - (_.cover [/.from-list] + (_.cover [/.from_list] (let [(^open ".") (/.equivalence n.equivalence)] (and (= dict dict) - (|> dict /.entries (/.from-list n.hash) (= dict))))) + (|> dict /.entries (/.from_list n.hash) (= dict))))) ))) -(def: for-entries +(def: for_entries Test (do random.monad - [#let [capped-nat (\ random.monad map (n.% 100) random.nat)] - size capped-nat - dict (random.dictionary n.hash size random.nat capped-nat) - non-key (random.filter (|>> (/.key? dict) not) + [#let [capped_nat (\ random.monad map (n.% 100) random.nat)] + size capped_nat + dict (random.dictionary n.hash size random.nat capped_nat) + non_key (random.filter (|>> (/.key? dict) not) random.nat) - test-val (random.filter (|>> (list.member? n.equivalence (/.values dict)) not) + test_val (random.filter (|>> (list.member? n.equivalence (/.values dict)) not) random.nat)] ($_ _.and (_.cover [/.key?] @@ -109,56 +109,56 @@ (#.Some _) true _ false)) (/.keys dict)) - (case (/.get non-key dict) + (case (/.get non_key dict) (#.Some _) false _ true))) (_.cover [/.put] (and (n.= (inc (/.size dict)) - (/.size (/.put non-key test-val dict))) - (case (/.get non-key (/.put non-key test-val dict)) - (#.Some v) (n.= test-val v) + (/.size (/.put non_key test_val dict))) + (case (/.get non_key (/.put non_key test_val dict)) + (#.Some v) (n.= test_val v) _ true))) - (_.cover [/.try-put /.key-already-exists] - (let [can-put-new-keys! - (case (/.try-put non-key test-val dict) + (_.cover [/.try_put /.key_already_exists] + (let [can_put_new_keys! + (case (/.try_put non_key test_val dict) (#try.Success dict) - (case (/.get non-key dict) - (#.Some v) (n.= test-val v) + (case (/.get non_key dict) + (#.Some v) (n.= test_val v) _ true) (#try.Failure _) false) - cannot-put-old-keys! + cannot_put_old_keys! (or (n.= 0 size) - (let [first-key (|> dict /.keys list.head maybe.assume)] - (case (/.try-put first-key test-val dict) + (let [first_key (|> dict /.keys list.head maybe.assume)] + (case (/.try_put first_key test_val dict) (#try.Success _) false (#try.Failure error) - (exception.match? /.key-already-exists error))))] - (and can-put-new-keys! - cannot-put-old-keys!))) + (exception.match? /.key_already_exists error))))] + (and can_put_new_keys! + cannot_put_old_keys!))) (_.cover [/.remove] - (and (let [base (/.put non-key test-val dict)] - (and (/.key? base non-key) - (not (/.key? (/.remove non-key base) non-key)))) + (and (let [base (/.put non_key test_val dict)] + (and (/.key? base non_key) + (not (/.key? (/.remove non_key base) non_key)))) (case (list.head (/.keys dict)) #.None true - (#.Some known-key) + (#.Some known_key) (n.= (dec (/.size dict)) - (/.size (/.remove known-key dict)))))) + (/.size (/.remove known_key dict)))))) (_.cover [/.update] - (let [base (/.put non-key test-val dict) - updt (/.update non-key inc base)] - (case [(/.get non-key base) (/.get non-key updt)] + (let [base (/.put non_key test_val dict) + updt (/.update non_key inc base)] + (case [(/.get non_key base) (/.get non_key updt)] [(#.Some x) (#.Some y)] (n.= (inc x) y) @@ -166,45 +166,45 @@ false))) (_.cover [/.upsert] - (let [can-upsert-new-key! - (case (/.get non-key (/.upsert non-key test-val inc dict)) + (let [can_upsert_new_key! + (case (/.get non_key (/.upsert non_key test_val inc dict)) (#.Some inserted) - (n.= (inc test-val) inserted) + (n.= (inc test_val) inserted) #.None false) - can-upsert-old-key! + can_upsert_old_key! (case (list.head (/.entries dict)) #.None true - (#.Some [known-key known-value]) - (case (/.get known-key (/.upsert known-key test-val inc dict)) + (#.Some [known_key known_value]) + (case (/.get known_key (/.upsert known_key test_val inc dict)) (#.Some updated) - (n.= (inc known-value) updated) + (n.= (inc known_value) updated) #.None false))] - (and can-upsert-new-key! - can-upsert-old-key!))) + (and can_upsert_new_key! + can_upsert_old_key!))) (_.cover [/.select] (|> dict - (/.put non-key test-val) - (/.select (list non-key)) + (/.put non_key test_val) + (/.select (list non_key)) /.size (n.= 1))) - (_.cover [/.re-bind] + (_.cover [/.re_bind] (or (n.= 0 size) - (let [first-key (|> dict /.keys list.head maybe.assume) - rebound (/.re-bind first-key non-key dict)] + (let [first_key (|> dict /.keys list.head maybe.assume) + rebound (/.re_bind first_key non_key dict)] (and (n.= (/.size dict) (/.size rebound)) - (/.key? rebound non-key) - (not (/.key? rebound first-key)) - (n.= (maybe.assume (/.get first-key dict)) - (maybe.assume (/.get non-key rebound))))))) + (/.key? rebound non_key) + (not (/.key? rebound first_key)) + (n.= (maybe.assume (/.get first_key dict)) + (maybe.assume (/.get non_key rebound))))))) ))) (def: #export test @@ -212,12 +212,12 @@ (<| (_.covering /._) (_.for [/.Dictionary]) (do random.monad - [#let [capped-nat (\ random.monad map (n.% 100) random.nat)] - size capped-nat - dict (random.dictionary n.hash size random.nat capped-nat) - non-key (random.filter (|>> (/.key? dict) not) + [#let [capped_nat (\ random.monad map (n.% 100) random.nat)] + size capped_nat + dict (random.dictionary n.hash size random.nat capped_nat) + non_key (random.filter (|>> (/.key? dict) not) random.nat) - test-val (random.filter (|>> (list.member? n.equivalence (/.values dict)) not) + test_val (random.filter (|>> (list.member? n.equivalence (/.values dict)) not) random.nat)] ($_ _.and (_.for [/.equivalence] @@ -227,6 +227,6 @@ (_.for [/.functor] ($functor.spec ..injection /.equivalence /.functor)) - ..for-dictionaries - ..for-entries + ..for_dictionaries + ..for_entries )))) diff --git a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux index 1553f2266..a44b5c295 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux @@ -22,7 +22,7 @@ {1 ["." /]}) -(def: #export (dictionary order gen-key gen-value size) +(def: #export (dictionary order gen_key gen_value size) (All [k v] (-> (Order k) (Random k) (Random v) Nat (Random (/.Dictionary k v)))) (case size @@ -31,10 +31,10 @@ _ (do random.monad - [partial (dictionary order gen-key gen-value (dec size)) + [partial (dictionary order gen_key gen_value (dec size)) key (random.filter (|>> (/.key? partial) not) - gen-key) - value gen-value] + gen_key) + value gen_value] (wrap (/.put key value partial))))) (def: #export test @@ -45,17 +45,17 @@ [size (\ ! map (n.% 100) random.nat) keys (random.set n.hash size random.nat) values (random.set n.hash size random.nat) - extra-key (random.filter (|>> (set.member? keys) not) + extra_key (random.filter (|>> (set.member? keys) not) random.nat) - extra-value random.nat + extra_value random.nat shift random.nat - #let [pairs (list.zip/2 (set.to-list keys) - (set.to-list values)) - sample (/.from-list n.order pairs) - sorted-pairs (list.sort (function (_ [left _] [right _]) + #let [pairs (list.zip/2 (set.to_list keys) + (set.to_list values)) + sample (/.from_list n.order pairs) + sorted_pairs (list.sort (function (_ [left _] [right _]) (n.< left right)) pairs) - sorted-values (list\map product.right sorted-pairs) + sorted_values (list\map product.right sorted_pairs) (^open "list\.") (list.equivalence (: (Equivalence [Nat Nat]) (function (_ [kr vr] [ks vs]) (and (n.= kr ks) @@ -73,7 +73,7 @@ (_.cover [/.new] (/.empty? (/.new n.order))) (_.cover [/.min] - (case [(/.min sample) (list.head sorted-values)] + (case [(/.min sample) (list.head sorted_values)] [#.None #.None] #1 @@ -83,7 +83,7 @@ _ #0)) (_.cover [/.max] - (case [(/.max sample) (list.last sorted-values)] + (case [(/.max sample) (list.last sorted_values)] [#.None #.None] #1 @@ -94,43 +94,43 @@ #0)) (_.cover [/.entries] (list\= (/.entries sample) - sorted-pairs)) + sorted_pairs)) (_.cover [/.keys /.values] (list\= (/.entries sample) (list.zip/2 (/.keys sample) (/.values sample)))) - (_.cover [/.from-list] + (_.cover [/.from_list] (|> sample - /.entries (/.from-list n.order) + /.entries (/.from_list n.order) (/\= sample))) (_.cover [/.key?] (and (list.every? (/.key? sample) (/.keys sample)) - (not (/.key? sample extra-key)))) + (not (/.key? sample extra_key)))) (_.cover [/.put] - (and (not (/.key? sample extra-key)) - (let [sample+ (/.put extra-key extra-value sample)] - (and (/.key? sample+ extra-key) + (and (not (/.key? sample extra_key)) + (let [sample+ (/.put extra_key extra_value sample)] + (and (/.key? sample+ extra_key) (n.= (inc (/.size sample)) (/.size sample+)))))) (_.cover [/.get] - (let [sample+ (/.put extra-key extra-value sample)] - (case [(/.get extra-key sample) - (/.get extra-key sample+)] + (let [sample+ (/.put extra_key extra_value sample)] + (case [(/.get extra_key sample) + (/.get extra_key sample+)] [#.None (#.Some actual)] - (n.= extra-value actual) + (n.= extra_value actual) _ false))) (_.cover [/.remove] (|> sample - (/.put extra-key extra-value) - (/.remove extra-key) + (/.put extra_key extra_value) + (/.remove extra_key) (/\= sample))) (_.cover [/.update] (|> sample - (/.put extra-key extra-value) - (/.update extra-key (n.+ shift)) - (/.get extra-key) - (maybe\map (n.= (n.+ shift extra-value))) + (/.put extra_key extra_value) + (/.update extra_key (n.+ shift)) + (/.get extra_key) + (maybe\map (n.= (n.+ shift extra_value))) (maybe.default false))) )))) diff --git a/stdlib/source/test/lux/data/collection/dictionary/plist.lux b/stdlib/source/test/lux/data/collection/dictionary/plist.lux index 2a92e28db..753b8db8a 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/plist.lux @@ -20,32 +20,32 @@ {1 ["." /]}) -(def: #export (random size gen-key gen-value) +(def: #export (random size gen_key gen_value) (All [v] (-> Nat (Random Text) (Random v) (Random (/.PList v)))) (do random.monad - [keys (random.set text.hash size gen-key) - values (random.list size gen-value)] - (wrap (list.zip/2 (set.to-list keys) values)))) + [keys (random.set text.hash size gen_key) + values (random.list size gen_value)] + (wrap (list.zip/2 (set.to_list keys) values)))) (def: #export test Test (<| (_.covering /._) (_.for [/.PList]) (do {! random.monad} - [#let [gen-key (random.ascii/alpha 10)] + [#let [gen_key (random.ascii/alpha 10)] size (\ ! map (n.% 100) random.nat) - sample (..random size gen-key random.nat) + sample (..random size gen_key random.nat) - #let [keys (|> sample /.keys (set.from-list text.hash))] - extra-key (random.filter (|>> (set.member? keys) not) - gen-key) - extra-value random.nat + #let [keys (|> sample /.keys (set.from_list text.hash))] + extra_key (random.filter (|>> (set.member? keys) not) + gen_key) + extra_value random.nat shift random.nat] ($_ _.and (_.for [/.equivalence] ($equivalence.spec (/.equivalence n.equivalence) - (..random size gen-key random.nat))) + (..random size gen_key random.nat))) (_.cover [/.size] (n.= size (/.size sample))) @@ -63,29 +63,29 @@ (and (list.every? (function (_ key) (/.contains? key sample)) (/.keys sample)) - (not (/.contains? extra-key sample)))) + (not (/.contains? extra_key sample)))) (_.cover [/.put] - (let [sample+ (/.put extra-key extra-value sample)] - (and (not (/.contains? extra-key sample)) - (/.contains? extra-key sample+) + (let [sample+ (/.put extra_key extra_value sample)] + (and (not (/.contains? extra_key sample)) + (/.contains? extra_key sample+) (n.= (inc (/.size sample)) (/.size sample+))))) (_.cover [/.get] (|> sample - (/.put extra-key extra-value) - (/.get extra-key) - (maybe\map (n.= extra-value)) + (/.put extra_key extra_value) + (/.get extra_key) + (maybe\map (n.= extra_value)) (maybe.default false))) (_.cover [/.update] (|> sample - (/.put extra-key extra-value) - (/.update extra-key (n.+ shift)) - (/.get extra-key) - (maybe\map (n.= (n.+ shift extra-value))) + (/.put extra_key extra_value) + (/.update extra_key (n.+ shift)) + (/.get extra_key) + (maybe\map (n.= (n.+ shift extra_value))) (maybe.default false))) (_.cover [/.remove] (|> sample - (/.put extra-key extra-value) - (/.remove extra-key) + (/.put extra_key extra_value) + (/.remove extra_key) (\ (/.equivalence n.equivalence) = sample))) )))) diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index ffde9bcf4..b2d35b1f4 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -31,7 +31,7 @@ {1 ["." / ("#\." monad)]}) -(def: bounded-size +(def: bounded_size (Random Nat) (\ random.monad map (n.% 100) random.nat)) @@ -39,10 +39,10 @@ (def: random (Random (List Nat)) (do {! random.monad} - [size ..bounded-size] + [size ..bounded_size] (|> random.nat (random.set n.hash size) - (\ ! map set.to-list)))) + (\ ! map set.to_list)))) (def: signatures Test @@ -81,9 +81,9 @@ (def: whole Test (do {! random.monad} - [size ..bounded-size + [size ..bounded_size #let [(^open "/\.") (/.equivalence n.equivalence)] - sample (\ ! map set.to-list (random.set n.hash size random.nat))] + sample (\ ! map set.to_list (random.set n.hash size random.nat))] ($_ _.and (_.cover [/.size] (n.= size (/.size sample))) @@ -95,15 +95,15 @@ (n.= size (/.size (/.repeat size [])))) (_.cover [/.reverse] (or (n.< 2 (/.size sample)) - (let [not-same! + (let [not_same! (not (/\= sample (/.reverse sample))) - self-symmetry! + self_symmetry! (/\= sample (/.reverse (/.reverse sample)))] - (and not-same! - self-symmetry!)))) + (and not_same! + self_symmetry!)))) (_.cover [/.every? /.any?] (if (/.every? n.even? sample) (not (/.any? (bit.complement n.even?) sample)) @@ -111,14 +111,14 @@ (_.cover [/.sort] (let [<<< n.< - size-preservation! + size_preservation! (n.= (/.size sample) (/.size (/.sort <<< sample))) symmetry! (/\= (/.sort <<< sample) (/.reverse (/.sort (function.flip <<<) sample)))] - (and size-preservation! + (and size_preservation! symmetry!))) ))) @@ -133,33 +133,33 @@ (_.cover [/.indices] (let [indices (/.indices size) - expected-amount! + expected_amount! (n.= size (/.size indices)) - already-sorted! + already_sorted! (/\= indices (/.sort n.< indices)) - expected-numbers! + expected_numbers! (/.every? (n.= (dec size)) - (/.zip-with/2 n.+ + (/.zip_with/2 n.+ indices (/.sort n.> indices)))] - (and expected-amount! - already-sorted! - expected-numbers!))) + (and expected_amount! + already_sorted! + expected_numbers!))) (_.cover [/.enumeration] (let [enumeration (/.enumeration sample) - has-correct-indices! + has_correct_indices! (/\= (/.indices (/.size enumeration)) (/\map product.left enumeration)) - has-correct-values! + has_correct_values! (/\= sample (/\map product.right enumeration))] - (and has-correct-indices! - has-correct-values!))) + (and has_correct_indices! + has_correct_values!))) (_.cover [/.nth] (/.every? (function (_ [index expected]) (case (/.nth index sample) @@ -180,7 +180,7 @@ ..random) #let [size (/.size sample)] idx (\ ! map (n.% size) random.nat) - chunk-size (\ ! map (|>> (n.% size) inc) random.nat)] + chunk_size (\ ! map (|>> (n.% size) inc) random.nat)] ($_ _.and (_.cover [/.filter] (let [positives (/.filter n.even? sample) @@ -201,21 +201,21 @@ (let [[left right] (/.split idx sample)] (/\= sample (/\compose left right)))) - (_.cover [/.split-with] - (let [[left right] (/.split-with n.even? sample)] + (_.cover [/.split_with] + (let [[left right] (/.split_with n.even? sample)] (/\= sample (/\compose left right)))) (_.cover [/.take /.drop] (/\= sample (/\compose (/.take idx sample) (/.drop idx sample)))) - (_.cover [/.take-while /.drop-while] + (_.cover [/.take_while /.drop_while] (/\= sample - (/\compose (/.take-while n.even? sample) - (/.drop-while n.even? sample)))) + (/\compose (/.take_while n.even? sample) + (/.drop_while n.even? sample)))) (_.cover [/.chunk] - (let [chunks (/.chunk chunk-size sample)] - (and (/.every? (|>> /.size (n.<= chunk-size)) chunks) + (let [chunks (/.chunk chunk_size sample)] + (and (/.every? (|>> /.size (n.<= chunk_size)) chunks) (/\= sample (/.concat chunks))))) )))) @@ -275,44 +275,44 @@ sample/1 ..random sample/2 ..random] ($_ _.and - (_.cover [/.as-pairs] + (_.cover [/.as_pairs] (n.= (n./ 2 (/.size sample/0)) - (/.size (/.as-pairs sample/0)))) + (/.size (/.as_pairs sample/0)))) (_.cover [/.zip/2] (let [zipped (/.zip/2 sample/0 sample/1) zipped::size (/.size zipped) - size-of-smaller-list! + size_of_smaller_list! (n.= zipped::size (n.min (/.size sample/0) (/.size sample/1))) - can-extract-values! + can_extract_values! (and (/\= (/.take zipped::size sample/0) (/\map product.left zipped)) (/\= (/.take zipped::size sample/1) (/\map product.right zipped)))] - (and size-of-smaller-list! - can-extract-values!))) + (and size_of_smaller_list! + can_extract_values!))) (_.cover [/.zip/3] (let [zipped (/.zip/3 sample/0 sample/1 sample/2) zipped::size (/.size zipped) - size-of-smaller-list! + size_of_smaller_list! (n.= zipped::size ($_ n.min (/.size sample/0) (/.size sample/1) (/.size sample/2))) - can-extract-values! + can_extract_values! (and (/\= (/.take zipped::size sample/0) (/\map product.left zipped)) (/\= (/.take zipped::size sample/1) (/\map (|>> product.right product.left) zipped)) (/\= (/.take zipped::size sample/2) (/\map (|>> product.right product.right) zipped)))] - (and size-of-smaller-list! - can-extract-values!))) + (and size_of_smaller_list! + can_extract_values!))) (_.cover [/.zip] (and (\ (/.equivalence (product.equivalence n.equivalence n.equivalence)) = (/.zip/2 sample/0 sample/1) @@ -321,21 +321,21 @@ (/.zip/3 sample/0 sample/1 sample/2) ((/.zip 3) sample/0 sample/1 sample/2)))) - (_.cover [/.zip-with/2] + (_.cover [/.zip_with/2] (/\= (/\map (function (_ [left right]) (+/2 left right)) (/.zip/2 sample/0 sample/1)) - (/.zip-with/2 +/2 sample/0 sample/1))) - (_.cover [/.zip-with/3] + (/.zip_with/2 +/2 sample/0 sample/1))) + (_.cover [/.zip_with/3] (/\= (/\map (function (_ [left mid right]) (+/3 left mid right)) (/.zip/3 sample/0 sample/1 sample/2)) - (/.zip-with/3 +/3 sample/0 sample/1 sample/2))) - (_.cover [/.zip-with] - (and (/\= (/.zip-with/2 +/2 sample/0 sample/1) - ((/.zip-with 2) +/2 sample/0 sample/1)) - (/\= (/.zip-with/3 +/3 sample/0 sample/1 sample/2) - ((/.zip-with 3) +/3 sample/0 sample/1 sample/2)))) + (/.zip_with/3 +/3 sample/0 sample/1 sample/2))) + (_.cover [/.zip_with] + (and (/\= (/.zip_with/2 +/2 sample/0 sample/1) + ((/.zip_with 2) +/2 sample/0 sample/1)) + (/\= (/.zip_with/3 +/3 sample/0 sample/1 sample/2) + ((/.zip_with 3) +/3 sample/0 sample/1 sample/2)))) (_.cover [/.concat] (and (/\= (/\compose sample/0 sample/1) (/.concat (list sample/0 sample/1))) @@ -407,7 +407,7 @@ (let [sample+ (/.interpose separator sample)] (and (n.= (|> (/.size sample) (n.* 2) dec) (/.size sample+)) - (|> sample+ /.as-pairs (/.every? (|>> product.right (n.= separator)))))))) + (|> sample+ /.as_pairs (/.every? (|>> product.right (n.= separator)))))))) (_.cover [/.iterate] (or (/.empty? sample) (let [size (/.size sample)] diff --git a/stdlib/source/test/lux/data/collection/queue.lux b/stdlib/source/test/lux/data/collection/queue.lux index aed90ebf9..3e532a66e 100644 --- a/stdlib/source/test/lux/data/collection/queue.lux +++ b/stdlib/source/test/lux/data/collection/queue.lux @@ -22,7 +22,7 @@ (def: injection (Injection /.Queue) - (|>> list /.from-list)) + (|>> list /.from_list)) (def: #export test Test @@ -31,34 +31,34 @@ (do {! random.monad} [size (\ ! map (n.% 100) random.nat) members (random.set n.hash size random.nat) - non-member (random.filter (|>> (set.member? members) not) + non_member (random.filter (|>> (set.member? members) not) random.nat) - #let [members (set.to-list members) - sample (/.from-list members)]] + #let [members (set.to_list members) + sample (/.from_list members)]] ($_ _.and (_.for [/.equivalence] ($equivalence.spec (/.equivalence n.equivalence) (random.queue size random.nat))) (_.for [/.functor] ($functor.spec ..injection /.equivalence /.functor)) - (_.cover [/.from-list /.to-list] - (|> members /.from-list /.to-list + (_.cover [/.from_list /.to_list] + (|> members /.from_list /.to_list (\ (list.equivalence n.equivalence) = members))) (_.cover [/.size] (n.= size (/.size sample))) (_.cover [/.empty?] (bit\= (n.= 0 size) (/.empty? sample))) (_.cover [/.empty] - (let [empty-is-empty! + (let [empty_is_empty! (/.empty? /.empty) - all-empty-queues-look-the-same! + all_empty_queues_look_the_same! (bit\= (/.empty? sample) (\ (/.equivalence n.equivalence) = sample /.empty))] - (and empty-is-empty! - all-empty-queues-look-the-same!))) + (and empty_is_empty! + all_empty_queues_look_the_same!))) (_.cover [/.peek] (case [members (/.peek sample)] [(#.Cons head tail) (#.Some first)] @@ -70,49 +70,49 @@ _ false)) (_.cover [/.member?] - (let [every-member-is-identified! + (let [every_member_is_identified! (list.every? (/.member? n.equivalence sample) - (/.to-list sample)) + (/.to_list sample)) - non-member-is-not-identified! - (not (/.member? n.equivalence sample non-member))] - (and every-member-is-identified! - non-member-is-not-identified!))) + non_member_is_not_identified! + (not (/.member? n.equivalence sample non_member))] + (and every_member_is_identified! + non_member_is_not_identified!))) (_.cover [/.push] - (let [pushed (/.push non-member sample) + (let [pushed (/.push non_member sample) - size-increases! + size_increases! (n.= (inc (/.size sample)) (/.size pushed)) - new-member-is-identified! - (/.member? n.equivalence pushed non-member) + new_member_is_identified! + (/.member? n.equivalence pushed non_member) - has-expected-order! + has_expected_order! (\ (list.equivalence n.equivalence) = - (list\compose (/.to-list sample) (list non-member)) - (/.to-list pushed))] - (and size-increases! - new-member-is-identified! - has-expected-order!))) + (list\compose (/.to_list sample) (list non_member)) + (/.to_list pushed))] + (and size_increases! + new_member_is_identified! + has_expected_order!))) (_.cover [/.pop] (case members (#.Cons target expected) (let [popped (/.pop sample) - size-decreases! + size_decreases! (n.= (dec (/.size sample)) (/.size popped)) - popped-member-is-not-identified! + popped_member_is_not_identified! (not (/.member? n.equivalence popped target)) - has-expected-order! + has_expected_order! (\ (list.equivalence n.equivalence) = expected - (/.to-list popped))] - (and size-decreases! - popped-member-is-not-identified! - has-expected-order!)) + (/.to_list popped))] + (and size_decreases! + popped_member_is_not_identified! + has_expected_order!)) #.Nil (and (/.empty? sample) diff --git a/stdlib/source/test/lux/data/collection/row.lux b/stdlib/source/test/lux/data/collection/row.lux index 46e305b8d..13ed9af28 100644 --- a/stdlib/source/test/lux/data/collection/row.lux +++ b/stdlib/source/test/lux/data/collection/row.lux @@ -50,7 +50,7 @@ (do {! random.monad} [size (\ ! map (n.% 100) random.nat) sample (random.set n.hash size random.nat) - #let [sample (|> sample set.to-list /.from-list)] + #let [sample (|> sample set.to_list /.from_list)] #let [(^open "/\.") (/.equivalence n.equivalence)]] ($_ _.and (_.cover [/.size] @@ -59,40 +59,40 @@ (bit\= (/.empty? sample) (n.= 0 (/.size sample)))) (_.cover [/.empty] (/.empty? /.empty)) - (_.cover [/.to-list /.from-list] - (|> sample /.to-list /.from-list (/\= sample))) + (_.cover [/.to_list /.from_list] + (|> sample /.to_list /.from_list (/\= sample))) (_.cover [/.reverse] (or (n.< 2 (/.size sample)) - (let [not-same! + (let [not_same! (not (/\= sample (/.reverse sample))) - self-symmetry! + self_symmetry! (/\= sample (/.reverse (/.reverse sample)))] - (and not-same! - self-symmetry!)))) + (and not_same! + self_symmetry!)))) (_.cover [/.every? /.any?] (if (/.every? n.even? sample) (not (/.any? (bit.complement n.even?) sample)) (/.any? (bit.complement n.even?) sample))) ))) -(def: index-based +(def: index_based Test (do {! random.monad} [size (\ ! map (|>> (n.% 100) inc) random.nat)] ($_ _.and (do ! - [good-index (|> random.nat (\ ! map (n.% size))) - #let [bad-index (n.+ size good-index)] + [good_index (|> random.nat (\ ! map (n.% size))) + #let [bad_index (n.+ size good_index)] sample (random.set n.hash size random.nat) - non-member (random.filter (|>> (set.member? sample) not) + non_member (random.filter (|>> (set.member? sample) not) random.nat) - #let [sample (|> sample set.to-list /.from-list)]] + #let [sample (|> sample set.to_list /.from_list)]] ($_ _.and (_.cover [/.nth] - (case (/.nth good-index sample) + (case (/.nth good_index sample) (#try.Success member) (/.member? n.equivalence sample member) @@ -101,20 +101,20 @@ (_.cover [/.put] (<| (try.default false) (do try.monad - [sample (/.put good-index non-member sample) - actual (/.nth good-index sample)] - (wrap (is? non-member actual))))) + [sample (/.put good_index non_member sample) + actual (/.nth good_index sample)] + (wrap (is? non_member actual))))) (_.cover [/.update] (<| (try.default false) (do try.monad - [sample (/.put good-index non-member sample) - sample (/.update good-index inc sample) - actual (/.nth good-index sample)] - (wrap (n.= (inc non-member) actual))))) - (_.cover [/.within-bounds?] - (and (/.within-bounds? sample good-index) - (not (/.within-bounds? sample bad-index)))) - (_.cover [/.index-out-of-bounds] + [sample (/.put good_index non_member sample) + sample (/.update good_index inc sample) + actual (/.nth good_index sample)] + (wrap (n.= (inc non_member) actual))))) + (_.cover [/.within_bounds?] + (and (/.within_bounds? sample good_index) + (not (/.within_bounds? sample bad_index)))) + (_.cover [/.index_out_of_bounds] (let [fails! (: (All [a] (-> (Try a) Bit)) (function (_ situation) (case situation @@ -122,10 +122,10 @@ false (#try.Failure error) - (exception.match? /.index-out-of-bounds error))))] - (and (fails! (/.nth bad-index sample)) - (fails! (/.put bad-index non-member sample)) - (fails! (/.update bad-index inc sample))))) + (exception.match? /.index_out_of_bounds error))))] + (and (fails! (/.nth bad_index sample)) + (fails! (/.put bad_index non_member sample)) + (fails! (/.update bad_index inc sample))))) )) ))) @@ -138,13 +138,13 @@ ($_ _.and ..signatures ..whole - ..index-based + ..index_based (do ! [sample (random.set n.hash size random.nat) - non-member (random.filter (|>> (set.member? sample) not) + non_member (random.filter (|>> (set.member? sample) not) random.nat) - #let [sample (|> sample set.to-list /.from-list)] + #let [sample (|> sample set.to_list /.from_list)] #let [(^open "/\.") (/.equivalence n.equivalence)]] ($_ _.and (do ! @@ -152,36 +152,36 @@ value/1 random.nat value/2 random.nat] (_.cover [/.row] - (/\= (/.from-list (list value/0 value/1 value/2)) + (/\= (/.from_list (list value/0 value/1 value/2)) (/.row value/0 value/1 value/2)))) (_.cover [/.member?] (and (list.every? (/.member? n.equivalence sample) - (/.to-list sample)) - (not (/.member? n.equivalence sample non-member)))) + (/.to_list sample)) + (not (/.member? n.equivalence sample non_member)))) (_.cover [/.add] - (let [added (/.add non-member sample) + (let [added (/.add non_member sample) - size-increases! + size_increases! (n.= (inc (/.size sample)) (/.size added)) - is-a-member! - (/.member? n.equivalence added non-member)] - (and size-increases! - is-a-member!))) + is_a_member! + (/.member? n.equivalence added non_member)] + (and size_increases! + is_a_member!))) (_.cover [/.pop] (if (/.empty? sample) (/.empty? (/.pop sample)) - (let [expected-size! + (let [expected_size! (n.= (dec (/.size sample)) (/.size (/.pop sample))) symmetry! (|> sample - (/.add non-member) + (/.add non_member) /.pop (/\= sample))] - (and expected-size! + (and expected_size! symmetry!)))) )) )))) diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux index b21741752..b97e1f7d2 100644 --- a/stdlib/source/test/lux/data/collection/sequence.lux +++ b/stdlib/source/test/lux/data/collection/sequence.lux @@ -39,8 +39,8 @@ index (\ ! map (n.% 100) random.nat) size (\ ! map (|>> (n.% 10) inc) random.nat) offset (\ ! map (n.% 100) random.nat) - cycle-start random.nat - cycle-next (random.list size random.nat)] + cycle_start random.nat + cycle_next (random.list size random.nat)] ($_ _.and (_.for [/.functor] ($functor.spec /.repeat ..equivalence /.functor)) @@ -65,19 +65,19 @@ drops) (list\= (enum.range n.enum size (dec (n.* 2 size))) (/.take size takes))))) - (_.cover [/.take-while] + (_.cover [/.take_while] (list\= (enum.range n.enum 0 (dec size)) - (/.take-while (n.< size) (/.iterate inc 0)))) - (_.cover [/.drop-while] + (/.take_while (n.< size) (/.iterate inc 0)))) + (_.cover [/.drop_while] (list\= (enum.range n.enum offset (dec (n.+ size offset))) - (/.take-while (n.< (n.+ size offset)) - (/.drop-while (n.< offset) (/.iterate inc 0))))) - (_.cover [/.split-while] - (let [[drops takes] (/.split-while (n.< size) (/.iterate inc 0))] + (/.take_while (n.< (n.+ size offset)) + (/.drop_while (n.< offset) (/.iterate inc 0))))) + (_.cover [/.split_while] + (let [[drops takes] (/.split_while (n.< size) (/.iterate inc 0))] (and (list\= (enum.range n.enum 0 (dec size)) drops) (list\= (enum.range n.enum size (dec (n.* 2 size))) - (/.take-while (n.< (n.* 2 size)) takes))))) + (/.take_while (n.< (n.* 2 size)) takes))))) (_.cover [/.head] (n.= offset (/.head (/.iterate inc offset)))) @@ -102,10 +102,10 @@ (/.unfold (function (_ n) [(inc n) (%.nat n)]) offset))))) (_.cover [/.cycle] - (let [cycle (list& cycle-start cycle-next)] + (let [cycle (list& cycle_start cycle_next)] (list\= (list.concat (list.repeat size cycle)) (/.take (n.* size (list.size cycle)) - (/.cycle [cycle-start cycle-next]))))) + (/.cycle [cycle_start cycle_next]))))) (_.cover [/.^sequence&] (let [(/.^sequence& first second third next) (/.iterate inc offset)] (and (n.= offset first) diff --git a/stdlib/source/test/lux/data/collection/set.lux b/stdlib/source/test/lux/data/collection/set.lux index 024a41e39..a58627cde 100644 --- a/stdlib/source/test/lux/data/collection/set.lux +++ b/stdlib/source/test/lux/data/collection/set.lux @@ -19,7 +19,7 @@ {1 ["." / ("\." equivalence)]}) -(def: gen-nat +(def: gen_nat (Random Nat) (\ random.monad map (n.% 100) random.nat)) @@ -29,7 +29,7 @@ (<| (_.covering /._) (_.for [/.Set]) (do {! random.monad} - [size ..gen-nat] + [size ..gen_nat] ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence (random.set n.hash size random.nat))) @@ -37,11 +37,11 @@ ($monoid.spec /.equivalence (/.monoid n.hash) (random.set n.hash size random.nat))) (do ! - [sizeL ..gen-nat - sizeR ..gen-nat + [sizeL ..gen_nat + sizeR ..gen_nat setL (random.set n.hash sizeL random.nat) setR (random.set n.hash sizeR random.nat) - non-memberL (random.filter (|>> (/.member? setL) not) + non_memberL (random.filter (|>> (/.member? setL) not) random.nat)] ($_ _.and (_.cover [/.new] @@ -55,74 +55,74 @@ (def: (hash _) constant)))) random.nat)] - (_.cover [/.member-hash] - (is? hash (/.member-hash (/.new hash))))) + (_.cover [/.member_hash] + (is? hash (/.member_hash (/.new hash))))) (_.cover [/.size] (n.= sizeL (/.size setL))) (_.cover [/.empty?] (bit\= (/.empty? setL) (n.= 0 (/.size setL)))) - (_.cover [/.to-list /.from-list] - (|> setL /.to-list (/.from-list n.hash) (\= setL))) + (_.cover [/.to_list /.from_list] + (|> setL /.to_list (/.from_list n.hash) (\= setL))) (_.cover [/.member?] - (and (list.every? (/.member? setL) (/.to-list setL)) - (not (/.member? setL non-memberL)))) + (and (list.every? (/.member? setL) (/.to_list setL)) + (not (/.member? setL non_memberL)))) (_.cover [/.add] - (let [before-addition! - (not (/.member? setL non-memberL)) + (let [before_addition! + (not (/.member? setL non_memberL)) - after-addition! - (/.member? (/.add non-memberL setL) non-memberL) + after_addition! + (/.member? (/.add non_memberL setL) non_memberL) - size-increase! + size_increase! (n.= (inc (/.size setL)) - (/.size (/.add non-memberL setL)))] - (and before-addition! - after-addition!))) + (/.size (/.add non_memberL setL)))] + (and before_addition! + after_addition!))) (_.cover [/.remove] (let [symmetry! (|> setL - (/.add non-memberL) - (/.remove non-memberL) + (/.add non_memberL) + (/.remove non_memberL) (\= setL)) idempotency! (|> setL - (/.remove non-memberL) + (/.remove non_memberL) (\= setL))] (and symmetry! idempotency!))) (_.cover [/.union /.sub?] (let [setLR (/.union setL setR) - sets-are-subs-of-their-unions! + sets_are_subs_of_their_unions! (and (/.sub? setLR setL) (/.sub? setLR setR)) - union-with-empty-set! + union_with_empty_set! (|> setL (/.union (/.new n.hash)) (\= setL))] - (and sets-are-subs-of-their-unions! - union-with-empty-set!))) + (and sets_are_subs_of_their_unions! + union_with_empty_set!))) (_.cover [/.intersection /.super?] (let [setLR (/.intersection setL setR) - sets-are-supers-of-their-intersections! + sets_are_supers_of_their_intersections! (and (/.super? setLR setL) (/.super? setLR setR)) - intersection-with-empty-set! + intersection_with_empty_set! (|> setL (/.intersection (/.new n.hash)) /.empty?)] - (and sets-are-supers-of-their-intersections! - intersection-with-empty-set!))) + (and sets_are_supers_of_their_intersections! + intersection_with_empty_set!))) (_.cover [/.difference] (let [setL+R (/.union setR setL) - setL-R (/.difference setR setL+R)] - (and (list.every? (/.member? setL+R) (/.to-list setR)) - (not (list.any? (/.member? setL-R) (/.to-list setR)))))) + setL_R (/.difference setR setL+R)] + (and (list.every? (/.member? setL+R) (/.to_list setR)) + (not (list.any? (/.member? setL_R) (/.to_list setR)))))) (_.cover [/.predicate] - (list.every? (/.predicate setL) (/.to-list setL))) + (list.every? (/.predicate setL) (/.to_list setL))) )))))) diff --git a/stdlib/source/test/lux/data/collection/set/multi.lux b/stdlib/source/test/lux/data/collection/set/multi.lux index 98877583f..8d6d5aa22 100644 --- a/stdlib/source/test/lux/data/collection/set/multi.lux +++ b/stdlib/source/test/lux/data/collection/set/multi.lux @@ -28,12 +28,12 @@ (All [a] (-> Nat (Hash a) (Random Nat) (Random a) (Random (/.Set a)))) (do {! random.monad} [elements (random.set hash size element) - element-counts (random.list size ..count)] + element_counts (random.list size ..count)] (wrap (list\fold (function (_ [count element] set) (/.add count element set)) (/.new hash) - (list.zip/2 element-counts - (set.to-list elements)))))) + (list.zip/2 element_counts + (set.to_list elements)))))) (def: #export test Test @@ -42,22 +42,22 @@ (do {! random.monad} [diversity (\ ! map (n.% 10) random.nat) sample (..random diversity n.hash ..count random.nat) - non-member (random.filter (predicate.complement (set.member? (/.support sample))) + non_member (random.filter (predicate.complement (set.member? (/.support sample))) random.nat) - addition-count ..count - partial-removal-count (\ ! map (n.% addition-count) random.nat) + addition_count ..count + partial_removal_count (\ ! map (n.% addition_count) random.nat) another (..random diversity n.hash ..count random.nat)] (`` ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence (..random diversity n.hash ..count random.nat))) - (_.cover [/.to-list /.from-list] + (_.cover [/.to_list /.from_list] (|> sample - /.to-list - (/.from-list n.hash) + /.to_list + (/.from_list n.hash) (\ /.equivalence = sample))) (_.cover [/.size] - (n.= (list.size (/.to-list sample)) + (n.= (list.size (/.to_list sample)) (/.size sample))) (_.cover [/.empty?] (bit\= (/.empty? sample) @@ -66,75 +66,75 @@ (/.empty? (/.new n.hash))) (_.cover [/.support] (list.every? (set.member? (/.support sample)) - (/.to-list sample))) + (/.to_list sample))) (_.cover [/.member?] - (let [non-member-is-not-identified! - (not (/.member? sample non-member)) + (let [non_member_is_not_identified! + (not (/.member? sample non_member)) - all-members-are-identified! + all_members_are_identified! (list.every? (/.member? sample) - (/.to-list sample))] - (and non-member-is-not-identified! - all-members-are-identified!))) + (/.to_list sample))] + (and non_member_is_not_identified! + all_members_are_identified!))) (_.cover [/.multiplicity] - (let [non-members-have-0-multiplicity! - (n.= 0 (/.multiplicity sample non-member)) + (let [non_members_have_0_multiplicity! + (n.= 0 (/.multiplicity sample non_member)) - every-member-has-positive-multiplicity! + every_member_has_positive_multiplicity! (list.every? (|>> (/.multiplicity sample) (n.> 0)) - (/.to-list sample))] - (and non-members-have-0-multiplicity! - every-member-has-positive-multiplicity!))) + (/.to_list sample))] + (and non_members_have_0_multiplicity! + every_member_has_positive_multiplicity!))) (_.cover [/.add] - (let [null-scenario! + (let [null_scenario! (|> sample - (/.add 0 non-member) + (/.add 0 non_member) (\ /.equivalence = sample)) - normal-scenario! - (let [sample+ (/.add addition-count non-member sample)] - (and (not (/.member? sample non-member)) - (/.member? sample+ non-member) - (n.= addition-count (/.multiplicity sample+ non-member))))] - (and null-scenario! - normal-scenario!))) + normal_scenario! + (let [sample+ (/.add addition_count non_member sample)] + (and (not (/.member? sample non_member)) + (/.member? sample+ non_member) + (n.= addition_count (/.multiplicity sample+ non_member))))] + (and null_scenario! + normal_scenario!))) (_.cover [/.remove] - (let [null-scenario! + (let [null_scenario! (\ /.equivalence = (|> sample - (/.add addition-count non-member)) + (/.add addition_count non_member)) (|> sample - (/.add addition-count non-member) - (/.remove 0 non-member))) + (/.add addition_count non_member) + (/.remove 0 non_member))) - partial-scenario! + partial_scenario! (let [sample* (|> sample - (/.add addition-count non-member) - (/.remove partial-removal-count non-member))] - (and (/.member? sample* non-member) - (n.= (n.- partial-removal-count - addition-count) - (/.multiplicity sample* non-member)))) + (/.add addition_count non_member) + (/.remove partial_removal_count non_member))] + (and (/.member? sample* non_member) + (n.= (n.- partial_removal_count + addition_count) + (/.multiplicity sample* non_member)))) - total-scenario! + total_scenario! (|> sample - (/.add addition-count non-member) - (/.remove addition-count non-member) + (/.add addition_count non_member) + (/.remove addition_count non_member) (\ /.equivalence = sample))] - (and null-scenario! - partial-scenario! - total-scenario!))) - (_.cover [/.from-set] - (let [unary (|> sample /.support /.from-set)] + (and null_scenario! + partial_scenario! + total_scenario!))) + (_.cover [/.from_set] + (let [unary (|> sample /.support /.from_set)] (list.every? (|>> (/.multiplicity unary) (n.= 1)) - (/.to-list unary)))) + (/.to_list unary)))) (_.cover [/.sub?] - (let [unary (|> sample /.support /.from-set)] + (let [unary (|> sample /.support /.from_set)] (and (/.sub? sample unary) (or (not (/.sub? unary sample)) (\ /.equivalence = sample unary))))) (_.cover [/.super?] - (let [unary (|> sample /.support /.from-set)] + (let [unary (|> sample /.support /.from_set)] (and (/.super? unary sample) (or (not (/.super? sample unary)) (\ /.equivalence = sample unary))))) @@ -142,27 +142,27 @@ [(_.cover [<name>] (let [|sample| (/.support sample) |another| (/.support another) - sample-only (set.difference |another| |sample|) - another-only (set.difference |sample| |another|) + sample_only (set.difference |another| |sample|) + another_only (set.difference |sample| |another|) common (set.intersection |sample| |another|) composed (<name> sample another) - no-left-changes! (list.every? (function (_ member) + no_left_changes! (list.every? (function (_ member) (n.= (/.multiplicity sample member) (/.multiplicity composed member))) - (set.to-list sample-only)) - no-right-changes! (list.every? (function (_ member) + (set.to_list sample_only)) + no_right_changes! (list.every? (function (_ member) (n.= (/.multiplicity another member) (/.multiplicity composed member))) - (set.to-list another-only)) - common-changes! (list.every? (function (_ member) + (set.to_list another_only)) + common_changes! (list.every? (function (_ member) (n.= (<composition> (/.multiplicity sample member) (/.multiplicity another member)) (/.multiplicity composed member))) - (set.to-list common))] - (and no-left-changes! - no-right-changes! - common-changes!)))] + (set.to_list common))] + (and no_left_changes! + no_right_changes! + common_changes!)))] [/.sum n.+] [/.union n.max] @@ -170,46 +170,46 @@ (_.cover [/.intersection] (let [|sample| (/.support sample) |another| (/.support another) - sample-only (set.difference |another| |sample|) - another-only (set.difference |sample| |another|) + sample_only (set.difference |another| |sample|) + another_only (set.difference |sample| |another|) common (set.intersection |sample| |another|) composed (/.intersection sample another) - left-removals! (list.every? (|>> (/.member? composed) not) - (set.to-list sample-only)) - right-removals! (list.every? (|>> (/.member? composed) not) - (set.to-list another-only)) - common-changes! (list.every? (function (_ member) + left_removals! (list.every? (|>> (/.member? composed) not) + (set.to_list sample_only)) + right_removals! (list.every? (|>> (/.member? composed) not) + (set.to_list another_only)) + common_changes! (list.every? (function (_ member) (n.= (n.min (/.multiplicity sample member) (/.multiplicity another member)) (/.multiplicity composed member))) - (set.to-list common))] - (and left-removals! - right-removals! - common-changes!))) + (set.to_list common))] + (and left_removals! + right_removals! + common_changes!))) (_.cover [/.difference] (let [|sample| (/.support sample) |another| (/.support another) - sample-only (set.difference |another| |sample|) - another-only (set.difference |sample| |another|) + sample_only (set.difference |another| |sample|) + another_only (set.difference |sample| |another|) common (set.intersection |sample| |another|) composed (/.difference sample another) ommissions! (list.every? (|>> (/.member? composed) not) - (set.to-list sample-only)) + (set.to_list sample_only)) intact! (list.every? (function (_ member) (n.= (/.multiplicity another member) (/.multiplicity composed member))) - (set.to-list another-only)) + (set.to_list another_only)) subtractions! (list.every? (function (_ member) - (let [sample-multiplicity (/.multiplicity sample member) - another-multiplicity (/.multiplicity another member)] - (n.= (if (n.> another-multiplicity sample-multiplicity) + (let [sample_multiplicity (/.multiplicity sample member) + another_multiplicity (/.multiplicity another member)] + (n.= (if (n.> another_multiplicity sample_multiplicity) 0 - (n.- sample-multiplicity - another-multiplicity)) + (n.- sample_multiplicity + another_multiplicity)) (/.multiplicity composed member)))) - (set.to-list common))] + (set.to_list common))] (and ommissions! intact! subtractions!))) diff --git a/stdlib/source/test/lux/data/collection/set/ordered.lux b/stdlib/source/test/lux/data/collection/set/ordered.lux index 25c645651..6c0e75b3d 100644 --- a/stdlib/source/test/lux/data/collection/set/ordered.lux +++ b/stdlib/source/test/lux/data/collection/set/ordered.lux @@ -23,7 +23,7 @@ (random.Random Nat) (\ random.monad map (n.% 100) random.nat)) -(def: #export (random size &order gen-value) +(def: #export (random size &order gen_value) (All [a] (-> Nat (Order a) (Random a) (Random (Set a)))) (case size 0 @@ -31,9 +31,9 @@ _ (do random.monad - [partial (random (dec size) &order gen-value) + [partial (random (dec size) &order gen_value) value (random.filter (|>> (/.member? partial) not) - gen-value)] + gen_value)] (wrap (/.add value partial))))) (def: #export test @@ -44,13 +44,13 @@ [sizeL ..size sizeR ..size usetL (random.set n.hash sizeL random.nat) - non-memberL (random.filter (|>> (//.member? usetL) not) + non_memberL (random.filter (|>> (//.member? usetL) not) random.nat) - #let [listL (//.to-list usetL)] - listR (|> (random.set n.hash sizeR random.nat) (\ ! map //.to-list)) + #let [listL (//.to_list usetL)] + listR (|> (random.set n.hash sizeR random.nat) (\ ! map //.to_list)) #let [(^open "/\.") /.equivalence - setL (/.from-list n.order listL) - setR (/.from-list n.order listR) + setL (/.from_list n.order listL) + setR (/.from_list n.order listR) empty (/.new n.order)]] (`` ($_ _.and (_.for [/.equivalence] @@ -63,19 +63,19 @@ (/.empty? setL))) (_.cover [/.new] (/.empty? (/.new n.order))) - (_.cover [/.to-list] + (_.cover [/.to_list] (\ (list.equivalence n.equivalence) = - (/.to-list (/.from-list n.order listL)) + (/.to_list (/.from_list n.order listL)) (list.sort (\ n.order <) listL))) - (_.cover [/.from-list] + (_.cover [/.from_list] (|> setL - /.to-list (/.from-list n.order) + /.to_list (/.from_list n.order) (/\= setL))) (~~ (template [<coverage> <comparison>] [(_.cover [<coverage>] (case (<coverage> setL) (#.Some value) - (|> setL /.to-list (list.every? (<comparison> value))) + (|> setL /.to_list (list.every? (<comparison> value))) #.None (/.empty? setL)))] @@ -84,23 +84,23 @@ [/.max n.<=] )) (_.cover [/.member?] - (let [members-are-identified! - (list.every? (/.member? setL) (/.to-list setL)) + (let [members_are_identified! + (list.every? (/.member? setL) (/.to_list setL)) - non-members-are-not-identified! - (not (/.member? setL non-memberL))] - (and members-are-identified! - non-members-are-not-identified!))) + non_members_are_not_identified! + (not (/.member? setL non_memberL))] + (and members_are_identified! + non_members_are_not_identified!))) (_.cover [/.add] - (let [setL+ (/.add non-memberL setL)] - (and (not (/.member? setL non-memberL)) - (/.member? setL+ non-memberL) + (let [setL+ (/.add non_memberL setL)] + (and (not (/.member? setL non_memberL)) + (/.member? setL+ non_memberL) (n.= (inc (/.size setL)) (/.size setL+))))) (_.cover [/.remove] (|> setL - (/.add non-memberL) - (/.remove non-memberL) + (/.add non_memberL) + (/.remove non_memberL) (\ /.equivalence = setL))) (_.cover [/.sub?] (let [self! @@ -164,7 +164,7 @@ difference! (not (list.any? (/.member? (/.difference setL setR)) - (/.to-list setL))) + (/.to_list setL))) idempotence! (\ /.equivalence = diff --git a/stdlib/source/test/lux/data/collection/tree/finger.lux b/stdlib/source/test/lux/data/collection/tree/finger.lux index 3c1325d4e..f169d8a5d 100644 --- a/stdlib/source/test/lux/data/collection/tree/finger.lux +++ b/stdlib/source/test/lux/data/collection/tree/finger.lux @@ -12,7 +12,7 @@ ["." list ("#\." fold)]]] [math ["." random]] - [type (#+ :by-example)]] + [type (#+ :by_example)]] {1 ["." /]}) @@ -20,7 +20,7 @@ (/.builder text.monoid)) (def: :@: - (:by-example [@] + (:by_example [@] {(/.Builder @ Text) ..builder} @)) @@ -30,56 +30,56 @@ (<| (_.covering /._) (_.for [/.Tree]) (do {! random.monad} - [tag-left (random.ascii/alpha-num 1) - tag-right (random.filter (|>> (text\= tag-left) not) - (random.ascii/alpha-num 1)) - expected-left random.nat - expected-right random.nat] + [tag_left (random.ascii/alpha_num 1) + tag_right (random.filter (|>> (text\= tag_left) not) + (random.ascii/alpha_num 1)) + expected_left random.nat + expected_right random.nat] ($_ _.and (_.cover [/.Builder /.builder] (exec (/.builder text.monoid) true)) (_.cover [/.tag] - (and (text\= tag-left - (/.tag (\ ..builder leaf tag-left expected-left))) - (text\= (text\compose tag-left tag-right) + (and (text\= tag_left + (/.tag (\ ..builder leaf tag_left expected_left))) + (text\= (text\compose tag_left tag_right) (/.tag (\ ..builder branch - (\ ..builder leaf tag-left expected-left) - (\ ..builder leaf tag-right expected-right)))))) + (\ ..builder leaf tag_left expected_left) + (\ ..builder leaf tag_right expected_right)))))) (_.cover [/.root] - (and (case (/.root (\ ..builder leaf tag-left expected-left)) + (and (case (/.root (\ ..builder leaf tag_left expected_left)) (#.Left actual) - (n.= expected-left actual) + (n.= expected_left actual) (#.Right _) false) (case (/.root (\ ..builder branch - (\ ..builder leaf tag-left expected-left) - (\ ..builder leaf tag-right expected-right))) + (\ ..builder leaf tag_left expected_left) + (\ ..builder leaf tag_right expected_right))) (#.Left _) false (#.Right [left right]) (case [(/.root left) (/.root right)] - [(#.Left actual-left) (#.Left actual-right)] - (and (n.= expected-left actual-left) - (n.= expected-right actual-right)) + [(#.Left actual_left) (#.Left actual_right)] + (and (n.= expected_left actual_left) + (n.= expected_right actual_right)) _ false)))) (_.cover [/.value] - (and (n.= expected-left - (/.value (\ ..builder leaf tag-left expected-left))) - (n.= expected-left + (and (n.= expected_left + (/.value (\ ..builder leaf tag_left expected_left))) + (n.= expected_left (/.value (\ ..builder branch - (\ ..builder leaf tag-left expected-left) - (\ ..builder leaf tag-right expected-right)))))) + (\ ..builder leaf tag_left expected_left) + (\ ..builder leaf tag_right expected_right)))))) (do random.monad - [#let [tags-equivalence (list.equivalence text.equivalence) - values-equivalence (list.equivalence n.equivalence)] - tags/H (random.ascii/alpha-num 1) - tags/T (random.list 5 (random.ascii/alpha-num 1)) + [#let [tags_equivalence (list.equivalence text.equivalence) + values_equivalence (list.equivalence n.equivalence)] + tags/H (random.ascii/alpha_num 1) + tags/T (random.list 5 (random.ascii/alpha_num 1)) values/H random.nat values/T (random.list 5 random.nat)] (_.cover [/.tags /.values] @@ -87,63 +87,63 @@ (\ builder branch tree (\ builder leaf tag value))) (\ builder leaf tags/H values/H) (list.zip/2 tags/T values/T))] - (and (\ tags-equivalence = (list& tags/H tags/T) (/.tags tree)) - (\ values-equivalence = (list& values/H values/T) (/.values tree)))))) + (and (\ tags_equivalence = (list& tags/H tags/T) (/.tags tree)) + (\ values_equivalence = (list& values/H values/T) (/.values tree)))))) (_.cover [/.search] - (let [can-find-correct-one! - (|> (\ ..builder leaf tag-left expected-left) - (/.search (text.contains? tag-left)) - (maybe\map (n.= expected-left)) + (let [can_find_correct_one! + (|> (\ ..builder leaf tag_left expected_left) + (/.search (text.contains? tag_left)) + (maybe\map (n.= expected_left)) (maybe.default false)) - cannot-find-incorrect-one! - (|> (\ ..builder leaf tag-right expected-right) - (/.search (text.contains? tag-left)) - (maybe\map (n.= expected-left)) + cannot_find_incorrect_one! + (|> (\ ..builder leaf tag_right expected_right) + (/.search (text.contains? tag_left)) + (maybe\map (n.= expected_left)) (maybe.default false) not) - can-find-left! + can_find_left! (|> (\ ..builder branch - (\ ..builder leaf tag-left expected-left) - (\ ..builder leaf tag-right expected-right)) - (/.search (text.contains? tag-left)) - (maybe\map (n.= expected-left)) + (\ ..builder leaf tag_left expected_left) + (\ ..builder leaf tag_right expected_right)) + (/.search (text.contains? tag_left)) + (maybe\map (n.= expected_left)) (maybe.default false)) - can-find-right! + can_find_right! (|> (\ ..builder branch - (\ ..builder leaf tag-left expected-left) - (\ ..builder leaf tag-right expected-right)) - (/.search (text.contains? tag-right)) - (maybe\map (n.= expected-right)) + (\ ..builder leaf tag_left expected_left) + (\ ..builder leaf tag_right expected_right)) + (/.search (text.contains? tag_right)) + (maybe\map (n.= expected_right)) (maybe.default false))] - (and can-find-correct-one! - cannot-find-incorrect-one! - can-find-left! - can-find-right!))) + (and can_find_correct_one! + cannot_find_incorrect_one! + can_find_left! + can_find_right!))) (_.cover [/.found?] - (let [can-find-correct-one! - (/.found? (text.contains? tag-left) - (\ ..builder leaf tag-left expected-left)) + (let [can_find_correct_one! + (/.found? (text.contains? tag_left) + (\ ..builder leaf tag_left expected_left)) - cannot-find-incorrect-one! - (not (/.found? (text.contains? tag-left) - (\ ..builder leaf tag-right expected-right))) + cannot_find_incorrect_one! + (not (/.found? (text.contains? tag_left) + (\ ..builder leaf tag_right expected_right))) - can-find-left! - (/.found? (text.contains? tag-left) + can_find_left! + (/.found? (text.contains? tag_left) (\ ..builder branch - (\ ..builder leaf tag-left expected-left) - (\ ..builder leaf tag-right expected-right))) + (\ ..builder leaf tag_left expected_left) + (\ ..builder leaf tag_right expected_right))) - can-find-right! - (/.found? (text.contains? tag-right) + can_find_right! + (/.found? (text.contains? tag_right) (\ ..builder branch - (\ ..builder leaf tag-left expected-left) - (\ ..builder leaf tag-right expected-right)))] - (and can-find-correct-one! - cannot-find-incorrect-one! - can-find-left! - can-find-right!))) + (\ ..builder leaf tag_left expected_left) + (\ ..builder leaf tag_right expected_right)))] + (and can_find_correct_one! + cannot_find_incorrect_one! + can_find_left! + can_find_right!))) )))) diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index 76075ba0b..c0ea5e699 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -26,37 +26,37 @@ (def: #export random (Random Color) (|> ($_ random.and random.nat random.nat random.nat) - (\ random.monad map /.from-rgb))) + (\ random.monad map /.from_rgb))) (def: scale (-> Nat Frac) (|>> .int int.frac)) (def: square (-> Frac Frac) (math.pow +2.0)) -(def: square-root (-> Frac Frac) (math.pow +0.5)) +(def: square_root (-> Frac Frac) (math.pow +0.5)) (def: (distance/1 from to) (-> Frac Frac Frac) - (square-root + (square_root (square (f.- from to)))) (def: (distance/3 from to) (-> Color Color Frac) - (let [[fr fg fb] (/.to-rgb from) - [tr tg tb] (/.to-rgb to)] - (square-root + (let [[fr fg fb] (/.to_rgb from) + [tr tg tb] (/.to_rgb to)] + (square_root ($_ f.+ (|> (scale tr) (f.- (scale fr)) square) (|> (scale tg) (f.- (scale fg)) square) (|> (scale tb) (f.- (scale fb)) square))))) -(def: rgb-error-margin +1.8) +(def: rgb_error_margin +1.8) (template [<field>] [(def: (<field> color) (-> Color Frac) - (let [[hue saturation luminance] (/.to-hsl color)] + (let [[hue saturation luminance] (/.to_hsl color)] <field>))] [saturation] @@ -66,21 +66,21 @@ (def: (encoding expected) (-> /.Color Test) ($_ _.and - (_.cover [/.RGB /.to-rgb /.from-rgb] - (|> expected /.to-rgb /.from-rgb + (_.cover [/.RGB /.to_rgb /.from_rgb] + (|> expected /.to_rgb /.from_rgb (\ /.equivalence = expected))) - (_.cover [/.HSL /.to-hsl /.from-hsl] - (|> expected /.to-hsl /.from-hsl + (_.cover [/.HSL /.to_hsl /.from_hsl] + (|> expected /.to_hsl /.from_hsl (distance/3 expected) - (f.<= ..rgb-error-margin))) - (_.cover [/.HSB /.to-hsb /.from-hsb] - (|> expected /.to-hsb /.from-hsb + (f.<= ..rgb_error_margin))) + (_.cover [/.HSB /.to_hsb /.from_hsb] + (|> expected /.to_hsb /.from_hsb (distance/3 expected) - (f.<= ..rgb-error-margin))) - (_.cover [/.CMYK /.to-cmyk /.from-cmyk] - (|> expected /.to-cmyk /.from-cmyk + (f.<= ..rgb_error_margin))) + (_.cover [/.CMYK /.to_cmyk /.from_cmyk] + (|> expected /.to_cmyk /.from_cmyk (distance/3 expected) - (f.<= ..rgb-error-margin))) + (f.<= ..rgb_error_margin))) )) (def: transformation @@ -94,7 +94,7 @@ ((function (_ saturation) (and (f.>= +0.25 saturation) (f.<= +0.75 saturation))))))) - ratio (|> random.safe-frac (random.filter (f.>= +0.5)))] + ratio (|> random.safe_frac (random.filter (f.>= +0.5)))] ($_ _.and (_.cover [/.darker /.brighter] (and (f.<= (distance/3 colorful /.black) @@ -109,17 +109,17 @@ (_.cover [/.saturate] (f.> (saturation mediocre) (saturation (/.saturate ratio mediocre)))) - (_.cover [/.de-saturate] + (_.cover [/.de_saturate] (f.< (saturation mediocre) - (saturation (/.de-saturate ratio mediocre)))) - (_.cover [/.gray-scale] - (let [gray'ed (/.gray-scale mediocre)] + (saturation (/.de_saturate ratio mediocre)))) + (_.cover [/.gray_scale] + (let [gray'ed (/.gray_scale mediocre)] (and (f.= +0.0 (saturation gray'ed)) (|> (luminance gray'ed) (f.- (luminance mediocre)) f.abs - (f.<= ..rgb-error-margin))))) + (f.<= ..rgb_error_margin))))) ))) (def: palette @@ -127,20 +127,20 @@ (_.for [/.Spread /.Palette] (do {! random.monad} [eH (\ ! map (|>> f.abs (f.% +0.9) (f.+ +0.05)) - random.safe-frac) + random.safe_frac) #let [eS +0.5] variations (\ ! map (|>> (n.% 3) (n.+ 2)) random.nat) - #let [max-spread (f./ (|> variations inc .int int.frac) + #let [max_spread (f./ (|> variations inc .int int.frac) +1.0) - min-spread (f./ +2.0 max-spread) - spread-space (f.- min-spread max-spread)] - spread (\ ! map (|>> f.abs (f.% spread-space) (f.+ min-spread)) - random.safe-frac)] + min_spread (f./ +2.0 max_spread) + spread_space (f.- min_spread max_spread)] + spread (\ ! map (|>> f.abs (f.% spread_space) (f.+ min_spread)) + random.safe_frac)] (`` ($_ _.and (~~ (template [<brightness> <palette>] [(_.cover [<palette>] (let [eB <brightness> - expected (/.from-hsb [eH eS eB]) + expected (/.from_hsb [eH eS eB]) palette (<palette> spread variations expected)] (and (n.= variations (list.size palette)) (not (list.any? (\ /.equivalence = expected) palette)))))] @@ -149,7 +149,7 @@ )) (~~ (template [<palette>] [(_.cover [<palette>] - (let [expected (/.from-hsb [eH eS +0.5]) + (let [expected (/.from_hsb [eH eS +0.5]) [c0 c1 c2] (<palette> expected)] (and (\ /.equivalence = expected c0) (not (\ /.equivalence = expected c1)) @@ -157,10 +157,10 @@ [/.triad] [/.clash] - [/.split-complement])) + [/.split_complement])) (~~ (template [<palette>] [(_.cover [<palette>] - (let [expected (/.from-hsb [eH eS +0.5]) + (let [expected (/.from_hsb [eH eS +0.5]) [c0 c1 c2 c3] (<palette> expected)] (and (\ /.equivalence = expected c0) (not (\ /.equivalence = expected c1)) diff --git a/stdlib/source/test/lux/data/color/named.lux b/stdlib/source/test/lux/data/color/named.lux index 0420eed19..062ba560b 100644 --- a/stdlib/source/test/lux/data/color/named.lux +++ b/stdlib/source/test/lux/data/color/named.lux @@ -17,9 +17,9 @@ ["." / ["/#" //]]}) -(with-expansions [<colors> (as-is [letter/a - [/.alice-blue - /.antique-white +(with_expansions [<colors> (as_is [letter/a + [/.alice_blue + /.antique_white ## /.aqua /.aquamarine /.azure]] @@ -28,67 +28,67 @@ [/.beige /.bisque /.black - /.blanched-almond + /.blanched_almond /.blue - /.blue-violet + /.blue_violet /.brown - /.burly-wood]] + /.burly_wood]] [letter/c - [/.cadet-blue + [/.cadet_blue /.chartreuse /.chocolate /.coral - /.cornflower-blue + /.cornflower_blue /.cornsilk /.crimson /.cyan]] [letter/d - [/.dark-blue - /.dark-cyan - /.dark-goldenrod - /.dark-gray - /.dark-green - /.dark-khaki - /.dark-magenta - /.dark-olive-green - /.dark-orange - /.dark-orchid - /.dark-red - /.dark-salmon - /.dark-sea-green - /.dark-slate-blue - /.dark-slate-gray - /.dark-turquoise - /.dark-violet - /.deep-pink - /.deep-sky-blue - /.dim-gray - /.dodger-blue]] + [/.dark_blue + /.dark_cyan + /.dark_goldenrod + /.dark_gray + /.dark_green + /.dark_khaki + /.dark_magenta + /.dark_olive_green + /.dark_orange + /.dark_orchid + /.dark_red + /.dark_salmon + /.dark_sea_green + /.dark_slate_blue + /.dark_slate_gray + /.dark_turquoise + /.dark_violet + /.deep_pink + /.deep_sky_blue + /.dim_gray + /.dodger_blue]] [letter/f - [/.fire-brick - /.floral-white - /.forest-green + [/.fire_brick + /.floral_white + /.forest_green ## /.fuchsia ]] [letter/g [/.gainsboro - /.ghost-white + /.ghost_white /.gold /.goldenrod /.gray /.green - /.green-yellow]] + /.green_yellow]] [letter/h - [/.honey-dew - /.hot-pink]] + [/.honey_dew + /.hot_pink]] [letter/i - [/.indian-red + [/.indian_red /.indigo /.ivory]] @@ -97,88 +97,88 @@ [letter/l [/.lavender - /.lavender-blush - /.lawn-green - /.lemon-chiffon - /.light-blue - /.light-coral - /.light-cyan - /.light-goldenrod-yellow - /.light-gray - /.light-green - /.light-pink - /.light-salmon - /.light-sea-green - /.light-sky-blue - /.light-slate-gray - /.light-steel-blue - /.light-yellow + /.lavender_blush + /.lawn_green + /.lemon_chiffon + /.light_blue + /.light_coral + /.light_cyan + /.light_goldenrod_yellow + /.light_gray + /.light_green + /.light_pink + /.light_salmon + /.light_sea_green + /.light_sky_blue + /.light_slate_gray + /.light_steel_blue + /.light_yellow /.lime - /.lime-green + /.lime_green /.linen]] [letter/m [/.magenta /.maroon - /.medium-aquamarine - /.medium-blue - /.medium-orchid - /.medium-purple - /.medium-sea-green - /.medium-slate-blue - /.medium-spring-green - /.medium-turquoise - /.medium-violet-red - /.midnight-blue - /.mint-cream - /.misty-rose + /.medium_aquamarine + /.medium_blue + /.medium_orchid + /.medium_purple + /.medium_sea_green + /.medium_slate_blue + /.medium_spring_green + /.medium_turquoise + /.medium_violet_red + /.midnight_blue + /.mint_cream + /.misty_rose /.moccasin]] [letter/n - [/.navajo-white + [/.navajo_white /.navy]] [letter/o - [/.old-lace + [/.old_lace /.olive - /.olive-drab + /.olive_drab /.orange - /.orange-red + /.orange_red /.orchid]] [letter/p - [/.pale-goldenrod - /.pale-green - /.pale-turquoise - /.pale-violet-red - /.papaya-whip - /.peach-puff + [/.pale_goldenrod + /.pale_green + /.pale_turquoise + /.pale_violet_red + /.papaya_whip + /.peach_puff /.peru /.pink /.plum - /.powder-blue + /.powder_blue /.purple]] [letter/r - [/.rebecca-purple + [/.rebecca_purple /.red - /.rosy-brown - /.royal-blue]] + /.rosy_brown + /.royal_blue]] [letter/s - [/.saddle-brown + [/.saddle_brown /.salmon - /.sandy-brown - /.sea-green - /.sea-shell + /.sandy_brown + /.sea_green + /.sea_shell /.sienna /.silver - /.sky-blue - /.slate-blue - /.slate-gray + /.sky_blue + /.slate_blue + /.slate_gray /.snow - /.spring-green - /.steel-blue]] + /.spring_green + /.steel_blue]] [letter/t [/.tan @@ -193,33 +193,33 @@ [letter/w [/.wheat /.white - /.white-smoke]] + /.white_smoke]] [letter/y [/.yellow - /.yellow-green]] + /.yellow_green]] ) - <named> (template [<definition> <by-letter>] + <named> (template [<definition> <by_letter>] [((: (-> Any (List //.Color)) (function (_ _) - (`` (list (~~ (template.splice <by-letter>)))))) + (`` (list (~~ (template.splice <by_letter>)))))) 123)] <colors>)] - (def: all-colors + (def: all_colors (list.concat (list <named>))) - (def: unique-colors - (set.from-list //.hash ..all-colors)) + (def: unique_colors + (set.from_list //.hash ..all_colors)) (def: verdict - (n.= (list.size ..all-colors) - (set.size ..unique-colors))) + (n.= (list.size ..all_colors) + (set.size ..unique_colors))) - (template [<definition> <by-letter>] + (template [<definition> <by_letter>] [(def: <definition> Test - (_.cover <by-letter> + (_.cover <by_letter> ..verdict))] <colors>) @@ -228,7 +228,7 @@ Test (<| (_.covering /._) (`` ($_ _.and - (~~ (template [<definition> <by-letter>] + (~~ (template [<definition> <by_letter>] [<definition>] <colors>)) diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux index 09f608543..2d38b8988 100644 --- a/stdlib/source/test/lux/data/format/json.lux +++ b/stdlib/source/test/lux/data/format/json.lux @@ -40,7 +40,7 @@ ($_ random.or (\ ! wrap []) random.bit - random.safe-frac + random.safe_frac (random.unicode size) (random.row size recur) (random.dictionary text.hash size (random.unicode size) recur) @@ -89,9 +89,9 @@ (try.default false)))) (do random.monad [keys (random.set text.hash 3 (random.ascii/alpha 1)) - values (random.set frac.hash 3 random.safe-frac) - #let [expected (list.zip/2 (set.to-list keys) - (list\map (|>> #/.Number) (set.to-list values))) + values (random.set frac.hash 3 random.safe_frac) + #let [expected (list.zip/2 (set.to_list keys) + (list\map (|>> #/.Number) (set.to_list values))) object (/.object expected)]] ($_ _.and (_.cover [/.object /.fields] @@ -114,26 +114,26 @@ [key (random.ascii/alpha 1) unknown (random.filter (|>> (\ text.equivalence = key) not) (random.ascii/alpha 1)) - expected random.safe-frac] + expected random.safe_frac] (_.cover [/.set] (<| (try.default false) (do try.monad [object (/.set key (#/.Number expected) (/.object (list))) - #let [can-find-known-key! + #let [can_find_known_key! (|> object (/.get key) (try\map (\= (#/.Number expected))) (try.default false)) - cannot-find-unknown-key! + cannot_find_unknown_key! (case (/.get unknown object) (#try.Success _) false (#try.Failure error) true)]] - (wrap (and can-find-known-key! - cannot-find-unknown-key!)))))) + (wrap (and can_find_known_key! + cannot_find_unknown_key!)))))) (~~ (template [<type> <get> <tag> <random> <equivalence>] [(do random.monad [key (random.ascii/alpha 1) @@ -144,16 +144,16 @@ (try\map (\ <equivalence> = value)) (try.default false))))] - [/.Boolean /.get-boolean #/.Boolean random.bit bit.equivalence] - [/.Number /.get-number #/.Number random.safe-frac frac.equivalence] - [/.String /.get-string #/.String (random.ascii/alpha 1) text.equivalence] - [/.Array /.get-array #/.Array (random.row 3 ..random) (row.equivalence /.equivalence)] - [/.Object /.get-object #/.Object (random.dictionary text.hash 3 (random.ascii/alpha 1) ..random) (dictionary.equivalence /.equivalence)] + [/.Boolean /.get_boolean #/.Boolean random.bit bit.equivalence] + [/.Number /.get_number #/.Number random.safe_frac frac.equivalence] + [/.String /.get_string #/.String (random.ascii/alpha 1) text.equivalence] + [/.Array /.get_array #/.Array (random.row 3 ..random) (row.equivalence /.equivalence)] + [/.Object /.get_object #/.Object (random.dictionary text.hash 3 (random.ascii/alpha 1) ..random) (dictionary.equivalence /.equivalence)] )) - (with-expansions [<boolean> (boolean) + (with_expansions [<boolean> (boolean) <number> (number) <string> (string) - <array-row> (row.row #/.Null + <array_row> (row.row #/.Null (#/.Boolean <boolean>) (#/.Number <number>) (#/.String <string>)) @@ -173,7 +173,7 @@ [#/.Number <number>] [#/.String <string>] )) - (\= (#/.Array <array-row>) (/.json [#null <boolean> <number> <string>])) + (\= (#/.Array <array_row>) (/.json [#null <boolean> <number> <string>])) (let [object (/.json {<key0> #null <key1> <boolean> <key2> <number> @@ -193,7 +193,7 @@ (\= (#/.Boolean <boolean>) value1) (\= (#/.Number <number>) value2) (\= (#/.String <string>) value3) - (\= (#/.Array <array-row>) value4) + (\= (#/.Array <array_row>) value4) (\= (#/.Number <number>) value6)))))) ))) )))) 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))) diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux index e95b843d2..57958281c 100644 --- a/stdlib/source/test/lux/data/format/xml.lux +++ b/stdlib/source/test/lux/data/format/xml.lux @@ -27,7 +27,7 @@ {1 ["." / (#+ XML)]}) -(def: char-range +(def: char_range Text (format "_" "abcdefghijklmnopqrstuvwxyz" @@ -36,8 +36,8 @@ (def: char (Random Nat) (do {! random.monad} - [idx (|> random.nat (\ ! map (n.% (text.size char-range))))] - (wrap (maybe.assume (text.nth idx char-range))))) + [idx (|> random.nat (\ ! map (n.% (text.size char_range))))] + (wrap (maybe.assume (text.nth idx char_range))))) (def: (size bottom top) (-> Nat Nat (Random Nat)) @@ -83,8 +83,8 @@ [(_.cover [<type> <format>] (and (text\= name (<format> ["" name])) (let [identifier (<format> identifier)] - (and (text.starts-with? namespace identifier) - (text.ends-with? name identifier)))))] + (and (text.starts_with? namespace identifier) + (text.ends_with? name identifier)))))] [/.Tag /.tag] [/.Attribute /.attribute] diff --git a/stdlib/source/test/lux/data/name.lux b/stdlib/source/test/lux/data/name.lux index dd5238aa4..08fd3065e 100644 --- a/stdlib/source/test/lux/data/name.lux +++ b/stdlib/source/test/lux/data/name.lux @@ -24,10 +24,10 @@ (random.filter (|>> (text.contains? ".") not) (random.unicode size))) -(def: #export (random module-size short-size) +(def: #export (random module_size short_size) (-> Nat Nat (Random Name)) - (random.and (..part module-size) - (..part short-size))) + (random.and (..part module_size) + (..part short_size))) (def: #export test Test @@ -59,17 +59,17 @@ (and (is? module1 (/.module name1)) (is? short1 (/.short name1)))) - (_.for [.name-of] + (_.for [.name_of] (let [(^open "/\.") /.equivalence] ($_ _.and (_.test "Can obtain Name from identifier." - (and (/\= ["lux" "yolo"] (.name-of .yolo)) - (/\= ["test/lux/data/name" "yolo"] (.name-of ..yolo)) - (/\= ["" "yolo"] (.name-of yolo)) - (/\= ["lux/test" "yolo"] (.name-of lux/test.yolo)))) + (and (/\= ["lux" "yolo"] (.name_of .yolo)) + (/\= ["test/lux/data/name" "yolo"] (.name_of ..yolo)) + (/\= ["" "yolo"] (.name_of yolo)) + (/\= ["lux/test" "yolo"] (.name_of lux/test.yolo)))) (_.test "Can obtain Name from tag." - (and (/\= ["lux" "yolo"] (.name-of #.yolo)) - (/\= ["test/lux/data/name" "yolo"] (.name-of #..yolo)) - (/\= ["" "yolo"] (.name-of #yolo)) - (/\= ["lux/test" "yolo"] (.name-of #lux/test.yolo))))))) + (and (/\= ["lux" "yolo"] (.name_of #.yolo)) + (/\= ["test/lux/data/name" "yolo"] (.name_of #..yolo)) + (/\= ["" "yolo"] (.name_of #yolo)) + (/\= ["lux/test" "yolo"] (.name_of #lux/test.yolo))))))) ))))) diff --git a/stdlib/source/test/lux/data/number.lux b/stdlib/source/test/lux/data/number.lux index d1d812aa9..d8e769369 100644 --- a/stdlib/source/test/lux/data/number.lux +++ b/stdlib/source/test/lux/data/number.lux @@ -25,9 +25,9 @@ ["#." ratio] ["#." complex]]) -(def: clean-commas +(def: clean_commas (-> Text Text) - (text.replace-all "," "")) + (text.replace_all "," "")) (def: #export test Test @@ -35,7 +35,7 @@ ($_ _.and (_.cover [/.bin] (`` (and (~~ (template [<=> <codec> <number>] - [(case (\ <codec> decode (..clean-commas <number>)) + [(case (\ <codec> decode (..clean_commas <number>)) (#try.Success actual) (<=> (/.bin <number>) actual) @@ -56,7 +56,7 @@ ))))) (_.cover [/.oct] (`` (and (~~ (template [<=> <codec> <number>] - [(case (\ <codec> decode (..clean-commas <number>)) + [(case (\ <codec> decode (..clean_commas <number>)) (#try.Success actual) (<=> (/.oct <number>) actual) @@ -77,7 +77,7 @@ ))))) (_.cover [/.hex] (`` (and (~~ (template [<=> <codec> <number>] - [(case (\ <codec> decode (..clean-commas <number>)) + [(case (\ <codec> decode (..clean_commas <number>)) (#try.Success actual) (<=> (/.hex <number>) actual) diff --git a/stdlib/source/test/lux/data/number/complex.lux b/stdlib/source/test/lux/data/number/complex.lux index 2d5865e3d..fc83ddb51 100644 --- a/stdlib/source/test/lux/data/number/complex.lux +++ b/stdlib/source/test/lux/data/number/complex.lux @@ -21,14 +21,14 @@ {1 ["." /]}) -(def: margin-of-error +(def: margin_of_error +0.000000001) (def: dimension (Random Frac) (do {! random.monad} [factor (|> random.nat (\ ! map (|>> (n.% 1000) (n.max 1)))) - measure (|> random.safe-frac (random.filter (f.> +0.0)))] + measure (|> random.safe_frac (random.filter (f.> +0.0)))] (wrap (f.* (|> factor .int int.frac) measure)))) @@ -60,12 +60,12 @@ (and (f.= real (get@ #/.real r+i)) (f.= +0.0 (get@ #/.imaginary r+i)))))) (_.cover [/.within?] - (/.within? ..margin-of-error + (/.within? ..margin_of_error (/.complex real imaginary) (/.complex real imaginary))) - (_.cover [/.not-a-number?] - (and (/.not-a-number? (/.complex f.not-a-number imaginary)) - (/.not-a-number? (/.complex real f.not-a-number)))) + (_.cover [/.not_a_number?] + (and (/.not_a_number? (/.complex f.not_a_number imaginary)) + (/.not_a_number? (/.complex real f.not_a_number)))) ))) (def: constant @@ -90,7 +90,7 @@ (/.* /.i (/.* /.i sample))))) ))) -(def: absolute-value&argument +(def: absolute_value&argument Test (do random.monad [real ..dimension @@ -102,23 +102,23 @@ (and (f.>= (f.abs real) (/.abs r+i)) (f.>= (f.abs imaginary) (/.abs r+i)))) - not-a-number! - (and (f.not-a-number? (/.abs (/.complex f.not-a-number imaginary))) - (f.not-a-number? (/.abs (/.complex real f.not-a-number)))) + not_a_number! + (and (f.not_a_number? (/.abs (/.complex f.not_a_number imaginary))) + (f.not_a_number? (/.abs (/.complex real f.not_a_number)))) infinity! - (and (f.= f.positive-infinity (/.abs (/.complex f.positive-infinity imaginary))) - (f.= f.positive-infinity (/.abs (/.complex real f.positive-infinity))) - (f.= f.positive-infinity (/.abs (/.complex f.negative-infinity imaginary))) - (f.= f.positive-infinity (/.abs (/.complex real f.negative-infinity))))] + (and (f.= f.positive_infinity (/.abs (/.complex f.positive_infinity imaginary))) + (f.= f.positive_infinity (/.abs (/.complex real f.positive_infinity))) + (f.= f.positive_infinity (/.abs (/.complex f.negative_infinity imaginary))) + (f.= f.positive_infinity (/.abs (/.complex real f.negative_infinity))))] (and normal! - not-a-number! + not_a_number! infinity!))) ## https://en.wikipedia.org/wiki/Argument_(complex_analysis)#Identities (_.cover [/.argument] (let [sample (/.complex real imaginary)] (or (/.= /.zero sample) - (/.within? ..margin-of-error + (/.within? ..margin_of_error sample (/.*' (/.abs sample) (/.exp (/.* /.i (/.complex (/.argument sample))))))))) @@ -148,14 +148,14 @@ (get@ #/.imaginary x)))))) inverse! - (and (|> x (/.+ y) (/.- y) (/.within? ..margin-of-error x)) - (|> x (/.- y) (/.+ y) (/.within? ..margin-of-error x)))] + (and (|> x (/.+ y) (/.- y) (/.within? ..margin_of_error x)) + (|> x (/.- y) (/.+ y) (/.within? ..margin_of_error x)))] (and normal! inverse!))) (_.cover [/.* /./] - (|> x (/.* y) (/./ y) (/.within? ..margin-of-error x))) + (|> x (/.* y) (/./ y) (/.within? ..margin_of_error x))) (_.cover [/.*' /./'] - (|> x (/.*' factor) (/./' factor) (/.within? ..margin-of-error x))) + (|> x (/.*' factor) (/./' factor) (/.within? ..margin_of_error x))) (_.cover [/.%] (let [rem (/.% y x) quotient (|> x (/.- rem) (/./ y)) @@ -180,36 +180,36 @@ (get@ #/.imaginary cx))))) (_.cover [/.reciprocal] (let [reciprocal! - (|> x (/.* (/.reciprocal x)) (/.within? ..margin-of-error /.+one)) + (|> x (/.* (/.reciprocal x)) (/.within? ..margin_of_error /.+one)) - own-inverse! - (|> x /.reciprocal /.reciprocal (/.within? ..margin-of-error x))] + own_inverse! + (|> x /.reciprocal /.reciprocal (/.within? ..margin_of_error x))] (and reciprocal! - own-inverse!))) + own_inverse!))) (_.cover [/.signum] ## Absolute value of signum is always root/2(2), 1 or 0. - (let [signum-abs (|> x /.signum /.abs)] - (or (f.= +0.0 signum-abs) - (f.= +1.0 signum-abs) - (f.= (math.pow +0.5 +2.0) signum-abs)))) + (let [signum_abs (|> x /.signum /.abs)] + (or (f.= +0.0 signum_abs) + (f.= +1.0 signum_abs) + (f.= (math.pow +0.5 +2.0) signum_abs)))) (_.cover [/.negate] - (let [own-inverse! + (let [own_inverse! (let [there (/.negate x) - back-again (/.negate there)] + back_again (/.negate there)] (and (not (/.= there x)) - (/.= back-again x))) + (/.= back_again x))) absolute! (f.= (/.abs x) (/.abs (/.negate x)))] - (and own-inverse! + (and own_inverse! absolute!))) ))) -(def: (trigonometric-symmetry forward backward angle) +(def: (trigonometric_symmetry forward backward angle) (-> (-> /.Complex /.Complex) (-> /.Complex /.Complex) /.Complex Bit) (let [normal (|> angle forward backward)] - (|> normal forward backward (/.within? ..margin-of-error normal)))) + (|> normal forward backward (/.within? ..margin_of_error normal)))) (def: trigonometry Test @@ -217,11 +217,11 @@ [angle ..angle] ($_ _.and (_.cover [/.sin /.asin] - (trigonometric-symmetry /.sin /.asin angle)) + (trigonometric_symmetry /.sin /.asin angle)) (_.cover [/.cos /.acos] - (trigonometric-symmetry /.cos /.acos angle)) + (trigonometric_symmetry /.cos /.acos angle)) (_.cover [/.tan /.atan] - (trigonometric-symmetry /.tan /.atan angle))))) + (trigonometric_symmetry /.tan /.atan angle))))) (def: hyperbolic Test @@ -229,15 +229,15 @@ [angle ..angle] ($_ _.and (_.cover [/.sinh] - (/.within? ..margin-of-error + (/.within? ..margin_of_error (|> angle (/.* /.i) /.sin (/.* /.i) (/.* /.-one)) (/.sinh angle))) (_.cover [/.cosh] - (/.within? ..margin-of-error + (/.within? ..margin_of_error (|> angle (/.* /.i) /.cos) (/.cosh angle))) (_.cover [/.tanh] - (/.within? ..margin-of-error + (/.within? ..margin_of_error (|> angle (/.* /.i) /.tan (/.* /.i) (/.* /.-one)) (/.tanh angle))) ))) @@ -248,11 +248,11 @@ [x ..random] ($_ _.and (_.cover [/.pow /.root/2] - (|> x (/.pow (/.complex +2.0)) /.root/2 (/.within? ..margin-of-error x))) + (|> x (/.pow (/.complex +2.0)) /.root/2 (/.within? ..margin_of_error x))) (_.cover [/.pow'] - (|> x (/.pow' +2.0) (/.pow' +0.5) (/.within? ..margin-of-error x))) + (|> x (/.pow' +2.0) (/.pow' +0.5) (/.within? ..margin_of_error x))) (_.cover [/.log /.exp] - (|> x /.log /.exp (/.within? ..margin-of-error x))) + (|> x /.log /.exp (/.within? ..margin_of_error x))) ))) (def: root @@ -264,7 +264,7 @@ (|> sample (/.roots degree) (list\map (/.pow' (|> degree .int int.frac))) - (list.every? (/.within? ..margin-of-error sample)))))) + (list.every? (/.within? ..margin_of_error sample)))))) (def: #export test Test @@ -276,7 +276,7 @@ ..construction ..constant - ..absolute-value&argument + ..absolute_value&argument ..number ..conjugate&reciprocal&signum&negation ..trigonometry diff --git a/stdlib/source/test/lux/data/number/frac.lux b/stdlib/source/test/lux/data/number/frac.lux index d982b6492..dcaa417ed 100644 --- a/stdlib/source/test/lux/data/number/frac.lux +++ b/stdlib/source/test/lux/data/number/frac.lux @@ -31,21 +31,21 @@ (def: constant Test (do random.monad - [sample random.safe-frac] + [sample random.safe_frac] ($_ _.and (_.cover [/.biggest] (/.<= /.biggest sample)) - (_.cover [/.positive-infinity] - (/.< /.positive-infinity sample)) + (_.cover [/.positive_infinity] + (/.< /.positive_infinity sample)) (_.cover [/.smallest] (bit\= (/.positive? sample) (/.>= /.smallest sample))) - (_.cover [/.negative-infinity] - (/.> /.negative-infinity sample)) - (_.cover [/.not-a-number /.not-a-number?] - (and (/.not-a-number? /.not-a-number) - (not (or (/.= /.not-a-number sample) - (/.not-a-number? sample))))) + (_.cover [/.negative_infinity] + (/.> /.negative_infinity sample)) + (_.cover [/.not_a_number /.not_a_number?] + (and (/.not_a_number? /.not_a_number) + (not (or (/.= /.not_a_number sample) + (/.not_a_number? sample))))) ))) (def: predicate @@ -67,9 +67,9 @@ (and (/.within? /.smallest sample sample) (/.within? (/.+ +1.0 shift) sample (/.+ shift sample)))) (_.cover [/.number?] - (and (not (/.number? /.not-a-number)) - (not (/.number? /.positive-infinity)) - (not (/.number? /.negative-infinity)) + (and (not (/.number? /.not_a_number)) + (not (/.number? /.positive_infinity)) + (not (/.number? /.negative_infinity)) (/.number? sample))) ))) @@ -85,7 +85,7 @@ (_.cover [/.int] (|> expected i.frac /.int (i.= expected)))) (do {! random.monad} - [expected (\ ! map (|>> (i64.left-shift 52) .rev) + [expected (\ ! map (|>> (i64.left_shift 52) .rev) random.nat)] (_.cover [/.rev] (|> expected r.frac /.rev (r.= expected)))) @@ -95,11 +95,11 @@ Test (`` ($_ _.and (_.for [/.equivalence /.=] - ($equivalence.spec /.equivalence random.safe-frac)) + ($equivalence.spec /.equivalence random.safe_frac)) (_.for [/.hash] ($hash.spec /.hash random.frac)) (_.for [/.order /.<] - ($order.spec /.order random.safe-frac)) + ($order.spec /.order random.safe_frac)) (~~ (template [<compose> <monoid>] [(_.for [<monoid> <compose>] ($monoid.spec /.equivalence <monoid> ..random))] @@ -112,18 +112,18 @@ )) (~~ (template [<codec>] [(_.for [<codec>] - ($codec.spec /.equivalence <codec> random.safe-frac))] + ($codec.spec /.equivalence <codec> random.safe_frac))] [/.binary] [/.octal] [/.decimal] [/.hex] )) ))) -(with-expansions [<jvm> (as-is (host.import: java/lang/Double +(with_expansions [<jvm> (as_is (host.import: java/lang/Double ["#::." (#static doubleToRawLongBits #manual [double] long) (#static longBitsToDouble #manual [long] double)]))] - (for {@.old (as-is <jvm>) - @.jvm (as-is <jvm>)})) + (for {@.old (as_is <jvm>) + @.jvm (as_is <jvm>)})) (def: #export test Test @@ -131,8 +131,8 @@ (_.for [.Frac]) ($_ _.and (do random.monad - [left random.safe-frac - right random.safe-frac] + [left random.safe_frac + right random.safe_frac] ($_ _.and (_.cover [/.>] (bit\= (/.> left right) @@ -142,7 +142,7 @@ (/.>= right left))) )) (do random.monad - [sample random.safe-frac] + [sample random.safe_frac] ($_ _.and (_.cover [/.-] (and (/.= +0.0 (/.- sample sample)) @@ -186,48 +186,48 @@ (/.= (/.+ left (/.% left right)) (/.mod left right)))))) )) - (with-expansions [<jvm> ($_ _.and + (with_expansions [<jvm> ($_ _.and (let [test (: (-> Frac Bit) (function (_ value) (n.= (.nat (java/lang/Double::doubleToRawLongBits value)) - (/.to-bits value))))] + (/.to_bits value))))] (do random.monad [sample random.frac] - (_.cover [/.to-bits] + (_.cover [/.to_bits] (and (test sample) (test /.biggest) (test /.smallest) - (test /.not-a-number) - (test /.positive-infinity) - (test /.negative-infinity))))) + (test /.not_a_number) + (test /.positive_infinity) + (test /.negative_infinity))))) (do random.monad [sample random.i64] - (_.cover [/.from-bits] + (_.cover [/.from_bits] (let [expected (java/lang/Double::longBitsToDouble sample) - actual (/.from-bits sample)] + actual (/.from_bits sample)] (or (/.= expected actual) - (and (/.not-a-number? expected) - (/.not-a-number? actual)))))) + (and (/.not_a_number? expected) + (/.not_a_number? actual)))))) )] (for {@.old <jvm> @.jvm <jvm>} (let [test (: (-> Frac Bit) (function (_ expected) - (let [actual (|> expected /.to-bits /.from-bits)] + (let [actual (|> expected /.to_bits /.from_bits)] (or (/.= expected actual) - (and (/.not-a-number? expected) - (/.not-a-number? actual))))))] + (and (/.not_a_number? expected) + (/.not_a_number? actual))))))] (do random.monad [sample random.frac] - (_.cover [/.to-bits /.from-bits] + (_.cover [/.to_bits /.from_bits] (and (test sample) (test /.biggest) (test /.smallest) - (test /.not-a-number) - (test /.positive-infinity) - (test /.negative-infinity))))))) + (test /.not_a_number) + (test /.positive_infinity) + (test /.negative_infinity))))))) (do random.monad - [expected random.safe-frac] + [expected random.safe_frac] (_.cover [/.negate] (let [subtraction! (/.= +0.0 (/.+ (/.negate expected) expected)) diff --git a/stdlib/source/test/lux/data/number/i64.lux b/stdlib/source/test/lux/data/number/i64.lux index 78b293fd5..45e644ab2 100644 --- a/stdlib/source/test/lux/data/number/i64.lux +++ b/stdlib/source/test/lux/data/number/i64.lux @@ -49,38 +49,38 @@ ($_ _.and (do ! [idx (\ ! map (n.% /.width) random.nat)] - (_.cover [/.arithmetic-right-shift] + (_.cover [/.arithmetic_right_shift] (let [value (.int pattern) nullity! - (\= pattern (/.arithmetic-right-shift 0 pattern)) + (\= pattern (/.arithmetic_right_shift 0 pattern)) idempotency! - (\= value (/.arithmetic-right-shift /.width value)) + (\= value (/.arithmetic_right_shift /.width value)) - sign-preservation! + sign_preservation! (bit\= (i.negative? value) - (i.negative? (/.arithmetic-right-shift idx value)))] + (i.negative? (/.arithmetic_right_shift idx value)))] (and nullity! idempotency! - sign-preservation!)))) + sign_preservation!)))) (do ! [idx (\ ! map (|>> (n.% (dec /.width)) inc) random.nat)] - (_.cover [/.left-shift /.logic-right-shift] + (_.cover [/.left_shift /.logic_right_shift] (let [nullity! - (and (\= pattern (/.left-shift 0 pattern)) - (\= pattern (/.logic-right-shift 0 pattern))) + (and (\= pattern (/.left_shift 0 pattern)) + (\= pattern (/.logic_right_shift 0 pattern))) idempotency! - (and (\= pattern (/.left-shift /.width pattern)) - (\= pattern (/.logic-right-shift /.width pattern))) + (and (\= pattern (/.left_shift /.width pattern)) + (\= pattern (/.logic_right_shift /.width pattern))) movement! (let [shift (n.- idx /.width)] (\= (/.and (/.mask idx) pattern) (|> pattern - (/.left-shift shift) - (/.logic-right-shift shift))))] + (/.left_shift shift) + (/.logic_right_shift shift))))] (and nullity! idempotency! movement!)))) @@ -123,13 +123,13 @@ 0 (\= /.false (/.region size offset)) _ (\= (|> pattern ## NNNNYYYYNNNN - (/.logic-right-shift offset) + (/.logic_right_shift offset) ## ____NNNNYYYY - (/.left-shift spare) + (/.left_shift spare) ## YYYY________ - (/.logic-right-shift spare) + (/.logic_right_shift spare) ## ________YYYY - (/.left-shift offset) + (/.left_shift offset) ## ____YYYY____ ) (/.and (/.region size offset) pattern))))) @@ -184,11 +184,11 @@ [pattern random.nat idx (\ ! map (n.% /.width) random.nat)] ($_ _.and - (_.cover [/.width /.bits-per-byte /.bytes-per-i64] - (and (n.= /.bytes-per-i64 - (n./ /.bits-per-byte /.width)) - (n.= /.bits-per-byte - (n./ /.bytes-per-i64 /.width)))) + (_.cover [/.width /.bits_per_byte /.bytes_per_i64] + (and (n.= /.bytes_per_i64 + (n./ /.bits_per_byte /.width)) + (n.= /.bits_per_byte + (n./ /.bytes_per_i64 /.width)))) (_.cover [/.false] (n.= 0 (/.count /.false))) (_.cover [/.or] @@ -225,39 +225,39 @@ (/.count (/.not pattern))))] (and clear&set! complementarity!))) - (_.cover [/.rotate-left /.rotate-right] + (_.cover [/.rotate_left /.rotate_right] (let [false! - (and (\= /.false (/.rotate-left idx /.false)) - (\= /.false (/.rotate-right idx /.false))) + (and (\= /.false (/.rotate_left idx /.false)) + (\= /.false (/.rotate_right idx /.false))) true! - (and (\= /.true (/.rotate-left idx /.true)) - (\= /.true (/.rotate-right idx /.true))) + (and (\= /.true (/.rotate_left idx /.true)) + (\= /.true (/.rotate_right idx /.true))) inverse! (and (|> pattern - (/.rotate-left idx) - (/.rotate-right idx) + (/.rotate_left idx) + (/.rotate_right idx) (\= pattern)) (|> pattern - (/.rotate-right idx) - (/.rotate-left idx) + (/.rotate_right idx) + (/.rotate_left idx) (\= pattern))) nullity! (and (|> pattern - (/.rotate-left 0) + (/.rotate_left 0) (\= pattern)) (|> pattern - (/.rotate-right 0) + (/.rotate_right 0) (\= pattern))) futility! (and (|> pattern - (/.rotate-left /.width) + (/.rotate_left /.width) (\= pattern)) (|> pattern - (/.rotate-right /.width) + (/.rotate_right /.width) (\= pattern)))] (and false! true! diff --git a/stdlib/source/test/lux/data/number/rev.lux b/stdlib/source/test/lux/data/number/rev.lux index 294d8b97a..2e75eb874 100644 --- a/stdlib/source/test/lux/data/number/rev.lux +++ b/stdlib/source/test/lux/data/number/rev.lux @@ -92,7 +92,7 @@ random.rev) divisor (\ ! map (|>> (i64.and (hex "F")) (i64.or (hex "1")) - (i64.rotate-right 8) + (i64.rotate_right 8) .rev) random.nat)] dividend (random.filter (/.> .0) dividend) @@ -116,14 +116,14 @@ (/.down scale) (/.= dividend)) - discrete-division! + discrete_division! (/.= (/.% (.rev scale) dividend) (/.- (|> dividend (/.down scale) (/.up scale)) dividend))] (and symmetry! - discrete-division!))) + discrete_division!))) (_.cover [/.ratio] (|> dividend (/.up scale) @@ -156,7 +156,7 @@ (|> sample /.reciprocal .nat /.reciprocal .nat /.reciprocal)))) (do {! random.monad} [expected (\ ! map (|>> f.abs (f.% +1.0)) - random.safe-frac)] + random.safe_frac)] (_.cover [/.frac] (|> expected f.rev /.frac (f.= expected)))) diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index c751e6a78..4100d5f0d 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -29,7 +29,7 @@ {1 ["." /]}) -(def: bounded-size +(def: bounded_size (random.Random Nat) (|> random.nat (\ random.monad map (|>> (n.% 20) (n.+ 1))))) @@ -55,23 +55,23 @@ left (random.unicode 1) right (random.unicode 1) #let [full (\ /.monoid compose inner outer) - fake-index (.nat -1)]] + fake_index (.nat -1)]] (`` ($_ _.and (~~ (template [<affix> <predicate>] [(_.cover [<affix> <predicate>] (<predicate> outer (<affix> outer inner)))] - [/.prefix /.starts-with?] - [/.suffix /.ends-with?] + [/.prefix /.starts_with?] + [/.suffix /.ends_with?] [/.enclose' /.encloses?] )) (_.cover [/.enclose] (let [value (/.enclose [left right] inner)] - (and (/.starts-with? left value) - (/.ends-with? right value)))) + (and (/.starts_with? left value) + (/.ends_with? right value)))) (_.cover [/.encode] (let [sample (/.encode inner)] - (and (/.encloses? /.double-quote sample) + (and (/.encloses? /.double_quote sample) (/.contains? inner sample)))) )))) @@ -81,69 +81,69 @@ [inner (random.unicode 1) outer (random.filter (|>> (\ /.equivalence = inner) not) (random.unicode 1)) - #let [fake-index (.nat -1)]] + #let [fake_index (.nat -1)]] ($_ _.and (_.cover [/.contains?] (let [full (\ /.monoid compose inner outer)] (and (/.contains? inner full) (/.contains? outer full)))) - (_.cover [/.index-of] - (and (|> (/.index-of inner (\ /.monoid compose inner outer)) - (maybe.default fake-index) + (_.cover [/.index_of] + (and (|> (/.index_of inner (\ /.monoid compose inner outer)) + (maybe.default fake_index) (n.= 0)) - (|> (/.index-of outer (\ /.monoid compose inner outer)) - (maybe.default fake-index) + (|> (/.index_of outer (\ /.monoid compose inner outer)) + (maybe.default fake_index) (n.= 1)))) - (_.cover [/.index-of'] + (_.cover [/.index_of'] (let [full (\ /.monoid compose inner outer)] - (and (|> (/.index-of' inner 0 full) - (maybe.default fake-index) + (and (|> (/.index_of' inner 0 full) + (maybe.default fake_index) (n.= 0)) - (|> (/.index-of' inner 1 full) - (maybe.default fake-index) - (n.= fake-index)) + (|> (/.index_of' inner 1 full) + (maybe.default fake_index) + (n.= fake_index)) - (|> (/.index-of' outer 0 full) - (maybe.default fake-index) + (|> (/.index_of' outer 0 full) + (maybe.default fake_index) (n.= 1)) - (|> (/.index-of' outer 1 full) - (maybe.default fake-index) + (|> (/.index_of' outer 1 full) + (maybe.default fake_index) (n.= 1)) - (|> (/.index-of' outer 2 full) - (maybe.default fake-index) - (n.= fake-index))))) - (_.cover [/.last-index-of] + (|> (/.index_of' outer 2 full) + (maybe.default fake_index) + (n.= fake_index))))) + (_.cover [/.last_index_of] (let [full ($_ (\ /.monoid compose) outer inner outer)] - (and (|> (/.last-index-of inner full) - (maybe.default fake-index) + (and (|> (/.last_index_of inner full) + (maybe.default fake_index) (n.= 1)) - (|> (/.last-index-of outer full) - (maybe.default fake-index) + (|> (/.last_index_of outer full) + (maybe.default fake_index) (n.= 2))))) - (_.cover [/.last-index-of'] + (_.cover [/.last_index_of'] (let [full ($_ (\ /.monoid compose) outer inner outer)] - (and (|> (/.last-index-of' inner 0 full) - (maybe.default fake-index) + (and (|> (/.last_index_of' inner 0 full) + (maybe.default fake_index) (n.= 1)) - (|> (/.last-index-of' inner 2 full) - (maybe.default fake-index) - (n.= fake-index)) + (|> (/.last_index_of' inner 2 full) + (maybe.default fake_index) + (n.= fake_index)) - (|> (/.last-index-of' outer 0 full) - (maybe.default fake-index) + (|> (/.last_index_of' outer 0 full) + (maybe.default fake_index) (n.= 2)) - (|> (/.last-index-of' outer 2 full) - (maybe.default fake-index) + (|> (/.last_index_of' outer 2 full) + (maybe.default fake_index) (n.= 2)) - (|> (/.last-index-of' outer 3 full) - (maybe.default fake-index) - (n.= fake-index))))) + (|> (/.last_index_of' outer 3 full) + (maybe.default fake_index) + (n.= fake_index))))) ))) (def: char Test ($_ _.and - (_.for [/.Char /.from-code] + (_.for [/.Char /.from_code] (`` ($_ _.and (~~ (template [<short> <long>] [(_.cover [<short> <long>] @@ -151,25 +151,25 @@ [/.\0 /.null] [/.\a /.alarm] - [/.\b /.back-space] + [/.\b /.back_space] [/.\t /.tab] - [/.\n /.new-line] - [/.\v /.vertical-tab] - [/.\f /.form-feed] - [/.\r /.carriage-return] - [/.\'' /.double-quote])) - (_.cover [/.line-feed] - (\ /.equivalence = /.new-line /.line-feed)) + [/.\n /.new_line] + [/.\v /.vertical_tab] + [/.\f /.form_feed] + [/.\r /.carriage_return] + [/.\'' /.double_quote])) + (_.cover [/.line_feed] + (\ /.equivalence = /.new_line /.line_feed)) ))) (do {! random.monad} [size (\ ! map (|>> (n.% 10) inc) random.nat) characters (random.set /.hash size (random.ascii/alpha 1)) - #let [sample (|> characters set.to-list /.concat)] + #let [sample (|> characters set.to_list /.concat)] expected (\ ! map (n.% size) random.nat)] (_.cover [/.nth] (case (/.nth expected sample) (#.Some char) - (case (/.index-of (/.from-code char) sample) + (case (/.index_of (/.from_code char) sample) (#.Some actual) (n.= expected actual) @@ -183,11 +183,11 @@ [(/.space? (`` (.char (~~ (static <char>)))))] [/.tab] - [/.vertical-tab] + [/.vertical_tab] [/.space] - [/.new-line] - [/.carriage-return] - [/.form-feed] + [/.new_line] + [/.carriage_return] + [/.form_feed] ))))) )) @@ -198,7 +198,7 @@ characters (random.set /.hash size (random.ascii/alpha 1)) separator (random.filter (|>> (set.member? characters) not) (random.ascii/alpha 1)) - #let [with-no-separator (|> characters set.to-list /.concat)] + #let [with_no_separator (|> characters set.to_list /.concat)] static (random.ascii/alpha 1) #let [dynamic (random.filter (|>> (\ /.equivalence = static) not) (random.ascii/alpha 1))] @@ -207,22 +207,22 @@ ($_ _.and (_.cover [/.concat] (n.= (set.size characters) - (/.size (/.concat (set.to-list characters))))) - (_.cover [/.join-with /.split-all-with] - (and (|> (set.to-list characters) - (/.join-with separator) - (/.split-all-with separator) - (set.from-list /.hash) + (/.size (/.concat (set.to_list characters))))) + (_.cover [/.join_with /.split_all_with] + (and (|> (set.to_list characters) + (/.join_with separator) + (/.split_all_with separator) + (set.from_list /.hash) (\ set.equivalence = characters)) (\ /.equivalence = - (/.concat (set.to-list characters)) - (/.join-with "" (set.to-list characters))))) - (_.cover [/.replace-once] + (/.concat (set.to_list characters)) + (/.join_with "" (set.to_list characters))))) + (_.cover [/.replace_once] (\ /.equivalence = (\ /.monoid compose post static) - (/.replace-once pre post (\ /.monoid compose pre static)))) - (_.cover [/.split-with] - (case (/.split-with static ($_ (\ /.monoid compose) pre static post)) + (/.replace_once pre post (\ /.monoid compose pre static)))) + (_.cover [/.split_with] + (case (/.split_with static ($_ (\ /.monoid compose) pre static post)) (#.Some [left right]) (and (\ /.equivalence = pre left) (\ /.equivalence = post right)) @@ -250,8 +250,8 @@ ..manipulation (do random.monad - [sizeL bounded-size - sizeR bounded-size + [sizeL bounded_size + sizeR bounded_size sampleL (random.unicode sizeL) sampleR (random.unicode sizeR) middle (random.unicode 1) @@ -282,23 +282,23 @@ #0))) )) (do {! random.monad} - [sizeP bounded-size - sizeL bounded-size + [sizeP bounded_size + sizeL bounded_size #let [## The wider unicode charset includes control characters that ## can make text replacement work improperly. ## Because of that, I restrict the charset. - normal-char-gen (|> random.nat (\ ! map (|>> (n.% 128) (n.max 1))))] - sep1 (random.text normal-char-gen 1) - sep2 (random.text normal-char-gen 1) - #let [part-gen (|> (random.text normal-char-gen sizeP) + normal_char_gen (|> random.nat (\ ! map (|>> (n.% 128) (n.max 1))))] + sep1 (random.text normal_char_gen 1) + sep2 (random.text normal_char_gen 1) + #let [part_gen (|> (random.text normal_char_gen sizeP) (random.filter (|>> (/.contains? sep1) not)))] - parts (random.list sizeL part-gen) + parts (random.list sizeL part_gen) #let [sample1 (/.concat (list.interpose sep1 parts)) sample2 (/.concat (list.interpose sep2 parts)) (^open "/\.") /.equivalence]] - (_.cover [/.replace-all] + (_.cover [/.replace_all] (/\= sample2 - (/.replace-all sep1 sep2 sample1)))) + (/.replace_all sep1 sep2 sample1)))) /buffer.test /encoding.test diff --git a/stdlib/source/test/lux/data/text/encoding.lux b/stdlib/source/test/lux/data/text/encoding.lux index fcf01e93d..2e61159dc 100644 --- a/stdlib/source/test/lux/data/text/encoding.lux +++ b/stdlib/source/test/lux/data/text/encoding.lux @@ -23,190 +23,190 @@ {1 ["." /]}) -(with-expansions [<encodings> (as-is [all/a +(with_expansions [<encodings> (as_is [all/a [/.ascii]] [all/ibm<1000 - [/.ibm-37 - /.ibm-273 - /.ibm-277 - /.ibm-278 - /.ibm-280 - /.ibm-284 - /.ibm-285 - /.ibm-290 - /.ibm-297 - /.ibm-300 - /.ibm-420 - /.ibm-424 - /.ibm-437 - /.ibm-500 - /.ibm-737 - /.ibm-775 - /.ibm-833 - /.ibm-834 - /.ibm-838 - /.ibm-850 - /.ibm-852 - /.ibm-855 - /.ibm-856 - /.ibm-857 - /.ibm-858 - /.ibm-860 - /.ibm-861 - /.ibm-862 - /.ibm-863 - /.ibm-864 - /.ibm-865 - /.ibm-866 - /.ibm-868 - /.ibm-869 - /.ibm-870 - /.ibm-871 - /.ibm-874 - /.ibm-875 - /.ibm-918 - /.ibm-921 - /.ibm-922 - /.ibm-930 - /.ibm-933 - /.ibm-935 - /.ibm-937 - /.ibm-939 - /.ibm-942 - /.ibm-942c - /.ibm-943 - /.ibm-943c - /.ibm-948 - /.ibm-949 - /.ibm-949c - /.ibm-950 - /.ibm-964 - /.ibm-970]] + [/.ibm_37 + /.ibm_273 + /.ibm_277 + /.ibm_278 + /.ibm_280 + /.ibm_284 + /.ibm_285 + /.ibm_290 + /.ibm_297 + /.ibm_300 + /.ibm_420 + /.ibm_424 + /.ibm_437 + /.ibm_500 + /.ibm_737 + /.ibm_775 + /.ibm_833 + /.ibm_834 + /.ibm_838 + /.ibm_850 + /.ibm_852 + /.ibm_855 + /.ibm_856 + /.ibm_857 + /.ibm_858 + /.ibm_860 + /.ibm_861 + /.ibm_862 + /.ibm_863 + /.ibm_864 + /.ibm_865 + /.ibm_866 + /.ibm_868 + /.ibm_869 + /.ibm_870 + /.ibm_871 + /.ibm_874 + /.ibm_875 + /.ibm_918 + /.ibm_921 + /.ibm_922 + /.ibm_930 + /.ibm_933 + /.ibm_935 + /.ibm_937 + /.ibm_939 + /.ibm_942 + /.ibm_942c + /.ibm_943 + /.ibm_943c + /.ibm_948 + /.ibm_949 + /.ibm_949c + /.ibm_950 + /.ibm_964 + /.ibm_970]] [all/ibm>1000 - [/.ibm-1006 - /.ibm-1025 - /.ibm-1026 - /.ibm-1046 - /.ibm-1047 - /.ibm-1097 - /.ibm-1098 - /.ibm-1112 - /.ibm-1122 - /.ibm-1123 - /.ibm-1124 - /.ibm-1140 - /.ibm-1141 - /.ibm-1142 - /.ibm-1143 - /.ibm-1144 - /.ibm-1145 - /.ibm-1146 - /.ibm-1147 - /.ibm-1148 - /.ibm-1149 - /.ibm-1166 - /.ibm-1364 - /.ibm-1381 - /.ibm-1383 - /.ibm-33722]] + [/.ibm_1006 + /.ibm_1025 + /.ibm_1026 + /.ibm_1046 + /.ibm_1047 + /.ibm_1097 + /.ibm_1098 + /.ibm_1112 + /.ibm_1122 + /.ibm_1123 + /.ibm_1124 + /.ibm_1140 + /.ibm_1141 + /.ibm_1142 + /.ibm_1143 + /.ibm_1144 + /.ibm_1145 + /.ibm_1146 + /.ibm_1147 + /.ibm_1148 + /.ibm_1149 + /.ibm_1166 + /.ibm_1364 + /.ibm_1381 + /.ibm_1383 + /.ibm_33722]] [all/iso - [/.iso-2022-cn - /.iso2022-cn-cns - /.iso2022-cn-gb - /.iso-2022-jp - /.iso-2022-jp-2 - /.iso-2022-kr - /.iso-8859-1 - /.iso-8859-2 - /.iso-8859-3 - /.iso-8859-4 - /.iso-8859-5 - /.iso-8859-6 - /.iso-8859-7 - /.iso-8859-8 - /.iso-8859-9 - /.iso-8859-11 - /.iso-8859-13 - /.iso-8859-15]] + [/.iso_2022_cn + /.iso2022_cn_cns + /.iso2022_cn_gb + /.iso_2022_jp + /.iso_2022_jp_2 + /.iso_2022_kr + /.iso_8859_1 + /.iso_8859_2 + /.iso_8859_3 + /.iso_8859_4 + /.iso_8859_5 + /.iso_8859_6 + /.iso_8859_7 + /.iso_8859_8 + /.iso_8859_9 + /.iso_8859_11 + /.iso_8859_13 + /.iso_8859_15]] [all/mac - [/.mac-arabic - /.mac-central-europe - /.mac-croatian - /.mac-cyrillic - /.mac-dingbat - /.mac-greek - /.mac-hebrew - /.mac-iceland - /.mac-roman - /.mac-romania - /.mac-symbol - /.mac-thai - /.mac-turkish - /.mac-ukraine]] + [/.mac_arabic + /.mac_central_europe + /.mac_croatian + /.mac_cyrillic + /.mac_dingbat + /.mac_greek + /.mac_hebrew + /.mac_iceland + /.mac_roman + /.mac_romania + /.mac_symbol + /.mac_thai + /.mac_turkish + /.mac_ukraine]] [all/utf - [/.utf-8 - /.utf-16 - /.utf-32]] + [/.utf_8 + /.utf_16 + /.utf_32]] [all/windows - [/.windows-31j - /.windows-874 - /.windows-949 - /.windows-950 - /.windows-1250 - /.windows-1252 - /.windows-1251 - /.windows-1253 - /.windows-1254 - /.windows-1255 - /.windows-1256 - /.windows-1257 - /.windows-1258 - /.windows-iso2022jp - /.windows-50220 - /.windows-50221]] + [/.windows_31j + /.windows_874 + /.windows_949 + /.windows_950 + /.windows_1250 + /.windows_1252 + /.windows_1251 + /.windows_1253 + /.windows_1254 + /.windows_1255 + /.windows_1256 + /.windows_1257 + /.windows_1258 + /.windows_iso2022jp + /.windows_50220 + /.windows_50221]] [all/others - [/.cesu-8 - /.koi8-r - /.koi8-u]] + [/.cesu_8 + /.koi8_r + /.koi8_u]] ) - <named> (template [<definition> <by-letter>] + <named> (template [<definition> <by_letter>] [((: (-> Any (List /.Encoding)) (function (_ _) - (`` (list (~~ (template.splice <by-letter>)))))) + (`` (list (~~ (template.splice <by_letter>)))))) 123)] <encodings>)] - (def: all-encodings + (def: all_encodings (list.concat (list <named>))) - (def: unique-encodings - (set.from-list text.hash (list\map /.name ..all-encodings))) + (def: unique_encodings + (set.from_list text.hash (list\map /.name ..all_encodings))) (def: verdict - (n.= (list.size ..all-encodings) - (set.size ..unique-encodings))) + (n.= (list.size ..all_encodings) + (set.size ..unique_encodings))) - (template [<definition> <by-letter>] + (template [<definition> <by_letter>] [(def: <definition> Test - (`` (_.cover [/.name (~~ (template.splice <by-letter>))] + (`` (_.cover [/.name (~~ (template.splice <by_letter>))] ..verdict)))] <encodings>) (def: #export random (Random /.Encoding) - (let [options (list.size ..all-encodings)] + (let [options (list.size ..all_encodings)] (do {! random.monad} [choice (\ ! map (n.% options) random.nat)] - (wrap (maybe.assume (list.nth choice ..all-encodings)))))) + (wrap (maybe.assume (list.nth choice ..all_encodings)))))) (def: #export test Test @@ -216,7 +216,7 @@ (_.for [/.utf8] ($codec.spec text.equivalence /.utf8 (random.unicode 5))) - (~~ (template [<definition> <by-letter>] + (~~ (template [<definition> <by_letter>] [<definition>] <encodings>)) diff --git a/stdlib/source/test/lux/data/text/format.lux b/stdlib/source/test/lux/data/text/format.lux index cfad7f524..00df7058a 100644 --- a/stdlib/source/test/lux/data/text/format.lux +++ b/stdlib/source/test/lux/data/text/format.lux @@ -56,7 +56,7 @@ (def: (= reference subject) (text\= (reference example) (subject example)))) -(def: random-contravariant +(def: random_contravariant (Random (Ex [a] [(/.Format a) (Random a)])) ($_ random.either @@ -74,7 +74,7 @@ (`` ($_ _.and (_.for [/.functor] (do random.monad - [[format random] ..random-contravariant + [[format random] ..random_contravariant example random] ($contravariant.spec (..equivalence example) format @@ -149,12 +149,12 @@ (text\= (/.list /.nat members) (|> members (list\map /.nat) - (text.join-with " ") + (text.join_with " ") list (/.list (|>>)))))) (do {! random.monad} [modulus (random.one (|>> modulus.modulus - try.to-maybe) + try.to_maybe) random.int) sample (\ ! map (modular.modular modulus) random.int)] diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux index f72c19030..3998f78f7 100644 --- a/stdlib/source/test/lux/data/text/regex.lux +++ b/stdlib/source/test/lux/data/text/regex.lux @@ -21,7 +21,7 @@ {1 ["." /]}) -(def: (should-pass regex input) +(def: (should_pass regex input) (-> (Parser Text) Text Bit) (|> input (<text>.run regex) @@ -31,7 +31,7 @@ _ #0))) -(def: (text-should-pass test regex input) +(def: (text_should_pass test regex input) (-> Text (Parser Text) Text Bit) (|> input (<text>.run regex) @@ -41,7 +41,7 @@ _ false))) -(def: (should-fail regex input) +(def: (should_fail regex input) (All [a] (-> (Parser a) Text Bit)) (|> input (<text>.run regex) @@ -51,220 +51,220 @@ _ false))) -(syntax: (should-check pattern regex input) - (meta.with-gensyms [g!message g!_] - (wrap (list (` (|> (~ input) - (<text>.run (~ regex)) - (case> (^ (#try.Success (~ pattern))) - true +(syntax: (should_check pattern regex input) + (meta.with_gensyms [g!message g!_] + (wrap (list (` (|> (~ input) + (<text>.run (~ regex)) + (case> (^ (#try.Success (~ pattern))) + true - (~ g!_) - false))))))) + (~ g!_) + false))))))) (def: basics Test (_.test "Can parse character literals." - (and (should-pass (/.regex "a") "a") - (should-fail (/.regex "a") ".") - (should-pass (/.regex "\.") ".") - (should-fail (/.regex "\.") "a")))) + (and (should_pass (/.regex "a") "a") + (should_fail (/.regex "a") ".") + (should_pass (/.regex "\.") ".") + (should_fail (/.regex "\.") "a")))) -(def: system-character-classes +(def: system_character_classes Test ($_ _.and (_.test "Can parse anything." - (should-pass (/.regex ".") "a")) + (should_pass (/.regex ".") "a")) (_.test "Can parse digits." - (and (should-pass (/.regex "\d") "0") - (should-fail (/.regex "\d") "m"))) + (and (should_pass (/.regex "\d") "0") + (should_fail (/.regex "\d") "m"))) (_.test "Can parse non digits." - (and (should-pass (/.regex "\D") "m") - (should-fail (/.regex "\D") "0"))) + (and (should_pass (/.regex "\D") "m") + (should_fail (/.regex "\D") "0"))) (_.test "Can parse white-space." - (and (should-pass (/.regex "\s") " ") - (should-fail (/.regex "\s") "m"))) + (and (should_pass (/.regex "\s") " ") + (should_fail (/.regex "\s") "m"))) (_.test "Can parse non white-space." - (and (should-pass (/.regex "\S") "m") - (should-fail (/.regex "\S") " "))) + (and (should_pass (/.regex "\S") "m") + (should_fail (/.regex "\S") " "))) (_.test "Can parse word characters." - (and (should-pass (/.regex "\w") "_") - (should-fail (/.regex "\w") "^"))) + (and (should_pass (/.regex "\w") "_") + (should_fail (/.regex "\w") "^"))) (_.test "Can parse non word characters." - (and (should-pass (/.regex "\W") ".") - (should-fail (/.regex "\W") "a"))) + (and (should_pass (/.regex "\W") ".") + (should_fail (/.regex "\W") "a"))) )) -(def: special-system-character-classes +(def: special_system_character_classes Test ($_ _.and (_.test "Lower-case." - (and (should-pass (/.regex "\p{Lower}") "m") - (should-fail (/.regex "\p{Lower}") "M"))) + (and (should_pass (/.regex "\p{Lower}") "m") + (should_fail (/.regex "\p{Lower}") "M"))) (_.test "Upper-case." - (and (should-pass (/.regex "\p{Upper}") "M") - (should-fail (/.regex "\p{Upper}") "m"))) + (and (should_pass (/.regex "\p{Upper}") "M") + (should_fail (/.regex "\p{Upper}") "m"))) (_.test "Alphabetic." - (and (should-pass (/.regex "\p{Alpha}") "M") - (should-fail (/.regex "\p{Alpha}") "0"))) + (and (should_pass (/.regex "\p{Alpha}") "M") + (should_fail (/.regex "\p{Alpha}") "0"))) (_.test "Numeric digits." - (and (should-pass (/.regex "\p{Digit}") "1") - (should-fail (/.regex "\p{Digit}") "n"))) + (and (should_pass (/.regex "\p{Digit}") "1") + (should_fail (/.regex "\p{Digit}") "n"))) (_.test "Alphanumeric." - (and (should-pass (/.regex "\p{Alnum}") "1") - (should-fail (/.regex "\p{Alnum}") "."))) + (and (should_pass (/.regex "\p{Alnum}") "1") + (should_fail (/.regex "\p{Alnum}") "."))) (_.test "Whitespace." - (and (should-pass (/.regex "\p{Space}") " ") - (should-fail (/.regex "\p{Space}") "."))) + (and (should_pass (/.regex "\p{Space}") " ") + (should_fail (/.regex "\p{Space}") "."))) (_.test "Hexadecimal." - (and (should-pass (/.regex "\p{HexDigit}") "a") - (should-fail (/.regex "\p{HexDigit}") "."))) + (and (should_pass (/.regex "\p{HexDigit}") "a") + (should_fail (/.regex "\p{HexDigit}") "."))) (_.test "Octal." - (and (should-pass (/.regex "\p{OctDigit}") "6") - (should-fail (/.regex "\p{OctDigit}") "."))) + (and (should_pass (/.regex "\p{OctDigit}") "6") + (should_fail (/.regex "\p{OctDigit}") "."))) (_.test "Blank." - (and (should-pass (/.regex "\p{Blank}") text.tab) - (should-fail (/.regex "\p{Blank}") "."))) + (and (should_pass (/.regex "\p{Blank}") text.tab) + (should_fail (/.regex "\p{Blank}") "."))) (_.test "ASCII." - (and (should-pass (/.regex "\p{ASCII}") text.tab) - (should-fail (/.regex "\p{ASCII}") (text.from-code (hex "1234"))))) + (and (should_pass (/.regex "\p{ASCII}") text.tab) + (should_fail (/.regex "\p{ASCII}") (text.from_code (hex "1234"))))) (_.test "Control characters." - (and (should-pass (/.regex "\p{Contrl}") (text.from-code (hex "12"))) - (should-fail (/.regex "\p{Contrl}") "a"))) + (and (should_pass (/.regex "\p{Contrl}") (text.from_code (hex "12"))) + (should_fail (/.regex "\p{Contrl}") "a"))) (_.test "Punctuation." - (and (should-pass (/.regex "\p{Punct}") "@") - (should-fail (/.regex "\p{Punct}") "a"))) + (and (should_pass (/.regex "\p{Punct}") "@") + (should_fail (/.regex "\p{Punct}") "a"))) (_.test "Graph." - (and (should-pass (/.regex "\p{Graph}") "@") - (should-fail (/.regex "\p{Graph}") " "))) + (and (should_pass (/.regex "\p{Graph}") "@") + (should_fail (/.regex "\p{Graph}") " "))) (_.test "Print." - (and (should-pass (/.regex "\p{Print}") (text.from-code (hex "20"))) - (should-fail (/.regex "\p{Print}") (text.from-code (hex "1234"))))) + (and (should_pass (/.regex "\p{Print}") (text.from_code (hex "20"))) + (should_fail (/.regex "\p{Print}") (text.from_code (hex "1234"))))) )) -(def: custom-character-classes +(def: custom_character_classes Test ($_ _.and (_.test "Can parse using custom character classes." - (and (should-pass (/.regex "[abc]") "a") - (should-fail (/.regex "[abc]") "m"))) + (and (should_pass (/.regex "[abc]") "a") + (should_fail (/.regex "[abc]") "m"))) (_.test "Can parse using character ranges." - (and (should-pass (/.regex "[a-z]") "a") - (should-pass (/.regex "[a-z]") "m") - (should-pass (/.regex "[a-z]") "z"))) + (and (should_pass (/.regex "[a-z]") "a") + (should_pass (/.regex "[a-z]") "m") + (should_pass (/.regex "[a-z]") "z"))) (_.test "Can combine character ranges." - (and (should-pass (/.regex "[a-zA-Z]") "a") - (should-pass (/.regex "[a-zA-Z]") "m") - (should-pass (/.regex "[a-zA-Z]") "z") - (should-pass (/.regex "[a-zA-Z]") "A") - (should-pass (/.regex "[a-zA-Z]") "M") - (should-pass (/.regex "[a-zA-Z]") "Z"))) + (and (should_pass (/.regex "[a-zA-Z]") "a") + (should_pass (/.regex "[a-zA-Z]") "m") + (should_pass (/.regex "[a-zA-Z]") "z") + (should_pass (/.regex "[a-zA-Z]") "A") + (should_pass (/.regex "[a-zA-Z]") "M") + (should_pass (/.regex "[a-zA-Z]") "Z"))) (_.test "Can negate custom character classes." - (and (should-fail (/.regex "[^abc]") "a") - (should-pass (/.regex "[^abc]") "m"))) + (and (should_fail (/.regex "[^abc]") "a") + (should_pass (/.regex "[^abc]") "m"))) (_.test "Can negate character ranges.." - (and (should-fail (/.regex "[^a-z]") "a") - (should-pass (/.regex "[^a-z]") "0"))) + (and (should_fail (/.regex "[^a-z]") "a") + (should_pass (/.regex "[^a-z]") "0"))) (_.test "Can parse negate combinations of character ranges." - (and (should-fail (/.regex "[^a-zA-Z]") "a") - (should-pass (/.regex "[^a-zA-Z]") "0"))) + (and (should_fail (/.regex "[^a-zA-Z]") "a") + (should_pass (/.regex "[^a-zA-Z]") "0"))) (_.test "Can make custom character classes more specific." (and (let [RE (/.regex "[a-z&&[def]]")] - (and (should-fail RE "a") - (should-pass RE "d"))) + (and (should_fail RE "a") + (should_pass RE "d"))) (let [RE (/.regex "[a-z&&[^bc]]")] - (and (should-pass RE "a") - (should-fail RE "b"))) + (and (should_pass RE "a") + (should_fail RE "b"))) (let [RE (/.regex "[a-z&&[^m-p]]")] - (and (should-pass RE "a") - (should-fail RE "m") - (should-fail RE "p"))))) + (and (should_pass RE "a") + (should_fail RE "m") + (should_fail RE "p"))))) )) (def: references Test (let [number (/.regex "\d+")] (_.test "Can build complex regexs by combining simpler ones." - (should-check ["809-345-6789" "809" "345" "6789"] + (should_check ["809-345-6789" "809" "345" "6789"] (/.regex "(\@<number>)-(\@<number>)-(\@<number>)") "809-345-6789")))) -(def: fuzzy-quantifiers +(def: fuzzy_quantifiers Test ($_ _.and (_.test "Can sequentially combine patterns." - (text-should-pass "aa" (/.regex "aa") "aa")) + (text_should_pass "aa" (/.regex "aa") "aa")) (_.test "Can match patterns optionally." - (and (text-should-pass "a" (/.regex "a?") "a") - (text-should-pass "" (/.regex "a?") ""))) + (and (text_should_pass "a" (/.regex "a?") "a") + (text_should_pass "" (/.regex "a?") ""))) (_.test "Can match a pattern 0 or more times." - (and (text-should-pass "aaa" (/.regex "a*") "aaa") - (text-should-pass "" (/.regex "a*") ""))) + (and (text_should_pass "aaa" (/.regex "a*") "aaa") + (text_should_pass "" (/.regex "a*") ""))) (_.test "Can match a pattern 1 or more times." - (and (text-should-pass "aaa" (/.regex "a+") "aaa") - (text-should-pass "a" (/.regex "a+") "a") - (should-fail (/.regex "a+") ""))) + (and (text_should_pass "aaa" (/.regex "a+") "aaa") + (text_should_pass "a" (/.regex "a+") "a") + (should_fail (/.regex "a+") ""))) )) -(def: crisp-quantifiers +(def: crisp_quantifiers Test ($_ _.and (_.test "Can match a pattern N times." - (and (text-should-pass "aa" (/.regex "a{2}") "aa") - (text-should-pass "a" (/.regex "a{1}") "a") - (should-fail (/.regex "a{3}") "aa"))) + (and (text_should_pass "aa" (/.regex "a{2}") "aa") + (text_should_pass "a" (/.regex "a{1}") "a") + (should_fail (/.regex "a{3}") "aa"))) (_.test "Can match a pattern at-least N times." - (and (text-should-pass "aa" (/.regex "a{1,}") "aa") - (text-should-pass "aa" (/.regex "a{2,}") "aa") - (should-fail (/.regex "a{3,}") "aa"))) + (and (text_should_pass "aa" (/.regex "a{1,}") "aa") + (text_should_pass "aa" (/.regex "a{2,}") "aa") + (should_fail (/.regex "a{3,}") "aa"))) (_.test "Can match a pattern at-most N times." - (and (text-should-pass "aa" (/.regex "a{,2}") "aa") - (text-should-pass "aa" (/.regex "a{,3}") "aa"))) + (and (text_should_pass "aa" (/.regex "a{,2}") "aa") + (text_should_pass "aa" (/.regex "a{,3}") "aa"))) (_.test "Can match a pattern between N and M times." - (and (text-should-pass "a" (/.regex "a{1,2}") "a") - (text-should-pass "aa" (/.regex "a{1,2}") "aa"))) + (and (text_should_pass "a" (/.regex "a{1,2}") "a") + (text_should_pass "aa" (/.regex "a{1,2}") "aa"))) )) (def: groups Test ($_ _.and (_.test "Can extract groups of sub-matches specified in a pattern." - (and (should-check ["abc" "b"] (/.regex "a(.)c") "abc") - (should-check ["abbbbbc" "bbbbb"] (/.regex "a(b+)c") "abbbbbc") - (should-check ["809-345-6789" "809" "345" "6789"] (/.regex "(\d{3})-(\d{3})-(\d{4})") "809-345-6789") - (should-check ["809-345-6789" "809" "6789"] (/.regex "(\d{3})-(?:\d{3})-(\d{4})") "809-345-6789") - (should-check ["809-809-6789" "809" "6789"] (/.regex "(\d{3})-\0-(\d{4})") "809-809-6789") - (should-check ["809-809-6789" "809" "6789"] (/.regex "(?<code>\d{3})-\k<code>-(\d{4})") "809-809-6789") - (should-check ["809-809-6789-6789" "809" "6789"] (/.regex "(?<code>\d{3})-\k<code>-(\d{4})-\0") "809-809-6789-6789"))) + (and (should_check ["abc" "b"] (/.regex "a(.)c") "abc") + (should_check ["abbbbbc" "bbbbb"] (/.regex "a(b+)c") "abbbbbc") + (should_check ["809-345-6789" "809" "345" "6789"] (/.regex "(\d{3})-(\d{3})-(\d{4})") "809-345-6789") + (should_check ["809-345-6789" "809" "6789"] (/.regex "(\d{3})-(?:\d{3})-(\d{4})") "809-345-6789") + (should_check ["809-809-6789" "809" "6789"] (/.regex "(\d{3})-\0-(\d{4})") "809-809-6789") + (should_check ["809-809-6789" "809" "6789"] (/.regex "(?<code>\d{3})-\k<code>-(\d{4})") "809-809-6789") + (should_check ["809-809-6789-6789" "809" "6789"] (/.regex "(?<code>\d{3})-\k<code>-(\d{4})-\0") "809-809-6789-6789"))) (_.test "Can specify groups within groups." - (should-check ["809-345-6789" "809" ["345-6789" "345" "6789"]] (/.regex "(\d{3})-((\d{3})-(\d{4}))") "809-345-6789")) + (should_check ["809-345-6789" "809" ["345-6789" "345" "6789"]] (/.regex "(\d{3})-((\d{3})-(\d{4}))") "809-345-6789")) )) (def: alternation Test ($_ _.and (_.test "Can specify alternative patterns." - (and (should-check ["a" (0 #0 [])] (/.regex "a|b") "a") - (should-check ["b" (0 #1 [])] (/.regex "a|b") "b") - (should-fail (/.regex "a|b") "c"))) + (and (should_check ["a" (0 #0 [])] (/.regex "a|b") "a") + (should_check ["b" (0 #1 [])] (/.regex "a|b") "b") + (should_fail (/.regex "a|b") "c"))) (_.test "Can have groups within alternations." - (and (should-check ["abc" (0 #0 ["b" "c"])] (/.regex "a(.)(.)|b(.)(.)") "abc") - (should-check ["bcd" (0 #1 ["c" "d"])] (/.regex "a(.)(.)|b(.)(.)") "bcd") - (should-fail (/.regex "a(.)(.)|b(.)(.)") "cde") + (and (should_check ["abc" (0 #0 ["b" "c"])] (/.regex "a(.)(.)|b(.)(.)") "abc") + (should_check ["bcd" (0 #1 ["c" "d"])] (/.regex "a(.)(.)|b(.)(.)") "bcd") + (should_fail (/.regex "a(.)(.)|b(.)(.)") "cde") - (should-check ["123-456-7890" (0 #0 ["123" "456-7890" "456" "7890"])] + (should_check ["123-456-7890" (0 #0 ["123" "456-7890" "456" "7890"])] (/.regex "(\d{3})-((\d{3})-(\d{4}))|b(.)d") "123-456-7890"))) )) @@ -276,12 +276,12 @@ (_.for [/.regex] ($_ _.and ..basics - ..system-character-classes - ..special-system-character-classes - ..custom-character-classes + ..system_character_classes + ..special_system_character_classes + ..custom_character_classes ..references - ..fuzzy-quantifiers - ..crisp-quantifiers + ..fuzzy_quantifiers + ..crisp_quantifiers ..groups ..alternation )) diff --git a/stdlib/source/test/lux/data/text/unicode/block.lux b/stdlib/source/test/lux/data/text/unicode/block.lux index eb55617ca..a575b4fc6 100644 --- a/stdlib/source/test/lux/data/text/unicode/block.lux +++ b/stdlib/source/test/lux/data/text/unicode/block.lux @@ -29,17 +29,17 @@ end random.nat] (wrap (/.block start end)))) -(with-expansions [<blocks> (as-is [blocks/0 - [/.basic-latin - /.latin-1-supplement - /.latin-extended-a - /.latin-extended-b - /.ipa-extensions - /.spacing-modifier-letters - /.combining-diacritical-marks - /.greek-and-coptic +(with_expansions [<blocks> (as_is [blocks/0 + [/.basic_latin + /.latin_1_supplement + /.latin_extended_a + /.latin_extended_b + /.ipa_extensions + /.spacing_modifier_letters + /.combining_diacritical_marks + /.greek_and_coptic /.cyrillic - /.cyrillic-supplementary + /.cyrillic_supplementary /.armenian /.hebrew /.arabic @@ -60,10 +60,10 @@ /.tibetan /.myanmar /.georgian - /.hangul-jamo + /.hangul_jamo /.ethiopic /.cherokee - /.unified-canadian-aboriginal-syllabics + /.unified_canadian_aboriginal_syllabics /.ogham /.runic /.tagalog @@ -74,74 +74,74 @@ /.mongolian]] [blocks/1 [/.limbu - /.tai-le - /.khmer-symbols - /.phonetic-extensions - /.latin-extended-additional - /.greek-extended - /.general-punctuation - /.superscripts-and-subscripts - /.currency-symbols - /.combining-diacritical-marks-for-symbols - /.letterlike-symbols - /.number-forms + /.tai_le + /.khmer_symbols + /.phonetic_extensions + /.latin_extended_additional + /.greek_extended + /.general_punctuation + /.superscripts_and_subscripts + /.currency_symbols + /.combining_diacritical_marks_for_symbols + /.letterlike_symbols + /.number_forms /.arrows - /.mathematical-operators - /.miscellaneous-technical - /.control-pictures - /.optical-character-recognition - /.enclosed-alphanumerics - /.box-drawing - /.block-elements - /.geometric-shapes - /.miscellaneous-symbols + /.mathematical_operators + /.miscellaneous_technical + /.control_pictures + /.optical_character_recognition + /.enclosed_alphanumerics + /.box_drawing + /.block_elements + /.geometric_shapes + /.miscellaneous_symbols /.dingbats - /.miscellaneous-mathematical-symbols-a - /.supplemental-arrows-a - /.braille-patterns - /.supplemental-arrows-b - /.miscellaneous-mathematical-symbols-b - /.supplemental-mathematical-operators - /.miscellaneous-symbols-and-arrows - /.cjk-radicals-supplement - /.kangxi-radicals - /.ideographic-description-characters - /.cjk-symbols-and-punctuation + /.miscellaneous_mathematical_symbols_a + /.supplemental_arrows_a + /.braille_patterns + /.supplemental_arrows_b + /.miscellaneous_mathematical_symbols_b + /.supplemental_mathematical_operators + /.miscellaneous_symbols_and_arrows + /.cjk_radicals_supplement + /.kangxi_radicals + /.ideographic_description_characters + /.cjk_symbols_and_punctuation /.hiragana /.katakana /.bopomofo - /.hangul-compatibility-jamo + /.hangul_compatibility_jamo /.kanbun - /.bopomofo-extended - /.katakana-phonetic-extensions - /.enclosed-cjk-letters-and-months - /.cjk-compatibility - /.cjk-unified-ideographs-extension-a - /.yijing-hexagram-symbols - /.cjk-unified-ideographs - /.yi-syllables - /.yi-radicals - /.hangul-syllables - /.high-surrogates - /.high-private-use-surrogates - /.low-surrogates - /.private-use-area - /.cjk-compatibility-ideographs - /.alphabetic-presentation-forms]] + /.bopomofo_extended + /.katakana_phonetic_extensions + /.enclosed_cjk_letters_and_months + /.cjk_compatibility + /.cjk_unified_ideographs_extension_a + /.yijing_hexagram_symbols + /.cjk_unified_ideographs + /.yi_syllables + /.yi_radicals + /.hangul_syllables + /.high_surrogates + /.high_private_use_surrogates + /.low_surrogates + /.private_use_area + /.cjk_compatibility_ideographs + /.alphabetic_presentation_forms]] [blocks/2 - [/.arabic-presentation-forms-a - /.variation-selectors - /.combining-half-marks - /.cjk-compatibility-forms - /.small-form-variants - /.arabic-presentation-forms-b - /.halfwidth-and-fullwidth-forms + [/.arabic_presentation_forms_a + /.variation_selectors + /.combining_half_marks + /.cjk_compatibility_forms + /.small_form_variants + /.arabic_presentation_forms_b + /.halfwidth_and_fullwidth_forms /.specials ## Specialized blocks - /.basic-latin/decimal - /.basic-latin/upper-alpha - /.basic-latin/lower-alpha]] + /.basic_latin/decimal + /.basic_latin/upper_alpha + /.basic_latin/lower_alpha]] ) <named> (template [<definition> <part>] [((: (-> Any (List /.Block)) @@ -155,7 +155,7 @@ Test (`` (_.cover [(~~ (template.splice <part>))] (let [all (list.concat (list <named>)) - unique (set.from-list /.hash all)] + unique (set.from_list /.hash all)] (n.= (list.size all) (set.size unique))))))] @@ -167,10 +167,10 @@ (<| (_.covering /._) (_.for [/.Block]) (do {! random.monad} - [#let [top-start (hex "AC00") - top-end (hex "D7AF")] - start (\ ! map (|>> (n.% top-start) inc) random.nat) - end (\ ! map (|>> (n.% top-end) inc) random.nat) + [#let [top_start (hex "AC00") + top_end (hex "D7AF")] + start (\ ! map (|>> (n.% top_start) inc) random.nat) + end (\ ! map (|>> (n.% top_end) inc) random.nat) #let [sample (/.block start end) size (/.size sample)] inside (\ ! map diff --git a/stdlib/source/test/lux/data/text/unicode/set.lux b/stdlib/source/test/lux/data/text/unicode/set.lux index 16e29d368..e32c08bfd 100644 --- a/stdlib/source/test/lux/data/text/unicode/set.lux +++ b/stdlib/source/test/lux/data/text/unicode/set.lux @@ -83,11 +83,11 @@ [/.ascii] [/.ascii/alpha] - [/.ascii/alpha-num] - [/.ascii/lower-alpha] - [/.ascii/upper-alpha] + [/.ascii/alpha_num] + [/.ascii/lower_alpha] + [/.ascii/upper_alpha] [/.character] - [/.non-character] + [/.non_character] [/.full] )) diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux index f5ba58758..9e8699c55 100644 --- a/stdlib/source/test/lux/extension.lux +++ b/stdlib/source/test/lux/extension.lux @@ -31,30 +31,30 @@ {1 ["." / (#+ analysis: synthesis: generation: directive:)]}) -(def: my-analysis "my analysis") -(def: my-synthesis "my synthesis") -(def: my-generation "my generation") -(def: my-directive "my directive") +(def: my_analysis "my analysis") +(def: my_synthesis "my synthesis") +(def: my_generation "my generation") +(def: my_directive "my directive") ## Generation (for {@.old - (as-is)} + (as_is)} - (as-is (analysis: (..my-generation self phase archive {parameters (<>.some <c>.any)}) + (as_is (analysis: (..my_generation self phase archive {parameters (<>.some <c>.any)}) (do phase.monad [_ (type.infer .Text)] (wrap (#analysis.Extension self (list))))) - (synthesis: (..my-generation self phase archive {parameters (<>.some <a>.any)}) + (synthesis: (..my_generation self phase archive {parameters (<>.some <a>.any)}) (do phase.monad [] (wrap (#synthesis.Extension self (list))))) )) (for {@.old - (as-is)} + (as_is)} - (generation: (..my-generation self phase archive {parameters (<>.some <s>.any)}) + (generation: (..my_generation self phase archive {parameters (<>.some <s>.any)}) (do phase.monad [] (wrap (for {@.jvm @@ -64,31 +64,31 @@ (js.string self)}))))) (for {@.old - (as-is)} + (as_is)} - (as-is (analysis: (..my-analysis self phase archive {parameters (<>.some <c>.any)}) + (as_is (analysis: (..my_analysis self phase archive {parameters (<>.some <c>.any)}) (do phase.monad [_ (type.infer .Text)] (wrap (#analysis.Primitive (#analysis.Text self))))) ## Synthesis - (analysis: (..my-synthesis self phase archive {parameters (<>.some <c>.any)}) + (analysis: (..my_synthesis self phase archive {parameters (<>.some <c>.any)}) (do phase.monad [_ (type.infer .Text)] (wrap (#analysis.Extension self (list))))) - (synthesis: (..my-synthesis self phase archive {parameters (<>.some <a>.any)}) + (synthesis: (..my_synthesis self phase archive {parameters (<>.some <a>.any)}) (do phase.monad [] (wrap (synthesis.text self)))) ## Directive - (directive: (..my-directive self phase archive {parameters (<>.some <c>.any)}) + (directive: (..my_directive self phase archive {parameters (<>.some <c>.any)}) (do phase.monad [#let [_ (log! (format "Successfully installed directive " (%.text self) "!"))]] - (wrap directive.no-requirements))) + (wrap directive.no_requirements))) - (`` ((~~ (static ..my-directive)))) + (`` ((~~ (static ..my_directive)))) )) (def: #export test @@ -102,9 +102,9 @@ (text\= (`` ((~~ (static <extension>)))) <extension>)))] - [/.analysis: ..my-analysis] - [/.synthesis: ..my-synthesis] - [/.generation: ..my-generation])) + [/.analysis: ..my_analysis] + [/.synthesis: ..my_synthesis] + [/.generation: ..my_generation])) (_.cover [/.directive:] true) )))) diff --git a/stdlib/source/test/lux/host.old.lux b/stdlib/source/test/lux/host.old.lux index 179a8a3b7..c18ef1f1e 100644 --- a/stdlib/source/test/lux/host.old.lux +++ b/stdlib/source/test/lux/host.old.lux @@ -53,13 +53,13 @@ (java/lang/Runnable [] (run self) void [])) -(def: test-runnable +(def: test_runnable (object [] [java/lang/Runnable] [] (java/lang/Runnable [] (run self) void []))) -(def: test-callable +(def: test_callable (object [a] [(java/util/concurrent/Callable a)] [] (java/util/concurrent/Callable [] (call self) a @@ -76,15 +76,15 @@ (~~ (template [<to> <from> <message>] [(_.test <message> (or (|> sample <to> <from> (i.= sample)) - (let [capped-sample (|> sample <to> <from>)] - (|> capped-sample <to> <from> (i.= capped-sample)))))] - - [/.long-to-byte /.byte-to-long "Can succesfully convert to/from byte."] - [/.long-to-short /.short-to-long "Can succesfully convert to/from short."] - [/.long-to-int /.int-to-long "Can succesfully convert to/from int."] - [/.long-to-float /.float-to-long "Can succesfully convert to/from float."] - [/.long-to-double /.double-to-long "Can succesfully convert to/from double."] - [(<| /.int-to-char /.long-to-int) (<| /.int-to-long /.char-to-int) "Can succesfully convert to/from char."] + (let [capped_sample (|> sample <to> <from>)] + (|> capped_sample <to> <from> (i.= capped_sample)))))] + + [/.long_to_byte /.byte_to_long "Can succesfully convert to/from byte."] + [/.long_to_short /.short_to_long "Can succesfully convert to/from short."] + [/.long_to_int /.int_to_long "Can succesfully convert to/from int."] + [/.long_to_float /.float_to_long "Can succesfully convert to/from float."] + [/.long_to_double /.double_to_long "Can succesfully convert to/from double."] + [(<| /.int_to_char /.long_to_int) (<| /.int_to_long /.char_to_int) "Can succesfully convert to/from char."] )) )))) @@ -103,7 +103,7 @@ (/.synchronized sample #1)) (_.test "Can access Class instances." - (text\= "java.lang.Class" (java/lang/Class::getName (/.class-for java/lang/Class)))) + (text\= "java.lang.Class" (java/lang/Class::getName (/.class_for java/lang/Class)))) (_.test "Can check if a value is null." (and (/.null? (/.null)) @@ -126,12 +126,12 @@ value r.int] ($_ _.and (_.test "Can create arrays of some length." - (n.= size (/.array-length (/.array java/lang/Long size)))) + (n.= size (/.array_length (/.array java/lang/Long size)))) (_.test "Can set and get array values." (let [arr (/.array java/lang/Long size)] - (exec (/.array-write idx value arr) - (i.= value (/.array-read idx arr))))) + (exec (/.array_write idx value arr) + (i.= value (/.array_read idx arr))))) ))) (def: #export test diff --git a/stdlib/source/test/lux/locale.lux b/stdlib/source/test/lux/locale.lux index b494779d3..5693eb2c4 100644 --- a/stdlib/source/test/lux/locale.lux +++ b/stdlib/source/test/lux/locale.lux @@ -21,27 +21,27 @@ ["." language (#+ Language)] ["." territory (#+ Territory)]]}) -(def: random-language +(def: random_language (Random Language) (random.either (random\wrap language.afar) (random\wrap language.zaza))) -(def: random-territory +(def: random_territory (Random Territory) (random.either (random\wrap territory.afghanistan) (random\wrap territory.zimbabwe))) -(def: random-encoding +(def: random_encoding (Random Encoding) (random.either (random\wrap encoding.ascii) - (random\wrap encoding.koi8-u))) + (random\wrap encoding.koi8_u))) -(def: random-locale +(def: random_locale (Random /.Locale) (do random.monad - [language ..random-language - territory ..random-territory - encoding ..random-encoding] + [language ..random_language + territory ..random_territory + encoding ..random_encoding] (wrap (/.locale language (#.Some territory) (#.Some encoding))))) (def: #export test @@ -50,28 +50,28 @@ (_.for [/.Locale]) ($_ _.and (_.for [/.equivalence] - ($equivalence.spec /.equivalence ..random-locale)) + ($equivalence.spec /.equivalence ..random_locale)) (do random.monad - [language ..random-language - territory ..random-territory - encoding ..random-encoding - #let [l-locale (/.locale language #.None #.None) - lt-locale (/.locale language (#.Some territory) #.None) - le-locale (/.locale language #.None (#.Some encoding)) - lte-locale (/.locale language (#.Some territory) (#.Some encoding))] - #let [language-check (and (text\= (language.code language) - (/.code l-locale)) - (list.every? (|>> /.code (text.starts-with? (language.code language))) - (list lt-locale le-locale lte-locale))) - territory-check (list.every? (|>> /.code (text.contains? (territory.long-code territory))) - (list lt-locale lte-locale)) - encoding-check (list.every? (|>> /.code (text.ends-with? (encoding.name encoding))) - (list le-locale lte-locale))]] + [language ..random_language + territory ..random_territory + encoding ..random_encoding + #let [l_locale (/.locale language #.None #.None) + lt_locale (/.locale language (#.Some territory) #.None) + le_locale (/.locale language #.None (#.Some encoding)) + lte_locale (/.locale language (#.Some territory) (#.Some encoding))] + #let [language_check (and (text\= (language.code language) + (/.code l_locale)) + (list.every? (|>> /.code (text.starts_with? (language.code language))) + (list lt_locale le_locale lte_locale))) + territory_check (list.every? (|>> /.code (text.contains? (territory.long_code territory))) + (list lt_locale lte_locale)) + encoding_check (list.every? (|>> /.code (text.ends_with? (encoding.name encoding))) + (list le_locale lte_locale))]] (_.cover [/.locale /.code] - (and language-check - territory-check - encoding-check))) + (and language_check + territory_check + encoding_check))) /language.test /territory.test diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux index fb31baa0e..6423b7627 100644 --- a/stdlib/source/test/lux/locale/language.lux +++ b/stdlib/source/test/lux/locale/language.lux @@ -36,17 +36,17 @@ languages (: (List /.Language) (`` (list (~~ (template.splice <languages>)))))] {#count count - #names (|> languages (list\map /.name) (set.from-list text.hash)) - #codes (|> languages (list\map /.code) (set.from-list text.hash)) - #languages (set.from-list /.hash languages) + #names (|> languages (list\map /.name) (set.from_list text.hash)) + #codes (|> languages (list\map /.code) (set.from_list text.hash)) + #languages (set.from_list /.hash languages) #test (_.cover <languages> true)}))] [languages/a [/.afar /.abkhazian /.achinese /.acoli /.adangme - /.adyghe /.afro-asiatic /.afrihili /.afrikaans /.ainu - /.akan /.akkadian /.aleut /.algonquian /.southern-altai - /.amharic /.old-english /.angika /.apache /.arabic - /.official-aramaic /.aragonese /.mapudungun /.arapaho /.artificial + /.adyghe /.afro_asiatic /.afrihili /.afrikaans /.ainu + /.akan /.akkadian /.aleut /.algonquian /.southern_altai + /.amharic /.old_english /.angika /.apache /.arabic + /.official_aramaic /.aragonese /.mapudungun /.arapaho /.artificial /.arawak /.assamese /.asturian /.athapascan /.australian /.avaric /.avestan /.awadhi /.aymara /.azerbaijani]] [languages/b [/.banda /.bamileke /.bashkir /.baluchi /.bambara @@ -55,87 +55,87 @@ /.bikol /.bini /.bislama /.siksika /.bantu /.tibetan /.bosnian /.braj /.breton /.batak /.buriat /.buginese /.bulgarian /.blin]] - [languages/c [/.caddo /.central-american-indian /.galibi-carib /.catalan /.caucasian + [languages/c [/.caddo /.central_american_indian /.galibi_carib /.catalan /.caucasian /.cebuano /.celtic /.czech /.chamorro /.chibcha /.chechen /.chagatai /.chuukese /.mari /.chinook - /.choctaw /.chipewyan /.cherokee /.church-slavic /.chuvash + /.choctaw /.chipewyan /.cherokee /.church_slavic /.chuvash /.cheyenne /.chamic /.montenegrin /.coptic /.cornish - /.corsican /.creoles-and-pidgins/english /.creoles-and-pidgins/french /.creoles-and-pidgins/portuguese /.cree - /.crimean /.creoles-and-pidgins /.kashubian /.cushitic /.welsh]] - [languages/d [/.dakota /.danish /.dargwa /.land-dayak /.delaware + /.corsican /.creoles_and_pidgins/english /.creoles_and_pidgins/french /.creoles_and_pidgins/portuguese /.cree + /.crimean /.creoles_and_pidgins /.kashubian /.cushitic /.welsh]] + [languages/d [/.dakota /.danish /.dargwa /.land_dayak /.delaware /.slavey /.dogrib /.dinka /.dhivehi /.dogri - /.dravidian /.lower-sorbian /.duala /.middle-dutch /.dyula + /.dravidian /.lower_sorbian /.duala /.middle_dutch /.dyula /.dzongkha]] [languages/e [/.efik /.egyptian /.ekajuk /.greek /.elamite - /.english /.middle-english /.esperanto /.estonian /.basque + /.english /.middle_english /.esperanto /.estonian /.basque /.ewe /.ewondo]] [languages/f [/.fang /.faroese /.persian /.fanti /.fijian - /.filipino /.finnish /.finno-ugrian /.fon /.french - /.middle-french /.old-french /.northern-frisian /.eastern-frisian /.western-frisian + /.filipino /.finnish /.finno_ugrian /.fon /.french + /.middle_french /.old_french /.northern_frisian /.eastern_frisian /.western_frisian /.fulah /.friulian]] [languages/g [/.ga /.gayo /.gbaya /.germanic /.german /.geez /.gilbertese /.gaelic /.irish /.galician - /.manx /.middle-high-german /.old-high-german /.gondi /.gorontalo - /.gothic /.grebo /.ancient-greek /.guarani /.swiss-german + /.manx /.middle_high_german /.old_high_german /.gondi /.gorontalo + /.gothic /.grebo /.ancient_greek /.guarani /.swiss_german /.gujarati /.gwich'in]] [languages/h [/.haida /.haitian /.hausa /.hawaiian /.hebrew /.herero /.hiligaynon /.himachali /.hindi /.hittite - /.hmong /.hiri-motu /.croatian /.upper-sorbian /.hungarian + /.hmong /.hiri_motu /.croatian /.upper_sorbian /.hungarian /.hupa /.armenian]] - [languages/i [/.iban /.igbo /.ido /.sichuan-yi /.ijo + [languages/i [/.iban /.igbo /.ido /.sichuan_yi /.ijo /.inuktitut /.interlingue /.iloko /.interlingua /.indic - /.indonesian /.indo-european /.ingush /.inupiaq /.iranian + /.indonesian /.indo_european /.ingush /.inupiaq /.iranian /.iroquoian /.icelandic /.italian]] - [languages/j [/.javanese /.lojban /.japanese /.judeo-persian /.judeo-arabic]] - [languages/k [/.kara-kalpak /.kabyle /.kachin /.kalaallisut /.kamba + [languages/j [/.javanese /.lojban /.japanese /.judeo_persian /.judeo_arabic]] + [languages/k [/.kara_kalpak /.kabyle /.kachin /.kalaallisut /.kamba /.kannada /.karen /.kashmiri /.georgian /.kanuri /.kawi /.kazakh /.kabardian /.khasi /.khoisan - /.central-khmer /.khotanese /.gikuyu /.kinyarwanda /.kyrgyz + /.central_khmer /.khotanese /.gikuyu /.kinyarwanda /.kyrgyz /.kimbundu /.konkani /.komi /.kongo /.korean - /.kosraean /.kpelle /.karachay-balkar /.karelian /.kru + /.kosraean /.kpelle /.karachay_balkar /.karelian /.kru /.kurukh /.kwanyama /.kumyk /.kurdish /.kutenai]] [languages/l [/.ladino /.lahnda /.lamba /.lao /.latin /.latvian /.lezghian /.limburgan /.lingala /.lithuanian - /.mongo /.lozi /.luxembourgish /.luba-lulua /.luba-katanga + /.mongo /.lozi /.luxembourgish /.luba_lulua /.luba_katanga /.ganda /.luiseno /.lunda /.luo /.lushai]] [languages/m [/.madurese /.magahi /.marshallese /.maithili /.makasar /.malayalam /.mandingo /.austronesian /.marathi /.masai - /.moksha /.mandar /.mende /.middle-irish /.mi'kmaq - /.minangkabau /.macedonian /.mon-khmer /.malagasy /.maltese + /.moksha /.mandar /.mende /.middle_irish /.mi'kmaq + /.minangkabau /.macedonian /.mon_khmer /.malagasy /.maltese /.manchu /.manipuri /.manobo /.mohawk /.mongolian /.mossi /.maori /.malay /.munda /.creek /.mirandese /.marwari /.burmese /.mayan /.erzya]] - [languages/n [/.nahuatl /.north-american-indian /.neapolitan /.nauru /.navajo - /.south-ndebele /.north-ndebele /.ndonga /.low-german /.nepali - /.newari /.nias /.niger-kordofanian /.niuean /.dutch - /.nynorsk /.bokmal /.nogai /.old-norse /.norwegian - /.n'ko /.northern-sotho /.nubian /.old-newari /.nyanja + [languages/n [/.nahuatl /.north_american_indian /.neapolitan /.nauru /.navajo + /.south_ndebele /.north_ndebele /.ndonga /.low_german /.nepali + /.newari /.nias /.niger_kordofanian /.niuean /.dutch + /.nynorsk /.bokmal /.nogai /.old_norse /.norwegian + /.n'ko /.northern_sotho /.nubian /.old_newari /.nyanja /.nyamwezi /.nyankole /.nyoro /.nzima]] [languages/o [/.occitan /.ojibwa /.oriya /.oromo /.osage - /.ossetic /.ottoman-turkish /.otomian]] + /.ossetic /.ottoman_turkish /.otomian]] [languages/p [/.papuan /.pangasinan /.pahlavi /.pampanga /.punjabi - /.papiamento /.palauan /.old-persian /.philippine /.phoenician + /.papiamento /.palauan /.old_persian /.philippine /.phoenician /.pali /.polish /.pohnpeian /.portuguese /.prakrit - /.old-provencal /.pashto]] + /.old_provencal /.pashto]] [languages/q [/.quechua]] [languages/r [/.rajasthani /.rapanui /.rarotongan /.romance /.romansh /.romany /.romanian /.rundi /.aromanian /.russian]] - [languages/s [/.sandawe /.sango /.yakut /.south-american-indian /.salishan - /.samaritan-aramaic /.sanskrit /.sasak /.santali /.sicilian - /.scots /.selkup /.semitic /.old-irish /.sign - /.shan /.sidamo /.sinhalese /.siouan /.sino-tibetan - /.slavic /.slovak /.slovenian /.southern-sami /.northern-sami - /.sami /.lule /.inari /.samoan /.skolt-sami + [languages/s [/.sandawe /.sango /.yakut /.south_american_indian /.salishan + /.samaritan_aramaic /.sanskrit /.sasak /.santali /.sicilian + /.scots /.selkup /.semitic /.old_irish /.sign + /.shan /.sidamo /.sinhalese /.siouan /.sino_tibetan + /.slavic /.slovak /.slovenian /.southern_sami /.northern_sami + /.sami /.lule /.inari /.samoan /.skolt_sami /.shona /.sindhi /.soninke /.sogdian /.somali - /.songhai /.southern-sotho /.spanish /.albanian /.sardinian - /.sranan-tongo /.serbian /.serer /.nilo-saharan /.swati + /.songhai /.southern_sotho /.spanish /.albanian /.sardinian + /.sranan_tongo /.serbian /.serer /.nilo_saharan /.swati /.sukuma /.sundanese /.susu /.sumerian /.swahili - /.swedish /.classical-syriac /.syriac]] + /.swedish /.classical_syriac /.syriac]] [languages/t [/.tahitian /.tai /.tamil /.tatar /.telugu /.timne /.tereno /.tetum /.tajik /.tagalog /.thai /.tigre /.tigrinya /.tiv /.tokelau /.klingon /.tlingit /.tamashek /.tonga /.tongan - /.tok-pisin /.tsimshian /.tswana /.tsonga /.turkmen + /.tok_pisin /.tsimshian /.tswana /.tsonga /.turkmen /.tumbuka /.tupi /.turkish /.altaic /.tuvalu /.twi /.tuvinian]] [languages/u [/.udmurt /.ugaritic /.uyghur /.ukrainian /.umbundu @@ -145,9 +145,9 @@ /.walloon /.wolof]] [languages/x [/.kalmyk /.xhosa]] [languages/y [/.yao /.yapese /.yiddish /.yoruba /.yupik]] - [languages/z [/.zapotec /.blissymbols /.zenaga /.standard-moroccan-tamazight /.zhuang + [languages/z [/.zapotec /.blissymbols /.zenaga /.standard_moroccan_tamazight /.zhuang /.chinese /.zande /.zulu /.zuni /.zaza]] - [languages/etc [/.uncoded /.multiple /.undetermined /.not-applicable]] + [languages/etc [/.uncoded /.multiple /.undetermined /.not_applicable]] ) (def: languages @@ -191,7 +191,7 @@ [0 (set.new hash)] territories)) -(def: languages-test +(def: languages_test Test (|> ..languages list.reverse @@ -214,24 +214,24 @@ (list.every? (\ /.equivalence = <reference>) (`` (list (~~ (template.splice <aliases>))))))) -(def: aliases-test +(def: aliases_test Test ($_ _.and ## A - (!aliases /.official-aramaic [/.imperial-aramaic]) + (!aliases /.official_aramaic [/.imperial_aramaic]) (!aliases /.asturian [/.bable /.leonese /.asturleonese]) ## B (!aliases /.bini [/.edo]) (!aliases /.blin [/.bilin]) ## C (!aliases /.catalan [/.valencian]) - (!aliases /.church-slavic [/.old-slavonic /.church-slavonic /.old-bulgarian /.old-church-slavonic]) + (!aliases /.church_slavic [/.old_slavonic /.church_slavonic /.old_bulgarian /.old_church_slavonic]) ## D (!aliases /.dhivehi [/.maldivian]) ## G - (!aliases /.swiss-german [/.alemannic /.alsatian]) + (!aliases /.swiss_german [/.alemannic /.alsatian]) ## I - (!aliases /.sichuan-yi [/.nuosu]) + (!aliases /.sichuan_yi [/.nuosu]) ## K (!aliases /.kachin [/.jingpho]) (!aliases /.kalaallisut [/.greenlandic]) @@ -239,19 +239,19 @@ ## M (!aliases /.mi'kmaq [/.micmac]) ## N - (!aliases /.newari [/.nepal-bhasa]) + (!aliases /.newari [/.nepal_bhasa]) (!aliases /.dutch [/.flemish]) - (!aliases /.northern-sotho [/.pedi /.sepedi]) - (!aliases /.old-newari [/.classical-newari /.classical-nepal-bhasa]) + (!aliases /.northern_sotho [/.pedi /.sepedi]) + (!aliases /.old_newari [/.classical_newari /.classical_nepal_bhasa]) (!aliases /.nyanja [/.chichewa /.chewa]) ## O (!aliases /.occitan [/.provencal]) ## P (!aliases /.pampanga [/.kapampangan]) ## R - (!aliases /.rarotongan [/.cook-islands-maori]) + (!aliases /.rarotongan [/.cook_islands_maori]) (!aliases /.romanian [/.moldavian /.moldovan]) - (!aliases /.aromanian [/.arumanian /.macedo-romanian]) + (!aliases /.aromanian [/.arumanian /.macedo_romanian]) ## S (!aliases /.spanish [/.castilian]) ## X @@ -263,7 +263,7 @@ (def: #export random (Random /.Language) (let [options (|> ..languages - (list\map (|>> (get@ #languages) set.to-list)) + (list\map (|>> (get@ #languages) set.to_list)) list.concat)] (do {! random.monad} [choice (\ ! map (n.% (list.size options)) @@ -278,6 +278,6 @@ (_.for [/.hash] ($hash.spec /.hash ..random)) - ..languages-test - ..aliases-test + ..languages_test + ..aliases_test ))) diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux index 4fc425804..86a44cf3a 100644 --- a/stdlib/source/test/lux/locale/territory.lux +++ b/stdlib/source/test/lux/locale/territory.lux @@ -37,74 +37,74 @@ (let [count (template.count <territories>) territories (`` (list (~~ (template.splice <territories>))))] {#count count - #names (|> territories (list\map /.name) (set.from-list text.hash)) - #shorts (|> territories (list\map /.short-code) (set.from-list text.hash)) - #longs (|> territories (list\map /.long-code) (set.from-list text.hash)) - #numbers (|> territories (list\map /.numeric-code) (set.from-list n.hash)) - #territories (|> territories (set.from-list /.hash)) + #names (|> territories (list\map /.name) (set.from_list text.hash)) + #shorts (|> territories (list\map /.short_code) (set.from_list text.hash)) + #longs (|> territories (list\map /.long_code) (set.from_list text.hash)) + #numbers (|> territories (list\map /.numeric_code) (set.from_list n.hash)) + #territories (|> territories (set.from_list /.hash)) #test (_.cover <territories> true)}))] - [territories/a [/.afghanistan /.aland-islands /.albania /.algeria /.american-samoa + [territories/a [/.afghanistan /.aland_islands /.albania /.algeria /.american_samoa /.andorra /.angola /.anguilla /.antarctica /.antigua /.argentina /.armenia /.aruba /.australia /.austria /.azerbaijan]] - [territories/b [/.the-bahamas /.bahrain /.bangladesh /.barbados /.belarus + [territories/b [/.the_bahamas /.bahrain /.bangladesh /.barbados /.belarus /.belgium /.belize /.benin /.bermuda /.bhutan - /.bolivia /.bonaire /.bosnia /.botswana /.bouvet-island - /.brazil /.british-indian-ocean-territory /.brunei-darussalam /.bulgaria /.burkina-faso + /.bolivia /.bonaire /.bosnia /.botswana /.bouvet_island + /.brazil /.british_indian_ocean_territory /.brunei_darussalam /.bulgaria /.burkina_faso /.burundi]] - [territories/c [/.cape-verde /.cambodia /.cameroon /.canada /.cayman-islands - /.central-african-republic /.chad /.chile /.china /.christmas-island - /.cocos-islands /.colombia /.comoros /.congo /.democratic-republic-of-the-congo - /.cook-islands /.costa-rica /.ivory-coast /.croatia /.cuba - /.curacao /.cyprus /.czech-republic]] - [territories/d [/.denmark /.djibouti /.dominica /.dominican-republic]] - [territories/e [/.ecuador /.egypt /.el-salvador /.equatorial-guinea /.eritrea + [territories/c [/.cape_verde /.cambodia /.cameroon /.canada /.cayman_islands + /.central_african_republic /.chad /.chile /.china /.christmas_island + /.cocos_islands /.colombia /.comoros /.congo /.democratic_republic_of_the_congo + /.cook_islands /.costa_rica /.ivory_coast /.croatia /.cuba + /.curacao /.cyprus /.czech_republic]] + [territories/d [/.denmark /.djibouti /.dominica /.dominican_republic]] + [territories/e [/.ecuador /.egypt /.el_salvador /.equatorial_guinea /.eritrea /.estonia /.eswatini /.ethiopia]] - [territories/f [/.falkland-islands /.faroe-islands /.fiji /.finland /.france - /.french-guiana /.french-polynesia /.french-southern-territories]] - [territories/g [/.gabon /.the-gambia /.georgia /.germany /.ghana + [territories/f [/.falkland_islands /.faroe_islands /.fiji /.finland /.france + /.french_guiana /.french_polynesia /.french_southern_territories]] + [territories/g [/.gabon /.the_gambia /.georgia /.germany /.ghana /.gibraltar /.greece /.greenland /.grenada /.guadeloupe - /.guam /.guatemala /.guernsey /.guinea /.guinea-bissau + /.guam /.guatemala /.guernsey /.guinea /.guinea_bissau /.guyana]] - [territories/h [/.haiti /.heard-island /.honduras /.hong-kong + [territories/h [/.haiti /.heard_island /.honduras /.hong_kong /.hungary]] [territories/i [/.iceland /.india /.indonesia /.iran /.iraq - /.ireland /.isle-of-man /.israel /.italy]] + /.ireland /.isle_of_man /.israel /.italy]] [territories/j [/.jamaica /.japan /.jersey /.jordan]] - [territories/k [/.kazakhstan /.kenya /.kiribati /.north-korea /.south-korea + [territories/k [/.kazakhstan /.kenya /.kiribati /.north_korea /.south_korea /.kuwait /.kyrgyzstan]] [territories/l [/.laos /.latvia /.lebanon /.lesotho /.liberia /.libya /.liechtenstein /.lithuania /.luxembourg]] [territories/m [/.macau /.macedonia /.madagascar /.malawi /.malaysia - /.maldives /.mali /.malta /.marshall-islands /.martinique + /.maldives /.mali /.malta /.marshall_islands /.martinique /.mauritania /.mauritius /.mayotte /.mexico /.micronesia /.moldova /.monaco /.mongolia /.montenegro /.montserrat /.morocco /.mozambique /.myanmar]] - [territories/n [/.namibia /.nauru /.nepal /.netherlands /.new-caledonia - /.new-zealand /.nicaragua /.niger /.nigeria /.niue - /.norfolk-island /.northern-mariana-islands /.norway]] + [territories/n [/.namibia /.nauru /.nepal /.netherlands /.new_caledonia + /.new_zealand /.nicaragua /.niger /.nigeria /.niue + /.norfolk_island /.northern_mariana_islands /.norway]] [territories/o [/.oman]] - [territories/p [/.pakistan /.palau /.palestine /.panama /.papua-new-guinea - /.paraguay /.peru /.philippines /.pitcairn-islands /.poland - /.portugal /.puerto-rico]] + [territories/p [/.pakistan /.palau /.palestine /.panama /.papua_new_guinea + /.paraguay /.peru /.philippines /.pitcairn_islands /.poland + /.portugal /.puerto_rico]] [territories/q [/.qatar]] [territories/r [/.reunion /.romania /.russia /.rwanda]] - [territories/s [/.saint-barthelemy /.saint-helena /.saint-kitts /.saint-lucia /.saint-martin - /.saint-pierre /.saint-vincent /.samoa /.san-marino /.sao-tome - /.saudi-arabia /.senegal /.serbia /.seychelles /.sierra-leone - /.singapore /.sint-maarten /.slovakia /.slovenia /.solomon-islands - /.somalia /.south-africa /.south-georgia /.south-sudan /.spain - /.sri-lanka /.sudan /.suriname /.svalbard /.sweden + [territories/s [/.saint_barthelemy /.saint_helena /.saint_kitts /.saint_lucia /.saint_martin + /.saint_pierre /.saint_vincent /.samoa /.san_marino /.sao_tome + /.saudi_arabia /.senegal /.serbia /.seychelles /.sierra_leone + /.singapore /.sint_maarten /.slovakia /.slovenia /.solomon_islands + /.somalia /.south_africa /.south_georgia /.south_sudan /.spain + /.sri_lanka /.sudan /.suriname /.svalbard /.sweden /.switzerland /.syria]] - [territories/t [/.taiwan /.tajikistan /.tanzania /.thailand /.east-timor + [territories/t [/.taiwan /.tajikistan /.tanzania /.thailand /.east_timor /.togo /.tokelau /.tonga /.trinidad /.tunisia /.turkey /.turkmenistan /.turks /.tuvalu]] - [territories/u [/.uganda /.ukraine /.united-arab-emirates /.united-kingdom /.united-states-of-america - /.united-states-minor-outlying-islands /.uruguay /.uzbekistan]] - [territories/v [/.vanuatu /.vatican-city /.venezuela /.vietnam /.british-virgin-islands /.united-states-virgin-islands]] - [territories/w [/.wallis /.western-sahara]] + [territories/u [/.uganda /.ukraine /.united_arab_emirates /.united_kingdom /.united_states_of_america + /.united_states_minor_outlying_islands /.uruguay /.uzbekistan]] + [territories/v [/.vanuatu /.vatican_city /.venezuela /.vietnam /.british_virgin_islands /.united_states_virgin_islands]] + [territories/w [/.wallis /.western_sahara]] [territories/y [/.yemen]] [territories/z [/.zambia /.zimbabwe]] ) @@ -148,7 +148,7 @@ [0 (set.new hash)] territories)) -(def: territories-test +(def: territories_test Test (|> ..territories list.reverse @@ -161,9 +161,9 @@ (n.= count (set.size set))))] [/.name #names text.hash] - [/.short-code #shorts text.hash] - [/.long-code #longs text.hash] - [/.numeric-code #numbers n.hash] + [/.short_code #shorts text.hash] + [/.long_code #longs text.hash] + [/.numeric_code #numbers n.hash] [/.equivalence #territories /.hash] )) ))))) @@ -173,29 +173,29 @@ (list.every? (\ /.equivalence = <reference>) (`` (list (~~ (template.splice <aliases>))))))) -(def: aliases-test +(def: aliases_test Test ($_ _.and ## A (!aliases /.antigua [/.barbuda]) ## B - (!aliases /.bonaire [/.sint-eustatius /.saba]) + (!aliases /.bonaire [/.sint_eustatius /.saba]) (!aliases /.bosnia [/.herzegovina]) ## H - (!aliases /.heard-island [/.mcdonald-islands]) + (!aliases /.heard_island [/.mcdonald_islands]) ## S - (!aliases /.saint-helena [/.ascension /.tristan-da-cunha]) - (!aliases /.saint-kitts [/.nevis]) - (!aliases /.saint-pierre [/.miquelon]) - (!aliases /.saint-vincent [/.the-grenadines]) - (!aliases /.sao-tome [/.principe]) - (!aliases /.south-georgia [/.south-sandwich-islands]) - (!aliases /.svalbard [/.jan-mayen]) + (!aliases /.saint_helena [/.ascension /.tristan_da_cunha]) + (!aliases /.saint_kitts [/.nevis]) + (!aliases /.saint_pierre [/.miquelon]) + (!aliases /.saint_vincent [/.the_grenadines]) + (!aliases /.sao_tome [/.principe]) + (!aliases /.south_georgia [/.south_sandwich_islands]) + (!aliases /.svalbard [/.jan_mayen]) ## T (!aliases /.trinidad [/.tobago]) - (!aliases /.turks [/.caicos-islands]) + (!aliases /.turks [/.caicos_islands]) ## U - (!aliases /.united-kingdom [/.northern-ireland]) + (!aliases /.united_kingdom [/.northern_ireland]) ## W (!aliases /.wallis [/.futuna]) )) @@ -203,7 +203,7 @@ (def: #export random (Random /.Territory) (let [options (|> ..territories - (list\map (|>> (get@ #territories) set.to-list)) + (list\map (|>> (get@ #territories) set.to_list)) list.concat)] (do {! random.monad} [choice (\ ! map (n.% (list.size options)) @@ -218,6 +218,6 @@ (_.for [/.hash] ($hash.spec /.hash ..random)) - ..territories-test - ..aliases-test + ..territories_test + ..aliases_test ))) diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux index 8f6dc91d5..cbaa5aee7 100644 --- a/stdlib/source/test/lux/macro/code.lux +++ b/stdlib/source/test/lux/macro/code.lux @@ -27,21 +27,21 @@ {1 ["." /]}) -(def: random-text +(def: random_text (Random Text) (random.ascii/alpha 10)) -(def: random-name +(def: random_name (Random Name) - (random.and ..random-text ..random-text)) + (random.and ..random_text ..random_text)) -(def: (random-sequence random) +(def: (random_sequence random) (All [a] (-> (Random a) (Random (List a)))) (do {! random.monad} [size (|> random.nat (\ ! map (n.% 3)))] (random.list size random))) -(def: (random-record random) +(def: (random_record random) (All [a] (-> (Random a) (Random (List [a a])))) (do {! random.monad} [size (|> random.nat (\ ! map (n.% 3)))] @@ -56,39 +56,39 @@ (random\map /.nat random.nat) (random\map /.int random.int) (random\map /.rev random.rev) - (random\map /.frac random.safe-frac) - (random\map /.text ..random-text) - (random\map /.identifier ..random-name) - (random\map /.tag ..random-name) - (random\map /.form (..random-sequence random)) - (random\map /.tuple (..random-sequence random)) - (random\map /.record (..random-record random)) + (random\map /.frac random.safe_frac) + (random\map /.text ..random_text) + (random\map /.identifier ..random_name) + (random\map /.tag ..random_name) + (random\map /.form (..random_sequence random)) + (random\map /.tuple (..random_sequence random)) + (random\map /.record (..random_record random)) )))) -(def: (read source-code) +(def: (read source_code) (-> Text (Try Code)) (let [parse (syntax.parse "" - syntax.no-aliases - (text.size source-code)) + syntax.no_aliases + (text.size source_code)) start (: Source - [location.dummy 0 source-code])] + [location.dummy 0 source_code])] (case (parse start) (#.Left [end error]) (#try.Failure error) - (#.Right [end lux-code]) - (#try.Success lux-code)))) + (#.Right [end lux_code]) + (#try.Success lux_code)))) -(def: (replace-simulation [original substitute]) +(def: (replace_simulation [original substitute]) (-> [Code Code] (Random [Code Code])) (random.rec - (function (_ replace-simulation) - (let [for-sequence (: (-> (-> (List Code) Code) (Random [Code Code])) - (function (_ to-code) + (function (_ replace_simulation) + (let [for_sequence (: (-> (-> (List Code) Code) (Random [Code Code])) + (function (_ to_code) (do {! random.monad} - [parts (..random-sequence replace-simulation)] - (wrap [(to-code (list\map product.left parts)) - (to-code (list\map product.right parts))]))))] + [parts (..random_sequence replace_simulation)] + (wrap [(to_code (list\map product.left parts)) + (to_code (list\map product.right parts))]))))] ($_ random.either (random\wrap [original substitute]) (do {! random.monad} @@ -98,15 +98,15 @@ (random\map /.nat random.nat) (random\map /.int random.int) (random\map /.rev random.rev) - (random\map /.frac random.safe-frac) - (random\map /.text ..random-text) - (random\map /.identifier ..random-name) - (random\map /.tag ..random-name)))] + (random\map /.frac random.safe_frac) + (random\map /.text ..random_text) + (random\map /.identifier ..random_name) + (random\map /.tag ..random_name)))] (wrap [sample sample])) - (for-sequence /.form) - (for-sequence /.tuple) + (for_sequence /.form) + (for_sequence /.tuple) (do {! random.monad} - [parts (..random-sequence replace-simulation)] + [parts (..random_sequence replace_simulation)] (wrap [(/.record (let [parts' (list\map product.left parts)] (list.zip/2 parts' parts'))) (/.record (let [parts' (list\map product.right parts)] @@ -141,13 +141,13 @@ [/.nat random.nat #.Nat] [/.int random.int #.Int] [/.rev random.rev #.Rev] - [/.frac random.safe-frac #.Frac] - [/.text ..random-text #.Text] - [/.tag ..random-name #.Tag] - [/.identifier ..random-name #.Identifier] - [/.form (..random-sequence ..random) #.Form] - [/.tuple (..random-sequence ..random) #.Tuple] - [/.record (..random-record ..random) #.Record])) + [/.frac random.safe_frac #.Frac] + [/.text ..random_text #.Text] + [/.tag ..random_name #.Tag] + [/.identifier ..random_name #.Identifier] + [/.form (..random_sequence ..random) #.Form] + [/.tuple (..random_sequence ..random) #.Tuple] + [/.record (..random_record ..random) #.Record])) (~~ (template [<coverage> <random> <tag>] [(do {! random.monad} [expected <random>] @@ -165,12 +165,12 @@ (<coverage> expected))) ))] - [/.local-tag ..random-text #.Tag] - [/.local-identifier ..random-text #.Identifier] + [/.local_tag ..random_text #.Tag] + [/.local_identifier ..random_text #.Identifier] ))))) (do {! random.monad} [[original substitute] (random.and ..random ..random) - [sample expected] (..replace-simulation [original substitute])] + [sample expected] (..replace_simulation [original substitute])] (_.cover [/.replace] (\ /.equivalence = expected diff --git a/stdlib/source/test/lux/macro/poly/equivalence.lux b/stdlib/source/test/lux/macro/poly/equivalence.lux index 16903ebc2..51315ec1e 100644 --- a/stdlib/source/test/lux/macro/poly/equivalence.lux +++ b/stdlib/source/test/lux/macro/poly/equivalence.lux @@ -41,43 +41,43 @@ #tuple [Int Frac Text] #recursive Recursive}) -(def: gen-recursive +(def: gen_recursive (Random Recursive) - (random.rec (function (_ gen-recursive) - (random.or random.safe-frac - (random.and random.safe-frac - gen-recursive))))) + (random.rec (function (_ gen_recursive) + (random.or random.safe_frac + (random.and random.safe_frac + gen_recursive))))) -(def: gen-record +(def: gen_record (Random Record) (do {! random.monad} [size (\ ! map (n.% 2) random.nat) - #let [gen-int (|> random.int (\ ! map (|>> i.abs (i.% +1,000,000))))]] + #let [gen_int (|> random.int (\ ! map (|>> i.abs (i.% +1,000,000))))]] ($_ random.and random.bit - gen-int - random.safe-frac + gen_int + random.safe_frac (random.unicode size) - (random.maybe gen-int) - (random.list size gen-int) + (random.maybe gen_int) + (random.list size gen_int) ($_ random.or random.bit - gen-int - random.safe-frac) + gen_int + random.safe_frac) ($_ random.and - gen-int - random.safe-frac + gen_int + random.safe_frac (random.unicode size)) - gen-recursive))) + gen_recursive))) (derived: equivalence (/.equivalence Record)) (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) (do random.monad - [sample gen-record + [sample gen_record #let [(^open "/\.") ..equivalence]] (_.test "Every instance equals itself." (/\= sample sample))))) diff --git a/stdlib/source/test/lux/macro/poly/functor.lux b/stdlib/source/test/lux/macro/poly/functor.lux index 85d24bc5b..3f2b4db50 100644 --- a/stdlib/source/test/lux/macro/poly/functor.lux +++ b/stdlib/source/test/lux/macro/poly/functor.lux @@ -15,13 +15,13 @@ [macro [poly (#+ derived:)]]]) -(derived: maybe-functor (/.functor .Maybe)) -(derived: list-functor (/.functor .List)) -(derived: state-functor (/.functor state.State)) -(derived: identity-functor (/.functor identity.Identity)) +(derived: maybe_functor (/.functor .Maybe)) +(derived: list_functor (/.functor .List)) +(derived: state_functor (/.functor state.State)) +(derived: identity_functor (/.functor identity.Identity)) (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) (_.test "Can derive functors automatically." true))) diff --git a/stdlib/source/test/lux/macro/poly/json.lux b/stdlib/source/test/lux/macro/poly/json.lux index 4b6718577..b6b3a29e2 100644 --- a/stdlib/source/test/lux/macro/poly/json.lux +++ b/stdlib/source/test/lux/macro/poly/json.lux @@ -75,32 +75,32 @@ #date tda.Date #grams (unit.Qty unit.Gram)}) -(def: gen-recursive +(def: gen_recursive (Random Recursive) (random.rec - (function (_ gen-recursive) - (random.or random.safe-frac - (random.and random.safe-frac - gen-recursive))))) + (function (_ gen_recursive) + (random.or random.safe_frac + (random.and random.safe_frac + gen_recursive))))) (def: qty (All [unit] (Random (unit.Qty unit))) (|> random.int (\ random.monad map unit.in))) -(def: gen-record +(def: gen_record (Random Record) (do {! random.monad} [size (\ ! map (n.% 2) random.nat)] ($_ random.and random.bit - random.safe-frac + random.safe_frac (random.unicode size) - (random.maybe random.safe-frac) - (random.list size random.safe-frac) - (random.dictionary text.hash size (random.unicode size) random.safe-frac) - ($_ random.or random.bit (random.unicode size) random.safe-frac) - ($_ random.and random.bit (random.unicode size) random.safe-frac) - ..gen-recursive + (random.maybe random.safe_frac) + (random.list size random.safe_frac) + (random.dictionary text.hash size (random.unicode size) random.safe_frac) + ($_ random.or random.bit (random.unicode size) random.safe_frac) + ($_ random.and random.bit (random.unicode size) random.safe_frac) + ..gen_recursive ## _instant.instant ## _duration.duration _date.date @@ -117,4 +117,4 @@ Test (<| (_.covering /._) (_.for [/.codec] - ($codec.spec ..equivalence ..codec ..gen-record)))) + ($codec.spec ..equivalence ..codec ..gen_record)))) diff --git a/stdlib/source/test/lux/macro/syntax.lux b/stdlib/source/test/lux/macro/syntax.lux index 90efa671f..316734d36 100644 --- a/stdlib/source/test/lux/macro/syntax.lux +++ b/stdlib/source/test/lux/macro/syntax.lux @@ -68,7 +68,7 @@ (~' _) #0))))) -(def: simple-values +(def: simple_values Test (`` ($_ _.and (~~ (template [<assertion> <value> <ctor> <Equivalence> <get>] @@ -82,25 +82,25 @@ ["Can parse Int syntax." +123 code.int int.equivalence s.int] ["Can parse Rev syntax." .123 code.rev rev.equivalence s.rev] ["Can parse Frac syntax." +123.0 code.frac frac.equivalence s.frac] - ["Can parse Text syntax." text.new-line code.text text.equivalence s.text] + ["Can parse Text syntax." text.new_line code.text text.equivalence s.text] ["Can parse Identifier syntax." ["yolo" "lol"] code.identifier name.equivalence s.identifier] ["Can parse Tag syntax." ["yolo" "lol"] code.tag name.equivalence s.tag] )) (_.test "Can parse identifiers belonging to the current namespace." (and (match "yolo" - (p.run s.local-identifier - (list (code.local-identifier "yolo")))) - (fails? (p.run s.local-identifier + (p.run s.local_identifier + (list (code.local_identifier "yolo")))) + (fails? (p.run s.local_identifier (list (code.identifier ["yolo" "lol"])))))) (_.test "Can parse tags belonging to the current namespace." (and (match "yolo" - (p.run s.local-tag - (list (code.local-tag "yolo")))) - (fails? (p.run s.local-tag + (p.run s.local_tag + (list (code.local_tag "yolo")))) + (fails? (p.run s.local_tag (list (code.tag ["yolo" "lol"])))))) ))) -(def: complex-values +(def: complex_values Test (`` ($_ _.and (~~ (template [<type> <parser> <ctor>] @@ -132,10 +132,10 @@ (def: #export test Test - (<| (_.context (name.module (name-of /._))) + (<| (_.context (name.module (name_of /._))) ($_ _.and - ..simple-values - ..complex-values + ..simple_values + ..complex_values ($_ _.and (_.test "Can parse any Code." (match [_ (#.Bit #1)] diff --git a/stdlib/source/test/lux/macro/syntax/common.lux b/stdlib/source/test/lux/macro/syntax/common.lux index 592baa036..769a28439 100644 --- a/stdlib/source/test/lux/macro/syntax/common.lux +++ b/stdlib/source/test/lux/macro/syntax/common.lux @@ -33,25 +33,25 @@ ["#." definition] ["#." export]]) -(def: annotations-equivalence +(def: annotations_equivalence (Equivalence /.Annotations) (list.equivalence (product.equivalence name.equivalence code.equivalence))) -(def: random-text +(def: random_text (Random Text) (random.ascii/alpha 10)) -(def: random-name +(def: random_name (Random Name) - (random.and ..random-text ..random-text)) + (random.and ..random_text ..random_text)) -(def: random-annotations +(def: random_annotations (Random /.Annotations) (do {! random.monad} [size (\ ! map (|>> (n.% 3)) random.nat)] - (random.list size (random.and random-name + (random.list size (random.and random_name ///code.random)))) (def: #export test @@ -63,33 +63,33 @@ (_.for [/.Annotations] ($_ _.and (do random.monad - [expected ..random-annotations] + [expected ..random_annotations] (_.cover [/reader.annotations /writer.annotations] (|> expected /writer.annotations list (<c>.run /reader.annotations) (case> (#try.Success actual) - (\ ..annotations-equivalence = expected actual) + (\ ..annotations_equivalence = expected actual) (#try.Failure error) false)))) - (_.cover [/.empty-annotations] - (|> /.empty-annotations + (_.cover [/.empty_annotations] + (|> /.empty_annotations /writer.annotations list (<c>.run /reader.annotations) (case> (#try.Success actual) - (\ ..annotations-equivalence = /.empty-annotations actual) + (\ ..annotations_equivalence = /.empty_annotations actual) (#try.Failure error) false))) )) (do {! random.monad} [size (\ ! map (|>> (n.% 3)) random.nat) - expected (random.list size ..random-text)] - (_.cover [/.Type-Var /reader.type-variables /writer.type-variables] + expected (random.list size ..random_text)] + (_.cover [/.Type_Var /reader.type_variables /writer.type_variables] (|> expected - /writer.type-variables - (<c>.run /reader.type-variables) + /writer.type_variables + (<c>.run /reader.type_variables) (case> (#try.Success actual) (\ (list.equivalence text.equivalence) = expected actual) @@ -98,8 +98,8 @@ (do {! random.monad} [size (\ ! map (|>> (n.% 3)) random.nat) expected (: (Random /.Declaration) - (random.and ..random-text - (random.list size ..random-text)))] + (random.and ..random_text + (random.list size ..random_text)))] (_.cover [/.Declaration /reader.declaration /writer.declaration] (|> expected /writer.declaration list @@ -112,13 +112,13 @@ (#try.Failure error) false)))) (do {! random.monad} - [expected (: (Random /.Typed-Input) + [expected (: (Random /.Typed_Input) (random.and ///code.random ///code.random))] - (_.cover [/.Typed-Input /reader.typed-input /writer.typed-input] + (_.cover [/.Typed_Input /reader.typed_input /writer.typed_input] (|> expected - /writer.typed-input list - (<c>.run /reader.typed-input) + /writer.typed_input list + (<c>.run /reader.typed_input) (case> (#try.Success actual) (let [equivalence (product.equivalence code.equivalence code.equivalence)] (\ equivalence = expected actual)) diff --git a/stdlib/source/test/lux/macro/syntax/common/definition.lux b/stdlib/source/test/lux/macro/syntax/common/definition.lux index 18af3edaa..937f5319a 100644 --- a/stdlib/source/test/lux/macro/syntax/common/definition.lux +++ b/stdlib/source/test/lux/macro/syntax/common/definition.lux @@ -25,7 +25,7 @@ ["#//" /// #_ ["#." code]]]) -(def: random-annotations +(def: random_annotations (Random Annotations) (let [name (random.and (random.ascii/alpha 5) (random.ascii/alpha 5))] @@ -37,7 +37,7 @@ (random.ascii/alpha 5) (random.or $//check.random $////code.random) - ..random-annotations + ..random_annotations random.bit )) @@ -47,15 +47,15 @@ #.mode #.Build} #.source [location.dummy 0 ""] #.location location.dummy - #.current-module #.None + #.current_module #.None #.modules (list) #.scopes (list) - #.type-context {#.ex-counter 0 - #.var-counter 0 - #.var-bindings (list)} + #.type_context {#.ex_counter 0 + #.var_counter 0 + #.var_bindings (list)} #.expected #.None #.seed 0 - #.scope-type-vars (list) + #.scope_type_vars (list) #.extensions [] #.host []}) @@ -71,7 +71,7 @@ [expected ..random type $////code.random - untyped-value $////code.random] + untyped_value $////code.random] ($_ _.and (_.cover [/.write /.parser] (case (<code>.run (/.parser compiler) @@ -82,7 +82,7 @@ (#try.Success actual) (\ /.equivalence = expected actual))) (_.cover [/.typed] - (let [expected (set@ #/.value (#.Left [type untyped-value]) expected)] + (let [expected (set@ #/.value (#.Left [type untyped_value]) expected)] (case (<code>.run (/.typed compiler) (list (/.write expected))) (#try.Failure error) @@ -90,12 +90,12 @@ (#try.Success actual) (\ /.equivalence = expected actual)))) - (_.cover [/.lacks-type!] - (let [expected (set@ #/.value (#.Right untyped-value) expected)] + (_.cover [/.lacks_type!] + (let [expected (set@ #/.value (#.Right untyped_value) expected)] (case (<code>.run (/.typed compiler) (list (/.write expected))) (#try.Failure error) - (exception.match? /.lacks-type! error) + (exception.match? /.lacks_type! error) (#try.Success actual) false))) diff --git a/stdlib/source/test/lux/macro/template.lux b/stdlib/source/test/lux/macro/template.lux index 8fa6a00ca..902e84255 100644 --- a/stdlib/source/test/lux/macro/template.lux +++ b/stdlib/source/test/lux/macro/template.lux @@ -20,9 +20,9 @@ [left random.nat mid random.nat right random.nat] - (with-expansions [<module> (as-is [-8.9 +6.7 .5 -4 +3 2 #1 #0 #c b "a"]) + (with_expansions [<module> (as_is [-8.9 +6.7 .5 -4 +3 2 #1 #0 #c b "a"]) <module>' "-8.9+6.7.5-4+32#1#0cba" - <short> (as-is ["a" b #c #0 #1 2 +3 -4 .5 +6.7 -8.9]) + <short> (as_is ["a" b #c #0 #1 2 +3 -4 .5 +6.7 -8.9]) <short>' "abc#0#12+3-4.5+6.7-8.9"] ($_ _.and (_.cover [/.splice] @@ -38,23 +38,23 @@ <short>' true _ false)) (_.cover [/.identifier] - (and (case (`` (name-of (~~ (/.identifier <short>)))) + (and (case (`` (name_of (~~ (/.identifier <short>)))) ["" <short>'] true _ false) - (case (`` (name-of (~~ (/.identifier <module> <short>)))) + (case (`` (name_of (~~ (/.identifier <module> <short>)))) [<module>' <short>'] true _ false) )) (_.cover [/.tag] - (and (case (`` (name-of (~~ (/.tag <short>)))) + (and (case (`` (name_of (~~ (/.tag <short>)))) ["" <short>'] true _ false) - (case (`` (name-of (~~ (/.tag <module> <short>)))) + (case (`` (name_of (~~ (/.tag <module> <short>)))) [<module>' <short>'] true _ false) )) - (_.cover [/.with-locals] - (/.with-locals [var0 var1] + (_.cover [/.with_locals] + (/.with_locals [var0 var1] (let [var0 left var1 right] (and (nat.= left var0) diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux index bede0dd2c..d9741e6ad 100644 --- a/stdlib/source/test/lux/math.lux +++ b/stdlib/source/test/lux/math.lux @@ -19,36 +19,36 @@ ["#/." continuous] ["#/." fuzzy]]]) -(def: (within? margin-of-error standard value) +(def: (within? margin_of_error standard value) (-> Frac Frac Frac Bit) - (f.< margin-of-error + (f.< margin_of_error (f.abs (f.- standard value)))) (def: margin Frac +0.0000001) -(def: (trigonometric-symmetry forward backward angle) +(def: (trigonometric_symmetry forward backward angle) (-> (-> Frac Frac) (-> Frac Frac) Frac Bit) (let [normal (|> angle forward backward)] (|> normal forward backward (within? margin normal)))) (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) ($_ _.and (<| (_.context "Trigonometry") (do {! r.monad} - [angle (|> r.safe-frac (\ ! map (f.* /.tau)))] + [angle (|> r.safe_frac (\ ! map (f.* /.tau)))] ($_ _.and (_.test "Sine and arc-sine are inverse functions." - (trigonometric-symmetry /.sin /.asin angle)) + (trigonometric_symmetry /.sin /.asin angle)) (_.test "Cosine and arc-cosine are inverse functions." - (trigonometric-symmetry /.cos /.acos angle)) + (trigonometric_symmetry /.cos /.acos angle)) (_.test "Tangent and arc-tangent are inverse functions." - (trigonometric-symmetry /.tan /.atan angle)) + (trigonometric_symmetry /.tan /.atan angle)) ))) (<| (_.context "Rounding") (do {! r.monad} - [sample (|> r.safe-frac (\ ! map (f.* +1000.0)))] + [sample (|> r.safe_frac (\ ! map (f.* +1000.0)))] ($_ _.and (_.test "The ceiling will be an integer value, and will be >= the original." (let [ceil'd (/.ceil sample)] @@ -67,14 +67,14 @@ ))) (<| (_.context "Exponentials and logarithms") (do {! r.monad} - [sample (|> r.safe-frac (\ ! map (f.* +10.0)))] + [sample (|> r.safe_frac (\ ! map (f.* +10.0)))] (_.test "Logarithm is the inverse of exponential." (|> sample /.exp /.log (within? +0.000000000000001 sample))))) (<| (_.context "Greatest-Common-Divisor and Least-Common-Multiple") (do {! r.monad} - [#let [gen-nat (|> r.nat (\ ! map (|>> (n.% 1000) (n.max 1))))] - x gen-nat - y gen-nat] + [#let [gen_nat (|> r.nat (\ ! map (|>> (n.% 1000) (n.max 1))))] + x gen_nat + y gen_nat] ($_ _.and (_.test "GCD" (let [gcd (n.gcd x y)] diff --git a/stdlib/source/test/lux/math/infix.lux b/stdlib/source/test/lux/math/infix.lux index d9c15a2e5..f4a3552e9 100644 --- a/stdlib/source/test/lux/math/infix.lux +++ b/stdlib/source/test/lux/math/infix.lux @@ -21,43 +21,43 @@ [subject random.nat parameter random.nat extra random.nat - angle random.safe-frac + angle random.safe_frac factor random.nat] (_.cover [/.infix] - (let [constant-values! + (let [constant_values! (n.= subject (/.infix subject)) - unary-functions! + unary_functions! (f.= (//.sin angle) (/.infix [//.sin angle])) - binary-functions! + binary_functions! (n.= (n.gcd parameter subject) (/.infix [subject n.gcd parameter])) - multiple-binary-functions! + multiple_binary_functions! (n.= (n.* factor (n.gcd parameter subject)) (/.infix [subject n.gcd parameter n.* factor])) - function-call! + function_call! (n.= (n.gcd extra (n.* parameter subject)) (/.infix [(n.* parameter subject) n.gcd extra])) - non-numeric! + non_numeric! (bit\= (and (n.< parameter subject) (n.< extra parameter)) (/.infix [[subject n.< parameter] and [parameter n.< extra]])) - and-composition! + and_composition! (and (bit\= (and (n.< parameter subject) (n.< extra parameter)) (/.infix [#and subject n.< parameter n.< extra])) (bit\= (and (n.< parameter subject) (n.> extra parameter)) (/.infix [#and subject n.< parameter n.> extra])))] - (and constant-values! - unary-functions! - binary-functions! - multiple-binary-functions! - function-call! - non-numeric! - and-composition! + (and constant_values! + unary_functions! + binary_functions! + multiple_binary_functions! + function_call! + non_numeric! + and_composition! )))))) diff --git a/stdlib/source/test/lux/math/logic/continuous.lux b/stdlib/source/test/lux/math/logic/continuous.lux index 6c4b8a721..dd18ad2d1 100644 --- a/stdlib/source/test/lux/math/logic/continuous.lux +++ b/stdlib/source/test/lux/math/logic/continuous.lux @@ -13,7 +13,7 @@ (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) (do random.monad [left random.rev right random.rev] diff --git a/stdlib/source/test/lux/math/logic/fuzzy.lux b/stdlib/source/test/lux/math/logic/fuzzy.lux index 731ee6865..476a40964 100644 --- a/stdlib/source/test/lux/math/logic/fuzzy.lux +++ b/stdlib/source/test/lux/math/logic/fuzzy.lux @@ -23,10 +23,10 @@ (template [<name> <desc> <hash> <gen> <triangle> <lt> <lte> <gt> <gte>] [(def: <name> Test - (<| (_.context (%.name (name-of <triangle>))) + (<| (_.context (%.name (name_of <triangle>))) (do random.monad [values (random.set <hash> 3 <gen>) - #let [[x y z] (case (set.to-list values) + #let [[x y z] (case (set.to_list values) (^ (list x y z)) [x y z] @@ -56,40 +56,40 @@ (<gte> top sample)))) ))))] - [rev-triangles "Rev" r.hash random.rev /.triangle r.< r.<= r.> r.>=] + [rev_triangles "Rev" r.hash random.rev /.triangle r.< r.<= r.> r.>=] ) (template [<name> <desc> <hash> <gen> <trapezoid> <lt> <lte> <gt> <gte>] [(def: <name> Test - (<| (_.context (%.name (name-of <trapezoid>))) + (<| (_.context (%.name (name_of <trapezoid>))) (do random.monad [values (random.set <hash> 4 <gen>) - #let [[w x y z] (case (set.to-list values) + #let [[w x y z] (case (set.to_list values) (^ (list w x y z)) [w x y z] _ (undefined))] sample <gen> - #let [[bottom middle-bottom middle-top top] (case (list.sort <lt> (list w x y z)) - (^ (list bottom middle-bottom middle-top top)) - [bottom middle-bottom middle-top top] + #let [[bottom middle_bottom middle_top top] (case (list.sort <lt> (list w x y z)) + (^ (list bottom middle_bottom middle_top top)) + [bottom middle_bottom middle_top top] _ (undefined)) trapezoid (<trapezoid> w x y z)]] ($_ _.and (_.test "The middle values will always have maximum membership." - (and (r.= //.true (/.membership middle-bottom trapezoid)) - (r.= //.true (/.membership middle-top trapezoid)))) + (and (r.= //.true (/.membership middle_bottom trapezoid)) + (r.= //.true (/.membership middle_top trapezoid)))) (_.test "Boundary values will always have 0 membership." (and (r.= //.false (/.membership bottom trapezoid)) (r.= //.false (/.membership top trapezoid)))) (_.test "Values within inner range will have membership = 1" (bit\= (r.= //.true (/.membership sample trapezoid)) - (and (<gte> middle-bottom sample) - (<lte> middle-top sample)))) + (and (<gte> middle_bottom sample) + (<lte> middle_top sample)))) (_.test "Values within range, will have membership > 0." (bit\= (r.> //.false (/.membership sample trapezoid)) (and (<gt> bottom sample) @@ -100,7 +100,7 @@ (<gte> top sample)))) ))))] - [rev-trapezoids "Rev" r.hash random.rev /.trapezoid r.< r.<= r.> r.>=] + [rev_trapezoids "Rev" r.hash random.rev /.trapezoid r.< r.<= r.> r.>=] ) (def: #export triangle @@ -119,40 +119,40 @@ right ..triangle sample random.rev] ($_ _.and - (_.test (%.name (name-of /.union)) + (_.test (%.name (name_of /.union)) (let [combined (/.union left right) - combined-membership (/.membership sample combined)] + combined_membership (/.membership sample combined)] (and (r.>= (/.membership sample left) - combined-membership) + combined_membership) (r.>= (/.membership sample right) - combined-membership)))) - (_.test (%.name (name-of /.intersection)) + combined_membership)))) + (_.test (%.name (name_of /.intersection)) (let [combined (/.intersection left right) - combined-membership (/.membership sample combined)] + combined_membership (/.membership sample combined)] (and (r.<= (/.membership sample left) - combined-membership) + combined_membership) (r.<= (/.membership sample right) - combined-membership)))) - (_.test (%.name (name-of /.complement)) + combined_membership)))) + (_.test (%.name (name_of /.complement)) (r.= (/.membership sample left) (//.not (/.membership sample (/.complement left))))) - (_.test (%.name (name-of /.difference)) + (_.test (%.name (name_of /.difference)) (r.<= (/.membership sample right) (/.membership sample (/.difference left right)))) )))) -(def: predicates-and-sets +(def: predicates_and_sets Test (do {! random.monad} - [#let [set-10 (set.from-list n.hash (enum.range n.enum 0 10))] + [#let [set_10 (set.from_list n.hash (enum.range n.enum 0 10))] sample (|> random.nat (\ ! map (n.% 20)))] ($_ _.and - (_.test (%.name (name-of /.from-predicate)) - (bit\= (r.= //.true (/.membership sample (/.from-predicate n.even?))) + (_.test (%.name (name_of /.from_predicate)) + (bit\= (r.= //.true (/.membership sample (/.from_predicate n.even?))) (n.even? sample))) - (_.test (%.name (name-of /.from-set)) - (bit\= (r.= //.true (/.membership sample (/.from-set set-10))) - (set.member? set-10 sample))) + (_.test (%.name (name_of /.from_set)) + (bit\= (r.= //.true (/.membership sample (/.from_set set_10))) + (set.member? set_10 sample))) ))) (def: thresholds @@ -161,12 +161,12 @@ [fuzzy ..triangle sample random.rev threshold random.rev - #let [vip-fuzzy (/.cut threshold fuzzy) - member? (/.to-predicate threshold fuzzy)]] - (<| (_.context (%.name (name-of /.cut))) + #let [vip_fuzzy (/.cut threshold fuzzy) + member? (/.to_predicate threshold fuzzy)]] + (<| (_.context (%.name (name_of /.cut))) ($_ _.and (_.test "Can increase the threshold of membership of a fuzzy set." - (bit\= (r.> //.false (/.membership sample vip-fuzzy)) + (bit\= (r.> //.false (/.membership sample vip_fuzzy)) (r.> threshold (/.membership sample fuzzy)))) (_.test "Can turn fuzzy sets into predicates through a threshold." (bit\= (member? sample) @@ -175,11 +175,11 @@ (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) ($_ _.and - ..rev-triangles - ..rev-trapezoids + ..rev_triangles + ..rev_trapezoids ..combinators - ..predicates-and-sets + ..predicates_and_sets ..thresholds ))) diff --git a/stdlib/source/test/lux/math/modular.lux b/stdlib/source/test/lux/math/modular.lux index 2bbcea587..66eb047fc 100644 --- a/stdlib/source/test/lux/math/modular.lux +++ b/stdlib/source/test/lux/math/modular.lux @@ -40,7 +40,7 @@ (def: value (All [m] (-> (/.Mod m) Int)) - (|>> /.un-modular product.right)) + (|>> /.un_modular product.right)) (def: (comparison m/? i/?) (All [m] diff --git a/stdlib/source/test/lux/math/modulus.lux b/stdlib/source/test/lux/math/modulus.lux index 502948efa..58d16666f 100644 --- a/stdlib/source/test/lux/math/modulus.lux +++ b/stdlib/source/test/lux/math/modulus.lux @@ -31,7 +31,7 @@ (_.for [/.Modulus]) (do random.monad [divisor random.int - modulus (random.one (|>> /.modulus try.to-maybe) + modulus (random.one (|>> /.modulus try.to_maybe) random.int) dividend random.int] ($_ _.and @@ -42,15 +42,15 @@ (#try.Failure error) (i.= +0 divisor))) - (_.cover [/.zero-cannot-be-a-modulus] + (_.cover [/.zero_cannot_be_a_modulus] (case (/.modulus +0) (#try.Failure error) - (exception.match? /.zero-cannot-be-a-modulus error) + (exception.match? /.zero_cannot_be_a_modulus error) (#try.Success modulus) false)) (_.cover [/.literal] - (with-expansions [<divisor> (|divisor|)] + (with_expansions [<divisor> (|divisor|)] (i.= <divisor> (/.divisor (/.literal <divisor>))))) (_.cover [/.congruent?] (and (/.congruent? modulus dividend dividend) diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index ef5be32b5..7428cae69 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -29,182 +29,182 @@ <pattern> true _ false)) -(def: compiler-related +(def: compiler_related Test (do random.monad - [target (random.ascii/upper-alpha 1) - version (random.ascii/upper-alpha 1) - source-code (random.ascii/upper-alpha 1) - expected-current-module (random.ascii/upper-alpha 1) - primitive-type (random.ascii/upper-alpha 1) - expected-seed random.nat + [target (random.ascii/upper_alpha 1) + version (random.ascii/upper_alpha 1) + source_code (random.ascii/upper_alpha 1) + expected_current_module (random.ascii/upper_alpha 1) + primitive_type (random.ascii/upper_alpha 1) + expected_seed random.nat expected random.nat dummy (random.filter (|>> (n.= expected) not) random.nat) - expected-error (random.ascii/upper-alpha 1) - expected-short (random.ascii/upper-alpha 1) - dummy-module (random.filter (|>> (text\= expected-current-module) not) - (random.ascii/upper-alpha 1)) - expected-gensym (random.ascii/upper-alpha 1) - #let [expected-lux {#.info {#.target target + expected_error (random.ascii/upper_alpha 1) + expected_short (random.ascii/upper_alpha 1) + dummy_module (random.filter (|>> (text\= expected_current_module) not) + (random.ascii/upper_alpha 1)) + expected_gensym (random.ascii/upper_alpha 1) + #let [expected_lux {#.info {#.target target #.version version #.mode #.Build} - #.source [location.dummy 0 source-code] + #.source [location.dummy 0 source_code] #.location location.dummy - #.current-module (#.Some expected-current-module) + #.current_module (#.Some expected_current_module) #.modules (list) #.scopes (list) - #.type-context {#.ex-counter 0 - #.var-counter 0 - #.var-bindings (list)} - #.expected (#.Some (#.Primitive primitive-type (list))) - #.seed expected-seed - #.scope-type-vars (list) + #.type_context {#.ex_counter 0 + #.var_counter 0 + #.var_bindings (list)} + #.expected (#.Some (#.Primitive primitive_type (list))) + #.seed expected_seed + #.scope_type_vars (list) #.extensions [] #.host []}]] ($_ _.and (_.cover [/.run] (|> (\ /.monad wrap expected) - (/.run expected-lux) + (/.run expected_lux) (!expect (^multi (#try.Success actual) (n.= expected actual))))) (_.cover [/.run'] (|> (\ /.monad wrap expected) - (/.run' expected-lux) - (!expect (^multi (#try.Success [actual-lux actual]) - (and (is? expected-lux actual-lux) + (/.run' expected_lux) + (!expect (^multi (#try.Success [actual_lux actual]) + (and (is? expected_lux actual_lux) (n.= expected actual)))))) - (_.cover [/.get-compiler] - (|> /.get-compiler - (/.run expected-lux) - (!expect (^multi (#try.Success actual-lux) - (is? expected-lux actual-lux))))) + (_.cover [/.get_compiler] + (|> /.get_compiler + (/.run expected_lux) + (!expect (^multi (#try.Success actual_lux) + (is? expected_lux actual_lux))))) ))) -(def: error-handling +(def: error_handling Test (do random.monad - [target (random.ascii/upper-alpha 1) - version (random.ascii/upper-alpha 1) - source-code (random.ascii/upper-alpha 1) - expected-current-module (random.ascii/upper-alpha 1) - primitive-type (random.ascii/upper-alpha 1) - expected-seed random.nat + [target (random.ascii/upper_alpha 1) + version (random.ascii/upper_alpha 1) + source_code (random.ascii/upper_alpha 1) + expected_current_module (random.ascii/upper_alpha 1) + primitive_type (random.ascii/upper_alpha 1) + expected_seed random.nat expected random.nat dummy (random.filter (|>> (n.= expected) not) random.nat) - expected-error (random.ascii/upper-alpha 1) - #let [expected-lux {#.info {#.target target + expected_error (random.ascii/upper_alpha 1) + #let [expected_lux {#.info {#.target target #.version version #.mode #.Build} - #.source [location.dummy 0 source-code] + #.source [location.dummy 0 source_code] #.location location.dummy - #.current-module (#.Some expected-current-module) + #.current_module (#.Some expected_current_module) #.modules (list) #.scopes (list) - #.type-context {#.ex-counter 0 - #.var-counter 0 - #.var-bindings (list)} - #.expected (#.Some (#.Primitive primitive-type (list))) - #.seed expected-seed - #.scope-type-vars (list) + #.type_context {#.ex_counter 0 + #.var_counter 0 + #.var_bindings (list)} + #.expected (#.Some (#.Primitive primitive_type (list))) + #.seed expected_seed + #.scope_type_vars (list) #.extensions [] #.host []}]] ($_ _.and (_.cover [/.fail] - (|> (/.fail expected-error) + (|> (/.fail expected_error) (: (Meta Any)) - (/.run expected-lux) - (!expect (^multi (#try.Failure actual-error) - (text\= expected-error actual-error))))) + (/.run expected_lux) + (!expect (^multi (#try.Failure actual_error) + (text\= expected_error actual_error))))) (_.cover [/.assert] - (and (|> (/.assert expected-error true) + (and (|> (/.assert expected_error true) (: (Meta Any)) - (/.run expected-lux) + (/.run expected_lux) (!expect (#try.Success []))) - (|> (/.assert expected-error false) - (/.run expected-lux) - (!expect (^multi (#try.Failure actual-error) - (text\= expected-error actual-error)))))) + (|> (/.assert expected_error false) + (/.run expected_lux) + (!expect (^multi (#try.Failure actual_error) + (text\= expected_error actual_error)))))) (_.cover [/.either] (and (|> (/.either (\ /.monad wrap expected) (: (Meta Nat) - (/.fail expected-error))) - (/.run expected-lux) + (/.fail expected_error))) + (/.run expected_lux) (!expect (^multi (#try.Success actual) (n.= expected actual)))) (|> (/.either (: (Meta Nat) - (/.fail expected-error)) + (/.fail expected_error)) (\ /.monad wrap expected)) - (/.run expected-lux) + (/.run expected_lux) (!expect (^multi (#try.Success actual) (n.= expected actual)))) (|> (/.either (: (Meta Nat) - (/.fail expected-error)) + (/.fail expected_error)) (: (Meta Nat) - (/.fail expected-error))) - (/.run expected-lux) - (!expect (^multi (#try.Failure actual-error) - (text\= expected-error actual-error)))) + (/.fail expected_error))) + (/.run expected_lux) + (!expect (^multi (#try.Failure actual_error) + (text\= expected_error actual_error)))) (|> (/.either (\ /.monad wrap expected) (\ /.monad wrap dummy)) - (/.run expected-lux) + (/.run expected_lux) (!expect (^multi (#try.Success actual) (n.= expected actual)))))) ))) -(def: module-related +(def: module_related Test (do random.monad - [target (random.ascii/upper-alpha 1) - version (random.ascii/upper-alpha 1) - source-code (random.ascii/upper-alpha 1) - expected-current-module (random.ascii/upper-alpha 1) - primitive-type (random.ascii/upper-alpha 1) - expected-seed random.nat + [target (random.ascii/upper_alpha 1) + version (random.ascii/upper_alpha 1) + source_code (random.ascii/upper_alpha 1) + expected_current_module (random.ascii/upper_alpha 1) + primitive_type (random.ascii/upper_alpha 1) + expected_seed random.nat expected random.nat dummy (random.filter (|>> (n.= expected) not) random.nat) - expected-error (random.ascii/upper-alpha 1) - expected-short (random.ascii/upper-alpha 1) - dummy-module (random.filter (|>> (text\= expected-current-module) not) - (random.ascii/upper-alpha 1)) - #let [expected-lux {#.info {#.target target + expected_error (random.ascii/upper_alpha 1) + expected_short (random.ascii/upper_alpha 1) + dummy_module (random.filter (|>> (text\= expected_current_module) not) + (random.ascii/upper_alpha 1)) + #let [expected_lux {#.info {#.target target #.version version #.mode #.Build} - #.source [location.dummy 0 source-code] + #.source [location.dummy 0 source_code] #.location location.dummy - #.current-module (#.Some expected-current-module) + #.current_module (#.Some expected_current_module) #.modules (list) #.scopes (list) - #.type-context {#.ex-counter 0 - #.var-counter 0 - #.var-bindings (list)} - #.expected (#.Some (#.Primitive primitive-type (list))) - #.seed expected-seed - #.scope-type-vars (list) + #.type_context {#.ex_counter 0 + #.var_counter 0 + #.var_bindings (list)} + #.expected (#.Some (#.Primitive primitive_type (list))) + #.seed expected_seed + #.scope_type_vars (list) #.extensions [] #.host []}]] ($_ _.and - (_.cover [/.current-module-name] - (|> /.current-module-name - (/.run expected-lux) - (!expect (^multi (#try.Success actual-current-module) - (text\= expected-current-module actual-current-module))))) + (_.cover [/.current_module_name] + (|> /.current_module_name + (/.run expected_lux) + (!expect (^multi (#try.Success actual_current_module) + (text\= expected_current_module actual_current_module))))) (_.cover [/.normalize] - (and (|> (/.normalize ["" expected-short]) - (/.run expected-lux) - (!expect (^multi (#try.Success [actual-module actual-short]) - (and (text\= expected-current-module actual-module) - (is? expected-short actual-short))))) - (|> (/.normalize [dummy-module expected-short]) - (/.run expected-lux) - (!expect (^multi (#try.Success [actual-module actual-short]) - (and (text\= dummy-module actual-module) - (is? expected-short actual-short))))))) + (and (|> (/.normalize ["" expected_short]) + (/.run expected_lux) + (!expect (^multi (#try.Success [actual_module actual_short]) + (and (text\= expected_current_module actual_module) + (is? expected_short actual_short))))) + (|> (/.normalize [dummy_module expected_short]) + (/.run expected_lux) + (!expect (^multi (#try.Success [actual_module actual_short]) + (and (text\= dummy_module actual_module) + (is? expected_short actual_short))))))) ))) -(def: random-location +(def: random_location (Random Location) ($_ random.and - (random.ascii/upper-alpha 1) + (random.ascii/upper_alpha 1) random.nat random.nat)) @@ -228,75 +228,75 @@ (<| (_.covering /._) ($_ _.and (do {! random.monad} - [target (random.ascii/upper-alpha 1) - version (random.ascii/upper-alpha 1) - source-code (random.ascii/upper-alpha 1) - expected-current-module (random.ascii/upper-alpha 1) - expected-type (\ ! map (function (_ name) + [target (random.ascii/upper_alpha 1) + version (random.ascii/upper_alpha 1) + source_code (random.ascii/upper_alpha 1) + expected_current_module (random.ascii/upper_alpha 1) + expected_type (\ ! map (function (_ name) (#.Primitive name (list))) - (random.ascii/upper-alpha 1)) - expected-seed random.nat + (random.ascii/upper_alpha 1)) + expected_seed random.nat expected random.nat dummy (random.filter (|>> (n.= expected) not) random.nat) - expected-error (random.ascii/upper-alpha 1) - expected-short (random.ascii/upper-alpha 1) - dummy-module (random.filter (|>> (text\= expected-current-module) not) - (random.ascii/upper-alpha 1)) - expected-gensym (random.ascii/upper-alpha 1) - expected-location ..random-location - #let [expected-lux {#.info {#.target target + expected_error (random.ascii/upper_alpha 1) + expected_short (random.ascii/upper_alpha 1) + dummy_module (random.filter (|>> (text\= expected_current_module) not) + (random.ascii/upper_alpha 1)) + expected_gensym (random.ascii/upper_alpha 1) + expected_location ..random_location + #let [expected_lux {#.info {#.target target #.version version #.mode #.Build} - #.source [location.dummy 0 source-code] - #.location expected-location - #.current-module (#.Some expected-current-module) + #.source [location.dummy 0 source_code] + #.location expected_location + #.current_module (#.Some expected_current_module) #.modules (list) #.scopes (list) - #.type-context {#.ex-counter 0 - #.var-counter 0 - #.var-bindings (list)} - #.expected (#.Some expected-type) - #.seed expected-seed - #.scope-type-vars (list) + #.type_context {#.ex_counter 0 + #.var_counter 0 + #.var_bindings (list)} + #.expected (#.Some expected_type) + #.seed expected_seed + #.scope_type_vars (list) #.extensions [] #.host []}]] ($_ _.and (_.for [/.functor] - ($functor.spec ..injection (..comparison expected-lux) /.functor)) + ($functor.spec ..injection (..comparison expected_lux) /.functor)) (_.for [/.apply] - ($apply.spec ..injection (..comparison expected-lux) /.apply)) + ($apply.spec ..injection (..comparison expected_lux) /.apply)) (_.for [/.monad] - ($monad.spec ..injection (..comparison expected-lux) /.monad)) + ($monad.spec ..injection (..comparison expected_lux) /.monad)) - ..compiler-related - ..error-handling - ..module-related + ..compiler_related + ..error_handling + ..module_related (_.cover [/.count] (|> (do /.monad [pre /.count post /.count] (wrap [pre post])) - (/.run expected-lux) - (!expect (^multi (#try.Success [actual-pre actual-post]) - (and (n.= expected-seed actual-pre) - (n.= (inc expected-seed) actual-post)))))) + (/.run expected_lux) + (!expect (^multi (#try.Success [actual_pre actual_post]) + (and (n.= expected_seed actual_pre) + (n.= (inc expected_seed) actual_post)))))) (_.cover [/.gensym] - (|> (/.gensym expected-gensym) + (|> (/.gensym expected_gensym) (\ /.monad map %.code) - (/.run expected-lux) - (!expect (^multi (#try.Success actual-gensym) - (and (text.contains? expected-gensym actual-gensym) - (text.contains? (%.nat expected-seed) actual-gensym)))))) + (/.run expected_lux) + (!expect (^multi (#try.Success actual_gensym) + (and (text.contains? expected_gensym actual_gensym) + (text.contains? (%.nat expected_seed) actual_gensym)))))) (_.cover [/.location] (|> /.location - (/.run expected-lux) - (!expect (^multi (#try.Success actual-location) - (is? expected-location actual-location))))) - (_.cover [/.expected-type] - (|> /.expected-type - (/.run expected-lux) - (!expect (^multi (#try.Success actual-type) - (is? expected-type actual-type))))) + (/.run expected_lux) + (!expect (^multi (#try.Success actual_location) + (is? expected_location actual_location))))) + (_.cover [/.expected_type] + (|> /.expected_type + (/.run expected_lux) + (!expect (^multi (#try.Success actual_type) + (is? expected_type actual_type))))) )) /annotation.test diff --git a/stdlib/source/test/lux/meta/annotation.lux b/stdlib/source/test/lux/meta/annotation.lux index af0ee2490..3718b8797 100644 --- a/stdlib/source/test/lux/meta/annotation.lux +++ b/stdlib/source/test/lux/meta/annotation.lux @@ -28,18 +28,18 @@ [macro ["_." code]]]) -(def: random-key +(def: random_key (Random Name) (random.and (random.ascii/alpha 1) (random.ascii/alpha 1))) -(def: (random-sequence random) +(def: (random_sequence random) (All [a] (-> (Random a) (Random (List a)))) (do {! random.monad} [size (|> random.nat (\ ! map (nat.% 3)))] (random.list size random))) -(def: (random-record random) +(def: (random_record random) (All [a] (-> (Random a) (Random (List [a a])))) (do {! random.monad} [size (|> random.nat (\ ! map (nat.% 3)))] @@ -55,10 +55,10 @@ (code.record (list [(code.tag key) value]))) -(def: typed-value +(def: typed_value Test (do {! random.monad} - [key ..random-key] + [key ..random_key] (`` ($_ _.and (~~ (template [<definition> <random> <constructor> <equivalence>] [(do {! random.monad} @@ -74,24 +74,24 @@ [/.nat random.nat code.nat nat.equivalence] [/.int random.int code.int int.equivalence] [/.rev random.rev code.rev rev.equivalence] - [/.frac random.safe-frac code.frac frac.equivalence] + [/.frac random.safe_frac code.frac frac.equivalence] [/.text (random.ascii/alpha 1) code.text text.equivalence] - [/.identifier ..random-key code.identifier name.equivalence] - [/.tag ..random-key code.tag name.equivalence] - [/.form (..random-sequence _code.random) code.form (list.equivalence code.equivalence)] - [/.tuple (..random-sequence _code.random) code.tuple (list.equivalence code.equivalence)] - [/.record (..random-record _code.random) code.record (list.equivalence (product.equivalence code.equivalence code.equivalence))] + [/.identifier ..random_key code.identifier name.equivalence] + [/.tag ..random_key code.tag name.equivalence] + [/.form (..random_sequence _code.random) code.form (list.equivalence code.equivalence)] + [/.tuple (..random_sequence _code.random) code.tuple (list.equivalence code.equivalence)] + [/.record (..random_record _code.random) code.record (list.equivalence (product.equivalence code.equivalence code.equivalence))] )) )))) (def: flag Test (do {! random.monad} - [key ..random-key] + [key ..random_key] (`` ($_ _.and (do ! [dummy (random.filter (|>> (name\= key) not) - ..random-key) + ..random_key) expected random.bit] (_.cover [/.flagged?] (and (|> expected code.bit @@ -106,7 +106,7 @@ [expected random.bit] (_.cover [<definition>] (and (|> expected code.bit - (..annotation (name-of <tag>)) + (..annotation (name_of <tag>)) <definition> (\ bit.equivalence = expected)) (not (|> expected code.bit @@ -114,7 +114,7 @@ <definition>)))))] [/.structure? #.struct?] - [/.recursive-type? #.type-rec?] + [/.recursive_type? #.type-rec?] [/.signature? #.sig?] )) )))) @@ -122,14 +122,14 @@ (def: arguments Test (do {! random.monad} - [key ..random-key] + [key ..random_key] (`` ($_ _.and (~~ (template [<definition> <tag>] [(do ! [expected (random.list 5 (random.ascii/alpha 1))] (_.cover [<definition>] (and (|> expected (list\map code.text) code.tuple - (..annotation (name-of <tag>)) + (..annotation (name_of <tag>)) <definition> (\ (list.equivalence text.equivalence) = expected)) (|> expected (list\map code.text) code.tuple @@ -137,8 +137,8 @@ <definition> (\ (list.equivalence text.equivalence) = (list))))))] - [/.function-arguments #.func-args] - [/.type-arguments #.type-args] + [/.function_arguments #.func-args] + [/.type_arguments #.type-args] )) )))) @@ -147,7 +147,7 @@ (<| (_.covering /._) (_.for [/.Annotation]) (do {! random.monad} - [key ..random-key] + [key ..random_key] ($_ _.and (do ! [expected _code.random] @@ -158,7 +158,7 @@ (!expect (^multi (#.Some actual) (code\= expected actual)))))) - ..typed-value + ..typed_value (do ! [expected (random.ascii/alpha 10)] @@ -169,7 +169,7 @@ (!expect (^multi (#.Some actual) (\ text.equivalence = expected actual))))) (|> expected code.text - (..annotation (name-of #.doc)) + (..annotation (name_of #.doc)) /.documentation (!expect (^multi (#.Some actual) (\ text.equivalence = expected actual))))))) diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index cb3398720..42d4eba11 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -53,7 +53,7 @@ ["#." type (#+ Type) ["." category (#+ Value Object Class)]]]}) -(def: method-modifier +(def: method_modifier ($_ /modifier\compose /method.public /method.static)) @@ -83,17 +83,17 @@ (getClass [] (java/lang/Class java/lang/Object)) (toString [] java/lang/String)]) -(def: class-name +(def: class_name (Random Text) (do random.monad - [super-package (random.ascii/lower-alpha 10) - package (random.ascii/lower-alpha 10) - name (random.ascii/upper-alpha 10)] - (wrap (format super-package - /name.external-separator package - /name.external-separator name)))) + [super_package (random.ascii/lower_alpha 10) + package (random.ascii/lower_alpha 10) + name (random.ascii/upper_alpha 10)] + (wrap (format super_package + /name.external_separator package + /name.external_separator name)))) -(def: (get-method name class) +(def: (get_method name class) (-> Text (java/lang/Class java/lang/Object) java/lang/reflect/Method) (java/lang/Class::getDeclaredMethod name (host.array (java/lang/Class java/lang/Object) 0) @@ -104,16 +104,16 @@ (def: (bytecode test bytecode) (-> (-> Any Bit) (Bytecode Any) (Random Bit)) (do random.monad - [class-name ..class-name - method-name (random.ascii/upper-alpha 10)] + [class_name ..class_name + method_name (random.ascii/upper_alpha 10)] (wrap (case (do try.monad [class (/class.class /version.v6_0 /class.public - (/name.internal class-name) + (/name.internal class_name) (/name.internal "java.lang.Object") (list) (list) - (list (/method.method ..method-modifier - method-name + (list (/method.method ..method_modifier + method_name (/type.method [(list) ..$Object (list)]) (list) (#.Some (do /.monad @@ -121,10 +121,10 @@ /.areturn)))) (row.row)) #let [bytecode (format.run /class.writer class) - loader (/loader.memory (/loader.new-library []))] - _ (/loader.define class-name bytecode loader) - class (io.run (/loader.load class-name loader)) - method (host.try (get-method method-name class))] + loader (/loader.memory (/loader.new_library []))] + _ (/loader.define class_name bytecode loader) + class (io.run (/loader.load class_name loader)) + method (host.try (get_method method_name class))] (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)) (#try.Success actual) (test actual) @@ -165,10 +165,10 @@ (/.invokestatic ..$Byte "valueOf" (/type.method [(list /type.byte) ..$Byte (list)]))) (def: $Byte::random (Random java/lang/Byte) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long-to-byte) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_byte) random.int)) (def: $Byte::literal (-> java/lang/Byte (Bytecode Any)) - (|>> host.byte-to-long (:coerce I64) i32.i32 /.int)) + (|>> host.byte_to_long (:coerce I64) i32.i32 /.int)) (def: $Byte::primitive (Primitive java/lang/Byte) {#unboxed /type.byte @@ -183,10 +183,10 @@ (/.invokestatic ..$Short "valueOf" (/type.method [(list /type.short) ..$Short (list)]))) (def: $Short::random (Random java/lang/Short) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long-to-short) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_short) random.int)) (def: $Short::literal (-> java/lang/Short (Bytecode Any)) - (|>> host.short-to-long (:coerce I64) i32.i32 /.int)) + (|>> host.short_to_long (:coerce I64) i32.i32 /.int)) (def: $Short::primitive (Primitive java/lang/Short) {#unboxed /type.short @@ -201,10 +201,10 @@ (/.invokestatic ..$Integer "valueOf" (/type.method [(list /type.int) ..$Integer (list)]))) (def: $Integer::random (Random java/lang/Integer) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long-to-int) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_int) random.int)) (def: $Integer::literal (-> java/lang/Integer (Bytecode Any)) - (|>> host.int-to-long (:coerce I64) i32.i32 /.int)) + (|>> host.int_to_long (:coerce I64) i32.i32 /.int)) (def: $Integer::primitive (Primitive java/lang/Integer) {#unboxed /type.int @@ -230,19 +230,19 @@ (def: $Float::random (Random java/lang/Float) (\ random.monad map - (|>> (:coerce java/lang/Double) host.double-to-float) + (|>> (:coerce java/lang/Double) host.double_to_float) random.frac)) (def: $Float::literal /.float) -(def: valid-float +(def: valid_float (Random java/lang/Float) - (random.filter (|>> host.float-to-double (:coerce Frac) f.not-a-number? not) + (random.filter (|>> host.float_to_double (:coerce Frac) f.not_a_number? not) ..$Float::random)) (def: $Float::primitive (Primitive java/lang/Float) {#unboxed /type.float #boxed ..$Float #wrap ..$Float::wrap - #random ..valid-float + #random ..valid_float #literal ..$Float::literal}) (def: $Double (/type.class "java.lang.Double" (list))) @@ -251,16 +251,16 @@ (def: $Double::literal (-> java/lang/Double (Bytecode Any)) (|>> (:coerce Frac) /.double)) -(def: valid-double +(def: valid_double (Random java/lang/Double) - (random.filter (|>> (:coerce Frac) f.not-a-number? not) + (random.filter (|>> (:coerce Frac) f.not_a_number? not) ..$Double::random)) (def: $Double::primitive (Primitive java/lang/Double) {#unboxed /type.double #boxed ..$Double #wrap ..$Double::wrap - #random ..valid-double + #random ..valid_double #literal ..$Double::literal}) (def: $Character @@ -269,10 +269,10 @@ (/.invokestatic ..$Character "valueOf" (/type.method [(list /type.char) ..$Character (list)]))) (def: $Character::random (Random java/lang/Character) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long-to-int host.int-to-char) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_int host.int_to_char) random.int)) (def: $Character::literal (-> java/lang/Character (Bytecode Any)) - (|>> host.char-to-long (:coerce I64) i32.i32 /.int)) + (|>> host.char_to_long (:coerce I64) i32.i32 /.int)) (def: $Character::primitive (Primitive java/lang/Character) {#unboxed /type.char @@ -300,34 +300,34 @@ #random ..$String::random #literal ..$String::literal}) -(template [<name> <bits> <type> <push> <wrap> <message> <to-long> <signed>] +(template [<name> <bits> <type> <push> <wrap> <message> <to_long> <signed>] [(def: <name> Test (do {! random.monad} [expected (\ ! map (i64.and (i64.mask <bits>)) random.nat)] (<| (_.lift <message>) (..bytecode (for {@.old - (|>> (:coerce <type>) <to-long> ("jvm leq" expected)) + (|>> (:coerce <type>) <to_long> ("jvm leq" expected)) @.jvm - (|>> (:coerce <type>) <to-long> "jvm object cast" ("jvm long =" ("jvm object cast" (:coerce java/lang/Long expected))))})) + (|>> (:coerce <type>) <to_long> "jvm object cast" ("jvm long =" ("jvm object cast" (:coerce java/lang/Long expected))))})) (do /.monad [_ (<push> (|> expected .int <signed> try.assume))] <wrap>))))] - [byte 7 java/lang/Byte /.bipush ..$Byte::wrap "BIPUSH" host.byte-to-long /signed.s1] - [short 15 java/lang/Short /.sipush ..$Short::wrap "SIPUSH" host.short-to-long /signed.s2] + [byte 7 java/lang/Byte /.bipush ..$Byte::wrap "BIPUSH" host.byte_to_long /signed.s1] + [short 15 java/lang/Short /.sipush ..$Short::wrap "SIPUSH" host.short_to_long /signed.s2] ) (template [<name> <type>] - [(template: (<name> <old-extension> <new-extension>) + [(template: (<name> <old_extension> <new_extension>) (: (-> <type> <type> <type>) (function (_ parameter subject) (for {@.old - (<old-extension> subject parameter) + (<old_extension> subject parameter) @.jvm ("jvm object cast" - (<new-extension> ("jvm object cast" parameter) + (<new_extension> ("jvm object cast" parameter) ("jvm object cast" subject)))}))))] [int/2 java/lang/Integer] @@ -336,15 +336,15 @@ [double/2 java/lang/Double] ) -(template: (int+long/2 <old-extension> <new-extension>) +(template: (int+long/2 <old_extension> <new_extension>) (: (-> java/lang/Integer java/lang/Long java/lang/Long) (function (_ parameter subject) (for {@.old - (<old-extension> subject parameter) + (<old_extension> subject parameter) @.jvm ("jvm object cast" - (<new-extension> ("jvm object cast" parameter) + (<new_extension> ("jvm object cast" parameter) ("jvm object cast" subject)))})))) (def: int @@ -382,7 +382,7 @@ shift (: (-> (-> java/lang/Integer java/lang/Integer java/lang/Integer) (Bytecode Any) (Random Bit)) (function (_ reference instruction) (do {! random.monad} - [parameter (\ ! map (|>> (n.% 32) .int (:coerce java/lang/Long) host.long-to-int) random.nat) + [parameter (\ ! map (|>> (n.% 32) .int (:coerce java/lang/Long) host.long_to_int) random.nat) subject ..$Integer::random] (int (reference parameter subject) (do /.monad @@ -390,13 +390,13 @@ _ (..$Integer::literal parameter)] instruction))))) literal ($_ _.and - (_.lift "ICONST_M1" (int (host.long-to-int (:coerce java/lang/Long -1)) /.iconst-m1)) - (_.lift "ICONST_0" (int (host.long-to-int (:coerce java/lang/Long +0)) /.iconst-0)) - (_.lift "ICONST_1" (int (host.long-to-int (:coerce java/lang/Long +1)) /.iconst-1)) - (_.lift "ICONST_2" (int (host.long-to-int (:coerce java/lang/Long +2)) /.iconst-2)) - (_.lift "ICONST_3" (int (host.long-to-int (:coerce java/lang/Long +3)) /.iconst-3)) - (_.lift "ICONST_4" (int (host.long-to-int (:coerce java/lang/Long +4)) /.iconst-4)) - (_.lift "ICONST_5" (int (host.long-to-int (:coerce java/lang/Long +5)) /.iconst-5)) + (_.lift "ICONST_M1" (int (host.long_to_int (:coerce java/lang/Long -1)) /.iconst_m1)) + (_.lift "ICONST_0" (int (host.long_to_int (:coerce java/lang/Long +0)) /.iconst_0)) + (_.lift "ICONST_1" (int (host.long_to_int (:coerce java/lang/Long +1)) /.iconst_1)) + (_.lift "ICONST_2" (int (host.long_to_int (:coerce java/lang/Long +2)) /.iconst_2)) + (_.lift "ICONST_3" (int (host.long_to_int (:coerce java/lang/Long +3)) /.iconst_3)) + (_.lift "ICONST_4" (int (host.long_to_int (:coerce java/lang/Long +4)) /.iconst_4)) + (_.lift "ICONST_5" (int (host.long_to_int (:coerce java/lang/Long +5)) /.iconst_5)) (_.lift "LDC_W/INTEGER" (do random.monad [expected ..$Integer::random] @@ -410,7 +410,7 @@ (_.lift "INEG" (unary (function (_ value) ((int/2 "jvm isub" "jvm int -") value - (host.long-to-int (:coerce java/lang/Long +0)))) + (host.long_to_int (:coerce java/lang/Long +0)))) /.ineg))) bitwise ($_ _.and (_.lift "IAND" (binary (int/2 "jvm iand" "jvm int and") /.iand)) @@ -463,14 +463,14 @@ (do {! random.monad} [parameter (\ ! map (|>> (n.% 64) (:coerce java/lang/Long)) random.nat) subject ..$Long::random] - (long (reference (host.long-to-int parameter) subject) + (long (reference (host.long_to_int parameter) subject) (do /.monad [_ (..$Long::literal subject) - _ (..$Integer::literal (host.long-to-int parameter))] + _ (..$Integer::literal (host.long_to_int parameter))] instruction))))) literal ($_ _.and - (_.lift "LCONST_0" (long (:coerce java/lang/Long +0) /.lconst-0)) - (_.lift "LCONST_1" (long (:coerce java/lang/Long +1) /.lconst-1)) + (_.lift "LCONST_0" (long (:coerce java/lang/Long +0) /.lconst_0)) + (_.lift "LCONST_1" (long (:coerce java/lang/Long +1) /.lconst_1)) (_.lift "LDC2_W/LONG" (do random.monad [expected ..$Long::random] @@ -534,14 +534,14 @@ (<| (..bytecode (for {@.old (function (_ actual) (or (|> actual (:coerce java/lang/Float) ("jvm feq" expected)) - (and (f.not-a-number? (:coerce Frac (host.float-to-double expected))) - (f.not-a-number? (:coerce Frac (host.float-to-double (:coerce java/lang/Float actual))))))) + (and (f.not_a_number? (:coerce Frac (host.float_to_double expected))) + (f.not_a_number? (:coerce Frac (host.float_to_double (:coerce java/lang/Float actual))))))) @.jvm (function (_ actual) (or (|> actual (:coerce java/lang/Float) "jvm object cast" ("jvm float =" ("jvm object cast" expected))) - (and (f.not-a-number? (:coerce Frac (host.float-to-double expected))) - (f.not-a-number? (:coerce Frac (host.float-to-double (:coerce java/lang/Float actual)))))))})) + (and (f.not_a_number? (:coerce Frac (host.float_to_double expected))) + (f.not_a_number? (:coerce Frac (host.float_to_double (:coerce java/lang/Float actual)))))))})) (do /.monad [_ bytecode] ..$Float::wrap)))) @@ -568,9 +568,9 @@ _ (..$Float::literal parameter)] instruction))))) literal ($_ _.and - (_.lift "FCONST_0" (float (host.double-to-float (:coerce java/lang/Double +0.0)) /.fconst-0)) - (_.lift "FCONST_1" (float (host.double-to-float (:coerce java/lang/Double +1.0)) /.fconst-1)) - (_.lift "FCONST_2" (float (host.double-to-float (:coerce java/lang/Double +2.0)) /.fconst-2)) + (_.lift "FCONST_0" (float (host.double_to_float (:coerce java/lang/Double +0.0)) /.fconst_0)) + (_.lift "FCONST_1" (float (host.double_to_float (:coerce java/lang/Double +1.0)) /.fconst_1)) + (_.lift "FCONST_2" (float (host.double_to_float (:coerce java/lang/Double +2.0)) /.fconst_2)) (_.lift "LDC_W/FLOAT" (do random.monad [expected ..$Float::random] @@ -584,15 +584,15 @@ (_.lift "FNEG" (unary (function (_ value) ((float/2 "jvm fsub" "jvm float -") value - (host.double-to-float (:coerce java/lang/Double +0.0)))) + (host.double_to_float (:coerce java/lang/Double +0.0)))) /.fneg))) comparison (: (-> (Bytecode Any) (-> java/lang/Float java/lang/Float Bit) (Random Bit)) (function (_ instruction standard) (do random.monad - [#let [valid-float (random.filter (|>> host.float-to-double (:coerce Frac) f.not-a-number? not) + [#let [valid_float (random.filter (|>> host.float_to_double (:coerce Frac) f.not_a_number? not) ..$Float::random)] - reference valid-float - subject valid-float + reference valid_float + subject valid_float #let [expected (if (for {@.old ("jvm feq" reference subject) @@ -609,7 +609,7 @@ _ instruction _ /.i2l] ..$Long::wrap))))) - comparison-standard (: (-> java/lang/Float java/lang/Float Bit) + comparison_standard (: (-> java/lang/Float java/lang/Float Bit) (function (_ reference subject) (for {@.old ("jvm fgt" subject reference) @@ -617,8 +617,8 @@ @.jvm ("jvm float <" ("jvm object cast" subject) ("jvm object cast" reference))}))) comparison ($_ _.and - (_.lift "FCMPL" (comparison /.fcmpl comparison-standard)) - (_.lift "FCMPG" (comparison /.fcmpg comparison-standard)))] + (_.lift "FCMPL" (comparison /.fcmpl comparison_standard)) + (_.lift "FCMPG" (comparison /.fcmpg comparison_standard)))] ($_ _.and (<| (_.context "literal") literal) @@ -635,14 +635,14 @@ (<| (..bytecode (for {@.old (function (_ actual) (or (|> actual (:coerce java/lang/Double) ("jvm deq" expected)) - (and (f.not-a-number? (:coerce Frac expected)) - (f.not-a-number? (:coerce Frac actual))))) + (and (f.not_a_number? (:coerce Frac expected)) + (f.not_a_number? (:coerce Frac actual))))) @.jvm (function (_ actual) (or (|> actual (:coerce java/lang/Double) "jvm object cast" ("jvm double =" ("jvm object cast" expected))) - (and (f.not-a-number? (:coerce Frac expected)) - (f.not-a-number? (:coerce Frac actual)))))})) + (and (f.not_a_number? (:coerce Frac expected)) + (f.not_a_number? (:coerce Frac actual)))))})) (do /.monad [_ bytecode] ..$Double::wrap)))) @@ -665,8 +665,8 @@ _ (..$Double::literal parameter)] instruction))))) literal ($_ _.and - (_.lift "DCONST_0" (double (:coerce java/lang/Double +0.0) /.dconst-0)) - (_.lift "DCONST_1" (double (:coerce java/lang/Double +1.0) /.dconst-1)) + (_.lift "DCONST_0" (double (:coerce java/lang/Double +0.0) /.dconst_0)) + (_.lift "DCONST_1" (double (:coerce java/lang/Double +1.0) /.dconst_1)) (_.lift "LDC2_W/DOUBLE" (do random.monad [expected ..$Double::random] @@ -685,8 +685,8 @@ comparison (: (-> (Bytecode Any) (-> java/lang/Double java/lang/Double Bit) (Random Bit)) (function (_ instruction standard) (do random.monad - [reference ..valid-double - subject ..valid-double + [reference ..valid_double + subject ..valid_double #let [expected (if (for {@.old ("jvm deq" reference subject) @@ -704,7 +704,7 @@ _ /.i2l] ..$Long::wrap))))) ## https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.dcmp_op - comparison-standard (: (-> java/lang/Double java/lang/Double Bit) + comparison_standard (: (-> java/lang/Double java/lang/Double Bit) (function (_ reference subject) (for {@.old ("jvm dgt" subject reference) @@ -712,8 +712,8 @@ @.jvm ("jvm double <" ("jvm object cast" subject) ("jvm object cast" reference))}))) comparison ($_ _.and - (_.lift "DCMPL" (comparison /.dcmpl comparison-standard)) - (_.lift "DCMPG" (comparison /.dcmpg comparison-standard)))] + (_.lift "DCMPL" (comparison /.dcmpl comparison_standard)) + (_.lift "DCMPG" (comparison /.dcmpg comparison_standard)))] ($_ _.and (<| (_.context "literal") literal) @@ -751,7 +751,7 @@ (<| (_.lift "ACONST_NULL") (..bytecode (|>> (:coerce Bit) not)) (do /.monad - [_ /.aconst-null + [_ /.aconst_null _ (/.instanceof ..$String)] ..$Boolean::wrap)) (<| (_.lift "INSTANCEOF") @@ -786,7 +786,7 @@ ($_ _.and (<| (_.lift "INVOKESTATIC") (do random.monad - [expected (random.filter (|>> (:coerce Frac) f.not-a-number? not) + [expected (random.filter (|>> (:coerce Frac) f.not_a_number? not) ..$Double::random)]) (..bytecode (for {@.old (|>> (:coerce java/lang/Double) ("jvm deq" expected)) @@ -799,7 +799,7 @@ (<| (_.lift "INVOKEVIRTUAL") (do random.monad [expected ..$Double::random]) - (..bytecode (|>> (:coerce Bit) (bit\= (f.not-a-number? (:coerce Frac expected))))) + (..bytecode (|>> (:coerce Bit) (bit\= (f.not_a_number? (:coerce Frac expected))))) (do /.monad [_ (/.double (:coerce Frac expected)) _ ..$Double::wrap @@ -807,7 +807,7 @@ ..$Boolean::wrap)) (<| (_.lift "INVOKESPECIAL") (do random.monad - [expected (random.filter (|>> (:coerce Frac) f.not-a-number? not) + [expected (random.filter (|>> (:coerce Frac) f.not_a_number? not) ..$Double::random)]) (..bytecode (for {@.old (|>> (:coerce java/lang/Double) ("jvm deq" expected)) @@ -833,7 +833,7 @@ (def: field Test (do random.monad - [class-name ..class-name + [class_name ..class_name part0 ..$Long::random part1 ..$Long::random #let [expected (: java/lang/Long @@ -843,35 +843,35 @@ @.jvm ("jvm object cast" ("jvm long +" ("jvm object cast" part0) ("jvm object cast" part1)))})) - $Self (/type.class class-name (list)) - class-field "class_field" - object-field "object_field" + $Self (/type.class class_name (list)) + class_field "class_field" + object_field "object_field" constructor "<init>" constructor::type (/type.method [(list /type.long) /type.void (list)]) - static-method "static_method" + static_method "static_method" bytecode (|> (/class.class /version.v6_0 /class.public - (/name.internal class-name) + (/name.internal class_name) (/name.internal "java.lang.Object") (list) - (list (/field.field /field.static class-field /type.long (row.row)) - (/field.field /field.public object-field /type.long (row.row))) + (list (/field.field /field.static class_field /type.long (row.row)) + (/field.field /field.public object_field /type.long (row.row))) (list (/method.method /method.private constructor constructor::type (list) (#.Some (do /.monad - [_ /.aload-0 + [_ /.aload_0 _ (/.invokespecial ..$Object constructor (/type.method [(list) /type.void (list)])) _ (..$Long::literal part0) - _ (/.putstatic $Self class-field /type.long) - _ /.aload-0 - _ /.lload-1 - _ (/.putfield $Self object-field /type.long)] + _ (/.putstatic $Self class_field /type.long) + _ /.aload_0 + _ /.lload_1 + _ (/.putfield $Self object_field /type.long)] /.return))) (/method.method ($_ /modifier\compose /method.public /method.static) - static-method + static_method (/type.method [(list) ..$Long (list)]) (list) (#.Some (do /.monad @@ -879,20 +879,20 @@ _ /.dup _ (..$Long::literal part1) _ (/.invokespecial $Self constructor constructor::type) - _ (/.getfield $Self object-field /type.long) - _ (/.getstatic $Self class-field /type.long) + _ (/.getfield $Self object_field /type.long) + _ (/.getstatic $Self class_field /type.long) _ /.ladd _ ..$Long::wrap] /.areturn)))) (row.row)) try.assume (format.run /class.writer)) - loader (/loader.memory (/loader.new-library []))]] + loader (/loader.memory (/loader.new_library []))]] (_.test "PUTSTATIC & PUTFIELD & GETFIELD & GETSTATIC" (case (do try.monad - [_ (/loader.define class-name bytecode loader) - class (io.run (/loader.load class-name loader)) - method (host.try (get-method static-method class)) + [_ (/loader.define class_name bytecode loader) + class (io.run (/loader.load class_name loader)) + method (host.try (get_method static_method class)) output (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)] (wrap (:coerce Int output))) (#try.Success actual) @@ -920,14 +920,14 @@ _ constructor _ ?length] $Long::wrap)))) - write-and-read (: (All [a] + write_and_read (: (All [a] (-> Nat (Bytecode Any) a (-> a (Bytecode Any)) [(Bytecode Any) (Bytecode Any) (Bytecode Any)] (-> a Any Bit) (Random Bit))) (function (_ size constructor value literal [*store *load *wrap] test) - (let [!index ($Integer::literal (host.long-to-int (:coerce java/lang/Long +0)))] + (let [!index ($Integer::literal (host.long_to_int (:coerce java/lang/Long +0)))] (<| (..bytecode (test value)) (do /.monad [_ (!length size) @@ -948,29 +948,29 @@ (<| (_.lift "length") (length size constructor)) (<| (_.lift "write and read") - (write-and-read size constructor value literal [*store *load *wrap] test))))))] + (write_and_read size constructor value literal [*store *load *wrap] test))))))] ($_ _.and (_.context "boolean" - (array (/.newarray /instruction.t-boolean) $Boolean::random $Boolean::literal [/.bastore /.baload $Boolean::wrap] + (array (/.newarray /instruction.t_boolean) $Boolean::random $Boolean::literal [/.bastore /.baload $Boolean::wrap] (function (_ expected) (|>> (:coerce Bit) (bit\= (:coerce Bit expected)))))) (_.context "byte" - (array (/.newarray /instruction.t-byte) $Byte::random $Byte::literal [/.bastore /.baload $Byte::wrap] + (array (/.newarray /instruction.t_byte) $Byte::random $Byte::literal [/.bastore /.baload $Byte::wrap] (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Byte) host.byte-to-long ("jvm leq" (host.byte-to-long expected))) + (|>> (:coerce java/lang/Byte) host.byte_to_long ("jvm leq" (host.byte_to_long expected))) @.jvm - (|>> (:coerce java/lang/Byte) host.byte-to-long "jvm object cast" ("jvm long =" ("jvm object cast" (host.byte-to-long (:coerce java/lang/Byte expected)))))})))) + (|>> (:coerce java/lang/Byte) host.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.byte_to_long (:coerce java/lang/Byte expected)))))})))) (_.context "short" - (array (/.newarray /instruction.t-short) $Short::random $Short::literal [/.sastore /.saload $Short::wrap] + (array (/.newarray /instruction.t_short) $Short::random $Short::literal [/.sastore /.saload $Short::wrap] (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Short) host.short-to-long ("jvm leq" (host.short-to-long expected))) + (|>> (:coerce java/lang/Short) host.short_to_long ("jvm leq" (host.short_to_long expected))) @.jvm - (|>> (:coerce java/lang/Short) host.short-to-long "jvm object cast" ("jvm long =" ("jvm object cast" (host.short-to-long (:coerce java/lang/Short expected)))))})))) + (|>> (:coerce java/lang/Short) host.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.short_to_long (:coerce java/lang/Short expected)))))})))) (_.context "int" - (array (/.newarray /instruction.t-int) $Integer::random $Integer::literal [/.iastore /.iaload $Integer::wrap] + (array (/.newarray /instruction.t_int) $Integer::random $Integer::literal [/.iastore /.iaload $Integer::wrap] (function (_ expected) (for {@.old (|>> (:coerce java/lang/Integer) ("jvm ieq" (:coerce java/lang/Integer expected))) @@ -978,7 +978,7 @@ @.jvm (|>> (:coerce java/lang/Integer) "jvm object cast" ("jvm int =" ("jvm object cast" (:coerce java/lang/Integer expected))))})))) (_.context "long" - (array (/.newarray /instruction.t-long) $Long::random $Long::literal [/.lastore /.laload $Long::wrap] + (array (/.newarray /instruction.t_long) $Long::random $Long::literal [/.lastore /.laload $Long::wrap] (function (_ expected) (for {@.old (|>> (:coerce java/lang/Long) ("jvm leq" expected)) @@ -986,7 +986,7 @@ @.jvm (|>> (:coerce java/lang/Long) "jvm object cast" ("jvm long =" ("jvm object cast" (:coerce java/lang/Long expected))))})))) (_.context "float" - (array (/.newarray /instruction.t-float) ..valid-float $Float::literal [/.fastore /.faload $Float::wrap] + (array (/.newarray /instruction.t_float) ..valid_float $Float::literal [/.fastore /.faload $Float::wrap] (function (_ expected) (for {@.old (|>> (:coerce java/lang/Float) ("jvm feq" expected)) @@ -994,7 +994,7 @@ @.jvm (|>> (:coerce java/lang/Float) "jvm object cast" ("jvm float =" ("jvm object cast" (:coerce java/lang/Float expected))))})))) (_.context "double" - (array (/.newarray /instruction.t-double) ..valid-double $Double::literal [/.dastore /.daload $Double::wrap] + (array (/.newarray /instruction.t_double) ..valid_double $Double::literal [/.dastore /.daload $Double::wrap] (function (_ expected) (for {@.old (|>> (:coerce java/lang/Double) ("jvm deq" expected)) @@ -1002,7 +1002,7 @@ @.jvm (|>> (:coerce java/lang/Double) "jvm object cast" ("jvm double =" ("jvm object cast" (:coerce java/lang/Double expected))))})))) (_.context "char" - (array (/.newarray /instruction.t-char) $Character::random $Character::literal [/.castore /.caload $Character::wrap] + (array (/.newarray /instruction.t_char) $Character::random $Character::literal [/.castore /.caload $Character::wrap] (function (_ expected) (for {@.old (|>> (:coerce java/lang/Character) ("jvm ceq" expected)) @@ -1028,7 +1028,7 @@ (<| (_.lift "MULTIANEWARRAY") (..bytecode (|>> (:coerce Nat) (n.= sizesH))) (do {! /.monad} - [_ (monad.map ! (|>> (:coerce java/lang/Long) host.long-to-int ..$Integer::literal) + [_ (monad.map ! (|>> (:coerce java/lang/Long) host.long_to_int ..$Integer::literal) (#.Cons sizesH sizesT)) _ (/.multianewarray type (|> dimensions /unsigned.u1 try.assume)) _ ?length] @@ -1064,40 +1064,40 @@ ($_ _.and (<| (_.context "int") ($_ _.and - (_.lift "I2L" (conversion ..$Integer::primitive ..$Long::primitive /.i2l (|>> host.int-to-long) long::=)) - (_.lift "I2F" (conversion ..$Integer::primitive ..$Float::primitive /.i2f (|>> host.int-to-float) float::=)) - (_.lift "I2D" (conversion ..$Integer::primitive ..$Double::primitive /.i2d (|>> host.int-to-double) double::=)) - (_.lift "I2B" (conversion ..$Integer::primitive ..$Byte::primitive /.i2b (|>> host.int-to-byte) + (_.lift "I2L" (conversion ..$Integer::primitive ..$Long::primitive /.i2l (|>> host.int_to_long) long::=)) + (_.lift "I2F" (conversion ..$Integer::primitive ..$Float::primitive /.i2f (|>> host.int_to_float) float::=)) + (_.lift "I2D" (conversion ..$Integer::primitive ..$Double::primitive /.i2d (|>> host.int_to_double) double::=)) + (_.lift "I2B" (conversion ..$Integer::primitive ..$Byte::primitive /.i2b (|>> host.int_to_byte) (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Byte) host.byte-to-long ("jvm leq" (host.byte-to-long expected))) + (|>> (:coerce java/lang/Byte) host.byte_to_long ("jvm leq" (host.byte_to_long expected))) @.jvm - (|>> (:coerce java/lang/Byte) host.byte-to-long "jvm object cast" ("jvm long =" ("jvm object cast" (host.byte-to-long (:coerce java/lang/Byte expected)))))})))) - (_.lift "I2C" (conversion ..$Integer::primitive ..$Character::primitive /.i2c (|>> host.int-to-char) + (|>> (:coerce java/lang/Byte) host.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.byte_to_long (:coerce java/lang/Byte expected)))))})))) + (_.lift "I2C" (conversion ..$Integer::primitive ..$Character::primitive /.i2c (|>> host.int_to_char) (!::= java/lang/Character "jvm ceq" "jvm char ="))) - (_.lift "I2S" (conversion ..$Integer::primitive ..$Short::primitive /.i2s (|>> host.int-to-short) + (_.lift "I2S" (conversion ..$Integer::primitive ..$Short::primitive /.i2s (|>> host.int_to_short) (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Short) host.short-to-long ("jvm leq" (host.short-to-long expected))) + (|>> (:coerce java/lang/Short) host.short_to_long ("jvm leq" (host.short_to_long expected))) @.jvm - (|>> (:coerce java/lang/Short) host.short-to-long "jvm object cast" ("jvm long =" ("jvm object cast" (host.short-to-long (:coerce java/lang/Short expected)))))})))))) + (|>> (:coerce java/lang/Short) host.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.short_to_long (:coerce java/lang/Short expected)))))})))))) (<| (_.context "long") ($_ _.and - (_.lift "L2I" (conversion ..$Long::primitive ..$Integer::primitive /.l2i (|>> host.long-to-int) int::=)) - (_.lift "L2F" (conversion ..$Long::primitive ..$Float::primitive /.l2f (|>> host.long-to-float) float::=)) - (_.lift "L2D" (conversion ..$Long::primitive ..$Double::primitive /.l2d (|>> host.long-to-double) double::=)))) + (_.lift "L2I" (conversion ..$Long::primitive ..$Integer::primitive /.l2i (|>> host.long_to_int) int::=)) + (_.lift "L2F" (conversion ..$Long::primitive ..$Float::primitive /.l2f (|>> host.long_to_float) float::=)) + (_.lift "L2D" (conversion ..$Long::primitive ..$Double::primitive /.l2d (|>> host.long_to_double) double::=)))) (<| (_.context "float") ($_ _.and - (_.lift "F2I" (conversion ..$Float::primitive ..$Integer::primitive /.f2i (|>> host.float-to-int) int::=)) - (_.lift "F2L" (conversion ..$Float::primitive ..$Long::primitive /.f2l (|>> host.float-to-long) long::=)) - (_.lift "F2D" (conversion ..$Float::primitive ..$Double::primitive /.f2d (|>> host.float-to-double) double::=)))) + (_.lift "F2I" (conversion ..$Float::primitive ..$Integer::primitive /.f2i (|>> host.float_to_int) int::=)) + (_.lift "F2L" (conversion ..$Float::primitive ..$Long::primitive /.f2l (|>> host.float_to_long) long::=)) + (_.lift "F2D" (conversion ..$Float::primitive ..$Double::primitive /.f2d (|>> host.float_to_double) double::=)))) (<| (_.context "double") ($_ _.and - (_.lift "D2I" (conversion ..$Double::primitive ..$Integer::primitive /.d2i (|>> host.double-to-int) int::=)) - (_.lift "D2L" (conversion ..$Double::primitive ..$Long::primitive /.d2l (|>> host.double-to-long) long::=)) - (_.lift "D2F" (conversion ..$Double::primitive ..$Float::primitive /.d2f (|>> host.double-to-float) float::=)))) + (_.lift "D2I" (conversion ..$Double::primitive ..$Integer::primitive /.d2i (|>> host.double_to_int) int::=)) + (_.lift "D2L" (conversion ..$Double::primitive ..$Long::primitive /.d2l (|>> host.double_to_long) long::=)) + (_.lift "D2F" (conversion ..$Double::primitive ..$Float::primitive /.d2f (|>> host.double_to_float) float::=)))) ))) (def: value @@ -1119,14 +1119,14 @@ (def: registry Test - (let [store-and-load (: (All [a] + (let [store_and_load (: (All [a] (-> (Random a) (-> a (Bytecode Any)) (Bytecode Any) [(-> Nat (Bytecode Any)) (-> Nat (Bytecode Any))] (-> a (-> Any Bit)) (Random Bit))) - (function (_ random-value literal *wrap [store load] test) + (function (_ random_value literal *wrap [store load] test) (do {! random.monad} - [expected random-value + [expected random_value register (\ ! map (n.% 128) random.nat)] (<| (..bytecode (test expected)) (do /.monad @@ -1139,15 +1139,15 @@ (let [test (!::= java/lang/Integer "jvm ieq" "jvm int =")] ($_ _.and (_.lift "ISTORE_0/ILOAD_0" - (store-and-load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore-0) (function.constant /.iload-0)] test)) + (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_0) (function.constant /.iload_0)] test)) (_.lift "ISTORE_1/ILOAD_1" - (store-and-load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore-1) (function.constant /.iload-1)] test)) + (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_1) (function.constant /.iload_1)] test)) (_.lift "ISTORE_2/ILOAD_2" - (store-and-load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore-2) (function.constant /.iload-2)] test)) + (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_2) (function.constant /.iload_2)] test)) (_.lift "ISTORE_3/ILOAD_3" - (store-and-load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore-3) (function.constant /.iload-3)] test)) + (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_3) (function.constant /.iload_3)] test)) (_.lift "ISTORE/ILOAD" - (store-and-load ..$Integer::random ..$Integer::literal ..$Integer::wrap [/.istore /.iload] test)) + (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [/.istore /.iload] test)) (_.lift "IINC" (do {! random.monad} [base ..$Byte::random @@ -1156,110 +1156,110 @@ #let [expected (: java/lang/Long (for {@.old ("jvm ladd" - (host.byte-to-long base) + (host.byte_to_long base) (.int (/unsigned.value increment))) @.jvm ("jvm object cast" ("jvm long +" - ("jvm object cast" (host.byte-to-long base)) + ("jvm object cast" (host.byte_to_long base)) ("jvm object cast" (:coerce java/lang/Long (/unsigned.value increment)))))}))]] (..bytecode (|>> (:coerce Int) (i.= (:coerce Int expected))) (do /.monad [_ (..$Byte::literal base) - _ /.istore-0 + _ /.istore_0 _ (/.iinc 0 increment) - _ /.iload-0 + _ /.iload_0 _ /.i2l] ..$Long::wrap))))))) (<| (_.context "long") (let [test (!::= java/lang/Long "jvm leq" "jvm long =")] ($_ _.and (_.lift "LSTORE_0/LLOAD_0" - (store-and-load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore-0) (function.constant /.lload-0)] test)) + (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_0) (function.constant /.lload_0)] test)) (_.lift "LSTORE_1/LLOAD_1" - (store-and-load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore-1) (function.constant /.lload-1)] test)) + (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_1) (function.constant /.lload_1)] test)) (_.lift "LSTORE_2/LLOAD_2" - (store-and-load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore-2) (function.constant /.lload-2)] test)) + (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_2) (function.constant /.lload_2)] test)) (_.lift "LSTORE_3/LLOAD_3" - (store-and-load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore-3) (function.constant /.lload-3)] test)) + (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_3) (function.constant /.lload_3)] test)) (_.lift "LSTORE/LLOAD" - (store-and-load ..$Long::random ..$Long::literal ..$Long::wrap [/.lstore /.lload] test))))) + (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [/.lstore /.lload] test))))) (<| (_.context "float") (let [test (!::= java/lang/Float "jvm feq" "jvm float =")] ($_ _.and (_.lift "FSTORE_0/FLOAD_0" - (store-and-load ..valid-float ..$Float::literal ..$Float::wrap [(function.constant /.fstore-0) (function.constant /.fload-0)] test)) + (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_0) (function.constant /.fload_0)] test)) (_.lift "FSTORE_1/FLOAD_1" - (store-and-load ..valid-float ..$Float::literal ..$Float::wrap [(function.constant /.fstore-1) (function.constant /.fload-1)] test)) + (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_1) (function.constant /.fload_1)] test)) (_.lift "FSTORE_2/FLOAD_2" - (store-and-load ..valid-float ..$Float::literal ..$Float::wrap [(function.constant /.fstore-2) (function.constant /.fload-2)] test)) + (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_2) (function.constant /.fload_2)] test)) (_.lift "FSTORE_3/FLOAD_3" - (store-and-load ..valid-float ..$Float::literal ..$Float::wrap [(function.constant /.fstore-3) (function.constant /.fload-3)] test)) + (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_3) (function.constant /.fload_3)] test)) (_.lift "FSTORE/FLOAD" - (store-and-load ..valid-float ..$Float::literal ..$Float::wrap [/.fstore /.fload] test))))) + (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [/.fstore /.fload] test))))) (<| (_.context "double") (let [test (!::= java/lang/Double "jvm deq" "jvm double =")] ($_ _.and (_.lift "DSTORE_0/DLOAD_0" - (store-and-load ..valid-double ..$Double::literal ..$Double::wrap [(function.constant /.dstore-0) (function.constant /.dload-0)] test)) + (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_0) (function.constant /.dload_0)] test)) (_.lift "DSTORE_1/DLOAD_1" - (store-and-load ..valid-double ..$Double::literal ..$Double::wrap [(function.constant /.dstore-1) (function.constant /.dload-1)] test)) + (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_1) (function.constant /.dload_1)] test)) (_.lift "DSTORE_2/DLOAD_2" - (store-and-load ..valid-double ..$Double::literal ..$Double::wrap [(function.constant /.dstore-2) (function.constant /.dload-2)] test)) + (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_2) (function.constant /.dload_2)] test)) (_.lift "DSTORE_3/DLOAD_3" - (store-and-load ..valid-double ..$Double::literal ..$Double::wrap [(function.constant /.dstore-3) (function.constant /.dload-3)] test)) + (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_3) (function.constant /.dload_3)] test)) (_.lift "DSTORE/DLOAD" - (store-and-load ..valid-double ..$Double::literal ..$Double::wrap [/.dstore /.dload] test))))) + (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [/.dstore /.dload] test))))) (<| (_.context "object") (let [test (: (-> java/lang/String Any Bit) (function (_ expected actual) (|> actual (:coerce Text) (text\= (:coerce Text expected)))))] ($_ _.and (_.lift "ASTORE_0/ALOAD_0" - (store-and-load ..$String::random ..$String::literal /.nop [(function.constant /.astore-0) (function.constant /.aload-0)] test)) + (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_0) (function.constant /.aload_0)] test)) (_.lift "ASTORE_1/ALOAD_1" - (store-and-load ..$String::random ..$String::literal /.nop [(function.constant /.astore-1) (function.constant /.aload-1)] test)) + (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_1) (function.constant /.aload_1)] test)) (_.lift "ASTORE_2/ALOAD_2" - (store-and-load ..$String::random ..$String::literal /.nop [(function.constant /.astore-2) (function.constant /.aload-2)] test)) + (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_2) (function.constant /.aload_2)] test)) (_.lift "ASTORE_3/ALOAD_3" - (store-and-load ..$String::random ..$String::literal /.nop [(function.constant /.astore-3) (function.constant /.aload-3)] test)) + (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_3) (function.constant /.aload_3)] test)) (_.lift "ASTORE/ALOAD" - (store-and-load ..$String::random ..$String::literal /.nop [/.astore /.aload] test))))) + (store_and_load ..$String::random ..$String::literal /.nop [/.astore /.aload] test))))) ))) (def: stack Test (do random.monad [expected/1 $String::random - #let [object-test (: (-> Any Bit) + #let [object_test (: (-> Any Bit) (|>> (:coerce Text) (text\= (:coerce Text expected/1))))] dummy/1 $String::random #let [single ($_ _.and (<| (_.lift "DUP & POP") - (..bytecode object-test) + (..bytecode object_test) (do /.monad [_ ($String::literal expected/1) _ /.dup] /.pop)) (<| (_.lift "DUP_X1 & POP2") - (..bytecode object-test) + (..bytecode object_test) (do /.monad [_ ($String::literal dummy/1) _ ($String::literal expected/1) - _ /.dup-x1] + _ /.dup_x1] /.pop2)) (<| (_.lift "DUP_X2") - (..bytecode object-test) + (..bytecode object_test) (do /.monad [_ ($String::literal dummy/1) _ ($String::literal dummy/1) _ ($String::literal expected/1) - _ /.dup-x2 + _ /.dup_x2 _ /.pop2] /.pop)) (<| (_.lift "SWAP") - (..bytecode object-test) + (..bytecode object_test) (do /.monad [_ ($String::literal dummy/1) _ ($String::literal expected/1) @@ -1267,32 +1267,32 @@ /.pop)) )] expected/2 $Long::random - #let [long-test (: (-> Any Bit) + #let [long_test (: (-> Any Bit) (|>> (:coerce Int) (i.= (:coerce Int expected/2))))] dummy/2 $Long::random #let [double ($_ _.and (<| (_.lift "DUP2") - (..bytecode long-test) + (..bytecode long_test) (do /.monad [_ ($Long::literal expected/2) _ /.dup2 _ /.pop2] ..$Long::wrap)) (<| (_.lift "DUP2_X1") - (..bytecode long-test) + (..bytecode long_test) (do /.monad [_ ($String::literal dummy/1) _ ($Long::literal expected/2) - _ /.dup2-x1 + _ /.dup2_x1 _ /.pop2 _ /.pop] ..$Long::wrap)) (<| (_.lift "DUP2_X2") - (..bytecode long-test) + (..bytecode long_test) (do /.monad [_ ($Long::literal dummy/2) _ ($Long::literal expected/2) - _ /.dup2-x2 + _ /.dup2_x2 _ /.pop2 _ /.pop2] ..$Long::wrap)) @@ -1315,35 +1315,35 @@ (def: return Test - (let [primitive-return (: (All [a] (-> (Primitive a) (Bytecode Any) (Maybe (-> a (Bytecode Any))) (-> a Any Bit) (Random Bit))) + (let [primitive_return (: (All [a] (-> (Primitive a) (Bytecode Any) (Maybe (-> a (Bytecode Any))) (-> a Any Bit) (Random Bit))) (function (_ primitive return substitute test) (do random.monad - [class-name ..class-name - primitive-method-name (random.ascii/upper-alpha 10) - #let [primitive-method-type (/type.method [(list) (get@ #unboxed primitive) (list)])] - object-method-name (|> (random.ascii/upper-alpha 10) - (random.filter (|>> (text\= primitive-method-name) not))) + [class_name ..class_name + primitive_method_name (random.ascii/upper_alpha 10) + #let [primitive_method_type (/type.method [(list) (get@ #unboxed primitive) (list)])] + object_method_name (|> (random.ascii/upper_alpha 10) + (random.filter (|>> (text\= primitive_method_name) not))) expected (get@ #random primitive) - #let [$Self (/type.class class-name (list))]] + #let [$Self (/type.class class_name (list))]] (wrap (case (do try.monad [class (/class.class /version.v6_0 /class.public - (/name.internal class-name) + (/name.internal class_name) (/name.internal "java.lang.Object") (list) (list) - (list (/method.method ..method-modifier - primitive-method-name - primitive-method-type + (list (/method.method ..method_modifier + primitive_method_name + primitive_method_type (list) (#.Some (do /.monad [_ ((get@ #literal primitive) expected)] return))) - (/method.method ..method-modifier - object-method-name + (/method.method ..method_modifier + object_method_name (/type.method [(list) (get@ #boxed primitive) (list)]) (list) (#.Some (do /.monad - [_ (/.invokestatic $Self primitive-method-name primitive-method-type) + [_ (/.invokestatic $Self primitive_method_name primitive_method_type) _ (case substitute #.None (wrap []) @@ -1354,10 +1354,10 @@ /.areturn)))) (row.row)) #let [bytecode (format.run /class.writer class) - loader (/loader.memory (/loader.new-library []))] - _ (/loader.define class-name bytecode loader) - class (io.run (/loader.load class-name loader)) - method (host.try (get-method object-method-name class))] + loader (/loader.memory (/loader.new_library []))] + _ (/loader.define class_name bytecode loader) + class (io.run (/loader.load class_name loader)) + method (host.try (get_method object_method_name class))] (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)) (#try.Success actual) (test expected actual) @@ -1366,12 +1366,12 @@ false) ))))] ($_ _.and - (_.lift "IRETURN" (primitive-return ..$Integer::primitive /.ireturn #.None (!::= java/lang/Integer "jvm ieq" "jvm int ="))) - (_.lift "LRETURN" (primitive-return ..$Long::primitive /.lreturn #.None (!::= java/lang/Long "jvm leq" "jvm long ="))) - (_.lift "FRETURN" (primitive-return ..$Float::primitive /.freturn #.None (!::= java/lang/Float "jvm feq" "jvm float ="))) - (_.lift "DRETURN" (primitive-return ..$Double::primitive /.dreturn #.None (!::= java/lang/Double "jvm deq" "jvm double ="))) - (_.lift "ARETURN" (primitive-return ..$String::primitive /.areturn #.None (function (_ expected actual) (text\= (:coerce Text expected) (:coerce Text actual))))) - (_.lift "RETURN" (primitive-return (: (Primitive java/lang/String) + (_.lift "IRETURN" (primitive_return ..$Integer::primitive /.ireturn #.None (!::= java/lang/Integer "jvm ieq" "jvm int ="))) + (_.lift "LRETURN" (primitive_return ..$Long::primitive /.lreturn #.None (!::= java/lang/Long "jvm leq" "jvm long ="))) + (_.lift "FRETURN" (primitive_return ..$Float::primitive /.freturn #.None (!::= java/lang/Float "jvm feq" "jvm float ="))) + (_.lift "DRETURN" (primitive_return ..$Double::primitive /.dreturn #.None (!::= java/lang/Double "jvm deq" "jvm double ="))) + (_.lift "ARETURN" (primitive_return ..$String::primitive /.areturn #.None (function (_ expected actual) (text\= (:coerce Text expected) (:coerce Text actual))))) + (_.lift "RETURN" (primitive_return (: (Primitive java/lang/String) {#unboxed /type.void #boxed ..$String #wrap /.nop @@ -1391,25 +1391,25 @@ (function (_ instruction prelude) (<| (..bytecode ((!::= java/lang/Long "jvm leq" "jvm long =") expected)) (do /.monad - [@then /.new-label - @end /.new-label + [@then /.new_label + @end /.new_label _ prelude _ (instruction @then) _ (..$Long::literal dummy) _ (/.goto @end) - _ (/.set-label @then) + _ (/.set_label @then) _ (..$Long::literal expected) - _ (/.set-label @end)] + _ (/.set_label @end)] ..$Long::wrap)))) - comparison-against-zero ($_ _.and - (_.lift "IFEQ" (if! /.ifeq /.iconst-0)) - (_.lift "IFNE" (if! /.ifne /.iconst-1)) - (_.lift "IFLT" (if! /.iflt /.iconst-m1)) - (_.lift "IFLE" (if! /.ifle /.iconst-0)) - (_.lift "IFGT" (if! /.ifgt /.iconst-1)) - (_.lift "IFGE" (if! /.ifge /.iconst-0))) - null-test ($_ _.and - (_.lift "IFNULL" (if! /.ifnull /.aconst-null)) + comparison_against_zero ($_ _.and + (_.lift "IFEQ" (if! /.ifeq /.iconst_0)) + (_.lift "IFNE" (if! /.ifne /.iconst_1)) + (_.lift "IFLT" (if! /.iflt /.iconst_m1)) + (_.lift "IFLE" (if! /.ifle /.iconst_0)) + (_.lift "IFGT" (if! /.ifgt /.iconst_1)) + (_.lift "IFGE" (if! /.ifge /.iconst_0))) + null_test ($_ _.and + (_.lift "IFNULL" (if! /.ifnull /.aconst_null)) (_.lift "IFNONNULL" (if! /.ifnonnull (/.string ""))))] reference ..$Integer::random subject (|> ..$Integer::random @@ -1421,27 +1421,27 @@ ("jvm int <" ("jvm object cast" subject) ("jvm object cast" reference))}) [reference subject] [subject reference]) - int-comparison ($_ _.and - (_.lift "IF_ICMPEQ" (if! /.if-icmpeq (do /.monad [_ (..$Integer::literal reference)] /.dup))) - (_.lift "IF_ICMPNE" (if! /.if-icmpne (do /.monad [_ (..$Integer::literal reference)] (..$Integer::literal subject)))) - (_.lift "IF_ICMPLT" (if! /.if-icmplt (do /.monad [_ (..$Integer::literal lesser)] (..$Integer::literal greater)))) - (_.lift "IF_ICMPLE" (if! /.if-icmple (do /.monad [_ (..$Integer::literal lesser)] (..$Integer::literal greater)))) - (_.lift "IF_ICMPGT" (if! /.if-icmpgt (do /.monad [_ (..$Integer::literal greater)] (..$Integer::literal lesser)))) - (_.lift "IF_ICMPGE" (if! /.if-icmpge (do /.monad [_ (..$Integer::literal greater)] (..$Integer::literal lesser))))) - new-object (: (Bytecode Any) + int_comparison ($_ _.and + (_.lift "IF_ICMPEQ" (if! /.if_icmpeq (do /.monad [_ (..$Integer::literal reference)] /.dup))) + (_.lift "IF_ICMPNE" (if! /.if_icmpne (do /.monad [_ (..$Integer::literal reference)] (..$Integer::literal subject)))) + (_.lift "IF_ICMPLT" (if! /.if_icmplt (do /.monad [_ (..$Integer::literal lesser)] (..$Integer::literal greater)))) + (_.lift "IF_ICMPLE" (if! /.if_icmple (do /.monad [_ (..$Integer::literal lesser)] (..$Integer::literal greater)))) + (_.lift "IF_ICMPGT" (if! /.if_icmpgt (do /.monad [_ (..$Integer::literal greater)] (..$Integer::literal lesser)))) + (_.lift "IF_ICMPGE" (if! /.if_icmpge (do /.monad [_ (..$Integer::literal greater)] (..$Integer::literal lesser))))) + new_object (: (Bytecode Any) (do /.monad [_ (/.new ..$Object) _ /.dup] (/.invokespecial ..$Object "<init>" (/type.method [(list) /type.void (list)])))) - reference-comparison ($_ _.and - (_.lift "IF_ACMPEQ" (if! /.if-acmpeq (do /.monad [_ new-object] /.dup))) - (_.lift "IF_ACMPNE" (if! /.if-acmpne (do /.monad [_ new-object] new-object))) + reference_comparison ($_ _.and + (_.lift "IF_ACMPEQ" (if! /.if_acmpeq (do /.monad [_ new_object] /.dup))) + (_.lift "IF_ACMPNE" (if! /.if_acmpne (do /.monad [_ new_object] new_object))) )]] ($_ _.and - comparison-against-zero - null-test - int-comparison - reference-comparison + comparison_against_zero + null_test + int_comparison + reference_comparison ))) (def: jump @@ -1453,20 +1453,20 @@ (function (_ goto) (<| (..bytecode ((!::= java/lang/Long "jvm leq" "jvm long =") expected)) (do /.monad - [@skipped /.new-label - @value /.new-label - @end /.new-label + [@skipped /.new_label + @value /.new_label + @end /.new_label _ (goto @value) - _ (/.set-label @skipped) + _ (/.set_label @skipped) _ (..$Long::literal dummy) _ (goto @end) - _ (/.set-label @value) + _ (/.set_label @value) _ (..$Long::literal expected) - _ (/.set-label @end)] + _ (/.set_label @end)] ..$Long::wrap))))]] ($_ _.and (_.lift "GOTO" (jump /.goto)) - (_.lift "GOTO_W" (jump /.goto-w))))) + (_.lift "GOTO_W" (jump /.goto_w))))) (def: switch Test @@ -1480,17 +1480,17 @@ afterwards (\ ! map (n.% 10) random.nat)]) (..bytecode ((!::= java/lang/Long "jvm leq" "jvm long =") expected)) (do /.monad - [@right /.new-label - @wrong /.new-label - @return /.new-label + [@right /.new_label + @wrong /.new_label + @return /.new_label _ (/.bipush (|> minimum /signed.value .int /signed.s1 try.assume)) _ (/.tableswitch minimum @wrong [@right (list.repeat afterwards @wrong)]) - _ (/.set-label @wrong) + _ (/.set_label @wrong) _ (..$Long::literal dummy) _ (/.goto @return) - _ (/.set-label @right) + _ (/.set_label @right) _ (..$Long::literal expected) - _ (/.set-label @return)] + _ (/.set_label @return)] ..$Long::wrap)) (<| (_.lift "LOOKUPSWITCH") (do {! random.monad} @@ -1498,28 +1498,28 @@ random.nat) choice (\ ! map (n.% options) random.nat) options (|> random.int - (\ ! map (|>> (:coerce java/lang/Long) host.long-to-int host.int-to-long (:coerce Int))) + (\ ! map (|>> (:coerce java/lang/Long) host.long_to_int host.int_to_long (:coerce Int))) (random.set i.hash options) - (\ ! map set.to-list)) + (\ ! map set.to_list)) #let [choice (maybe.assume (list.nth choice options))] expected ..$Long::random dummy ..$Long::random]) (..bytecode ((!::= java/lang/Long "jvm leq" "jvm long =") expected)) (do /.monad - [@right /.new-label - @wrong /.new-label - @return /.new-label - _ (..$Integer::literal (host.long-to-int (:coerce java/lang/Long choice))) + [@right /.new_label + @wrong /.new_label + @return /.new_label + _ (..$Integer::literal (host.long_to_int (:coerce java/lang/Long choice))) _ (/.lookupswitch @wrong (list\map (function (_ option) [(|> option /signed.s4 try.assume) (if (i.= choice option) @right @wrong)]) options)) - _ (/.set-label @wrong) + _ (/.set_label @wrong) _ (..$Long::literal dummy) _ (/.goto @return) - _ (/.set-label @right) + _ (/.set_label @right) _ (..$Long::literal expected) - _ (/.set-label @return)] + _ (/.set_label @return)] ..$Long::wrap)) )) @@ -1533,24 +1533,24 @@ (..bytecode ((!::= java/lang/Long "jvm leq" "jvm long =") expected)) (do /.monad [#let [$Exception (/type.class "java.lang.Exception" (list))] - @skipped /.new-label - @try /.new-label - @handler /.new-label - @return /.new-label + @skipped /.new_label + @try /.new_label + @handler /.new_label + @return /.new_label _ (/.try @try @handler @handler $Exception) - _ (/.set-label @try) + _ (/.set_label @try) _ (/.new $Exception) _ /.dup _ (..$String::literal exception) _ (/.invokespecial $Exception "<init>" (/type.method [(list ..$String) /type.void (list)])) _ /.athrow - _ (/.set-label @skipped) + _ (/.set_label @skipped) _ (..$Long::literal dummy) _ (/.goto @return) - _ (/.set-label @handler) + _ (/.set_label @handler) _ /.pop _ (..$Long::literal expected) - _ (/.set-label @return)] + _ (/.set_label @return)] ..$Long::wrap)))) (def: code @@ -1582,17 +1582,17 @@ (def: inheritance Test (do random.monad - [abstract-class ..class-name - interface-class (|> ..class-name - (random.filter (|>> (text\= abstract-class) not))) - concrete-class (|> ..class-name + [abstract_class ..class_name + interface_class (|> ..class_name + (random.filter (|>> (text\= abstract_class) not))) + concrete_class (|> ..class_name (random.filter (function (_ class) - (not (or (text\= abstract-class class) - (text\= interface-class class)))))) + (not (or (text\= abstract_class class) + (text\= interface_class class)))))) part0 ..$Long::random part1 ..$Long::random part2 ..$Long::random - fake-part2 ..$Long::random + fake_part2 ..$Long::random part3 ..$Long::random part4 ..$Long::random #let [expected ($_ i.+ @@ -1601,19 +1601,19 @@ (:coerce Int part2) (:coerce Int part3) (:coerce Int part4)) - $Concrete (/type.class concrete-class (list)) - $Abstract (/type.class abstract-class (list)) - $Interface (/type.class interface-class (list)) + $Concrete (/type.class concrete_class (list)) + $Abstract (/type.class abstract_class (list)) + $Interface (/type.class interface_class (list)) constructor::type (/type.method [(list) /type.void (list)]) method::type (/type.method [(list) /type.long (list)]) - inherited-method "inherited_method" - overriden-method "overriden_method" - abstract-method "abstract_method" - interface-method "interface_method" - virtual-method "virtual_method" - static-method "static_method" + inherited_method "inherited_method" + overriden_method "overriden_method" + abstract_method "abstract_method" + interface_method "interface_method" + virtual_method "virtual_method" + static_method "static_method" method (: (-> Text java/lang/Long (Resource Method)) (function (_ name value) @@ -1625,18 +1625,18 @@ [_ (..$Long::literal value)] /.lreturn))))) - interface-bytecode (|> (/class.class /version.v6_0 ($_ /modifier\compose /class.public /class.abstract /class.interface) - (/name.internal interface-class) + interface_bytecode (|> (/class.class /version.v6_0 ($_ /modifier\compose /class.public /class.abstract /class.interface) + (/name.internal interface_class) (/name.internal "java.lang.Object") (list) (list) (list (/method.method ($_ /modifier\compose /method.public /method.abstract) - interface-method method::type (list) #.None)) + interface_method method::type (list) #.None)) (row.row)) try.assume (format.run /class.writer)) - abstract-bytecode (|> (/class.class /version.v6_0 ($_ /modifier\compose /class.public /class.abstract) - (/name.internal abstract-class) + abstract_bytecode (|> (/class.class /version.v6_0 ($_ /modifier\compose /class.public /class.abstract) + (/name.internal abstract_class) (/name.internal "java.lang.Object") (list) (list) @@ -1645,71 +1645,71 @@ constructor::type (list) (#.Some (do /.monad - [_ /.aload-0 + [_ /.aload_0 _ (/.invokespecial ..$Object "<init>" constructor::type)] /.return))) - (method inherited-method part0) - (method overriden-method fake-part2) + (method inherited_method part0) + (method overriden_method fake_part2) (/method.method ($_ /modifier\compose /method.public /method.abstract) - abstract-method method::type (list) #.None)) + abstract_method method::type (list) #.None)) (row.row)) try.assume (format.run /class.writer)) invoke (: (-> (Type Class) Text (Bytecode Any)) (function (_ class method) (do /.monad - [_ /.aload-0] + [_ /.aload_0] (/.invokevirtual class method method::type)))) - concrete-bytecode (|> (/class.class /version.v6_0 /class.public - (/name.internal concrete-class) - (/name.internal abstract-class) - (list (/name.internal interface-class)) + concrete_bytecode (|> (/class.class /version.v6_0 /class.public + (/name.internal concrete_class) + (/name.internal abstract_class) + (list (/name.internal interface_class)) (list) (list (/method.method /method.public "<init>" constructor::type (list) (#.Some (do /.monad - [_ /.aload-0 + [_ /.aload_0 _ (/.invokespecial $Abstract "<init>" constructor::type)] /.return))) - (method virtual-method part1) - (method overriden-method part2) - (method abstract-method part3) - (method interface-method part4) + (method virtual_method part1) + (method overriden_method part2) + (method abstract_method part3) + (method interface_method part4) (/method.method ($_ /modifier\compose /method.public /method.static) - static-method + static_method (/type.method [(list) ..$Long (list)]) (list) (#.Some (do /.monad [_ (/.new $Concrete) _ /.dup _ (/.invokespecial $Concrete "<init>" constructor::type) - _ /.astore-0 - _ (invoke $Abstract inherited-method) - _ (invoke $Concrete virtual-method) + _ /.astore_0 + _ (invoke $Abstract inherited_method) + _ (invoke $Concrete virtual_method) _ /.ladd - _ (invoke $Abstract overriden-method) + _ (invoke $Abstract overriden_method) _ /.ladd - _ /.aload-0 _ (/.invokeinterface $Interface interface-method method::type) + _ /.aload_0 _ (/.invokeinterface $Interface interface_method method::type) _ /.ladd - _ (invoke $Abstract abstract-method) + _ (invoke $Abstract abstract_method) _ /.ladd _ ..$Long::wrap] /.areturn)))) (row.row)) try.assume (format.run /class.writer)) - loader (/loader.memory (/loader.new-library []))]] + loader (/loader.memory (/loader.new_library []))]] (_.test "Class & interface inheritance" (case (do try.monad - [_ (/loader.define abstract-class abstract-bytecode loader) - _ (/loader.define interface-class interface-bytecode loader) - _ (/loader.define concrete-class concrete-bytecode loader) - class (io.run (/loader.load concrete-class loader)) - method (host.try (get-method static-method class)) + [_ (/loader.define abstract_class abstract_bytecode loader) + _ (/loader.define interface_class interface_bytecode loader) + _ (/loader.define concrete_class concrete_bytecode loader) + class (io.run (/loader.load concrete_class loader)) + method (host.try (get_method static_method class)) output (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)] (wrap (:coerce Int output))) (#try.Success actual) @@ -1720,7 +1720,7 @@ (def: #export test Test - (<| (_.context (%.name (name-of .._))) + (<| (_.context (%.name (name_of .._))) ($_ _.and (<| (_.context "instruction") ..instruction) diff --git a/stdlib/source/test/lux/time/date.lux b/stdlib/source/test/lux/time/date.lux index 574bed8d6..7ad0e8ddc 100644 --- a/stdlib/source/test/lux/time/date.lux +++ b/stdlib/source/test/lux/time/date.lux @@ -27,7 +27,7 @@ (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) ($_ _.and ($equivalence.spec /.equivalence ..date) ($order.spec /.order ..date) diff --git a/stdlib/source/test/lux/time/day.lux b/stdlib/source/test/lux/time/day.lux index ffe896cdc..a08b54659 100644 --- a/stdlib/source/test/lux/time/day.lux +++ b/stdlib/source/test/lux/time/day.lux @@ -25,7 +25,7 @@ (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) ($_ _.and ($equivalence.spec /.equivalence ..day) ($order.spec /.order ..day) diff --git a/stdlib/source/test/lux/time/duration.lux b/stdlib/source/test/lux/time/duration.lux index bd7756f06..89d9a4db7 100644 --- a/stdlib/source/test/lux/time/duration.lux +++ b/stdlib/source/test/lux/time/duration.lux @@ -21,11 +21,11 @@ (def: #export duration (Random Duration) - (\ random.monad map /.from-millis random.int)) + (\ random.monad map /.from_millis random.int)) (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) ($_ _.and ($equivalence.spec /.equivalence ..duration) ($order.spec /.order ..duration) @@ -35,7 +35,7 @@ (do random.monad [millis random.int] (_.test "Can convert from/to milliseconds." - (|> millis /.from-millis /.to-millis (i.= millis)))) + (|> millis /.from_millis /.to_millis (i.= millis)))) (do {! random.monad} [sample (|> duration (\ ! map (/.frame /.day))) frame duration @@ -43,9 +43,9 @@ #let [(^open "/\.") /.order]] ($_ _.and (_.test "Can scale a duration." - (|> sample (/.scale-up factor) (/.query sample) (i.= (.int factor)))) + (|> sample (/.scale_up factor) (/.query sample) (i.= (.int factor)))) (_.test "Scaling a duration by one does not change it." - (|> sample (/.scale-up 1) (/\= sample))) + (|> sample (/.scale_up 1) (/\= sample))) (_.test "Merging a duration with it's opposite yields an empty duration." (|> sample (/.merge (/.inverse sample)) (/\= /.empty))))) ))) diff --git a/stdlib/source/test/lux/time/instant.lux b/stdlib/source/test/lux/time/instant.lux index d24a4438d..cc2c0a742 100644 --- a/stdlib/source/test/lux/time/instant.lux +++ b/stdlib/source/test/lux/time/instant.lux @@ -28,11 +28,11 @@ (def: #export instant (Random Instant) - (\ random.monad map /.from-millis random.int)) + (\ random.monad map /.from_millis random.int)) (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) ($_ _.and ($equivalence.spec /.equivalence ..instant) ($order.spec /.order ..instant) @@ -42,7 +42,7 @@ (do random.monad [millis random.int] (_.test "Can convert from/to milliseconds." - (|> millis /.from-millis /.to-millis (i.= millis)))) + (|> millis /.from_millis /.to_millis (i.= millis)))) (do random.monad [sample instant span _duration.duration diff --git a/stdlib/source/test/lux/time/month.lux b/stdlib/source/test/lux/time/month.lux index 1ebd3810c..d7078fa65 100644 --- a/stdlib/source/test/lux/time/month.lux +++ b/stdlib/source/test/lux/time/month.lux @@ -30,7 +30,7 @@ (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) ($_ _.and ($equivalence.spec /.equivalence ..month) ($order.spec /.order ..month) diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux index 239e77434..c06b89478 100644 --- a/stdlib/source/test/lux/type.lux +++ b/stdlib/source/test/lux/type.lux @@ -53,7 +53,7 @@ (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) ($_ _.and (do r.monad [sample ..random] @@ -75,14 +75,14 @@ (_.test "Can remove aliases from an already-named type." (\ /.equivalence = base - (/.un-alias aliased))) + (/.un_alias aliased))) (_.test "Can remove all names from a type." (and (not (\ /.equivalence = base - (/.un-name aliased))) + (/.un_name aliased))) (\ /.equivalence = - (/.un-name base) - (/.un-name aliased)))))) + (/.un_name base) + (/.un_name aliased)))))) (do {! r.monad} [size (|> r.nat (\ ! map (n.% 3))) members (|> ..random @@ -105,8 +105,8 @@ (and (list\= (list) members) (list\= (list <unit>) flat)))))] - ["variant" /.variant /.flatten-variant Nothing] - ["tuple" /.tuple /.flatten-tuple Any] + ["variant" /.variant /.flatten_variant Nothing] + ["tuple" /.tuple /.flatten_tuple Any] )) ))) (do {! r.monad} @@ -124,12 +124,12 @@ (^open "list\.") (list.equivalence /.equivalence)]] ($_ _.and (_.test "Can build and tear-down function types." - (let [[inputs output] (|> (/.function members extra) /.flatten-function)] + (let [[inputs output] (|> (/.function members extra) /.flatten_function)] (and (list\= members inputs) (/\= extra output)))) (_.test "Can build and tear-down application types." - (let [[tfunc tparams] (|> extra (/.application members) /.flatten-application)] + (let [[tfunc tparams] (|> extra (/.application members) /.flatten_application)] (n.= (list.size members) (list.size tparams)))) )) (do {! r.monad} @@ -146,19 +146,19 @@ (`` ($_ _.and (~~ (template [<desc> <ctor> <dtor>] [(_.test (format "Can build and tear-down " <desc> " types.") - (let [[flat-size flat-body] (|> extra (<ctor> size) <dtor>)] - (and (n.= size flat-size) - (/\= extra flat-body))))] + (let [[flat_size flat_body] (|> extra (<ctor> size) <dtor>)] + (and (n.= size flat_size) + (/\= extra flat_body))))] - ["universally-quantified" /.univ-q /.flatten-univ-q] - ["existentially-quantified" /.ex-q /.flatten-ex-q] + ["universally-quantified" /.univ_q /.flatten_univ_q] + ["existentially-quantified" /.ex_q /.flatten_ex_q] )) ))) - (_.test (%.name (name-of /.:by-example)) + (_.test (%.name (name_of /.:by_example)) (let [example (: (Maybe Nat) #.None)] (/\= (.type (List Nat)) - (/.:by-example [a] + (/.:by_example [a] {(Maybe a) example} (List a))))) diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux index dad107b5e..c41f610dc 100644 --- a/stdlib/source/test/lux/type/check.lux +++ b/stdlib/source/test/lux/type/check.lux @@ -29,30 +29,30 @@ (r.Random Name) (r.and ..short ..short)) -(def: (type' num-vars) +(def: (type' num_vars) (-> Nat (r.Random Type)) (r.rec (function (_ recur) (let [(^open "R\.") r.monad pairG (r.and recur recur) - quantifiedG (r.and (R\wrap (list)) (type' (inc num-vars))) - random-pair (r.either (r.either (R\map (|>> #.Sum) pairG) + quantifiedG (r.and (R\wrap (list)) (type' (inc num_vars))) + random_pair (r.either (r.either (R\map (|>> #.Sum) pairG) (R\map (|>> #.Product) pairG)) (r.either (R\map (|>> #.Function) pairG) (R\map (|>> #.Apply) pairG))) - random-id (let [random-id (r.either (R\map (|>> #.Var) r.nat) + random_id (let [random_id (r.either (R\map (|>> #.Var) r.nat) (R\map (|>> #.Ex) r.nat))] - (case num-vars - 0 random-id - _ (r.either (R\map (|>> (n.% num-vars) (n.* 2) inc #.Parameter) r.nat) - random-id))) - random-quantified (r.either (R\map (|>> #.UnivQ) quantifiedG) + (case num_vars + 0 random_id + _ (r.either (R\map (|>> (n.% num_vars) (n.* 2) inc #.Parameter) r.nat) + random_id))) + random_quantified (r.either (R\map (|>> #.UnivQ) quantifiedG) (R\map (|>> #.ExQ) quantifiedG))] ($_ r.either (R\map (|>> #.Primitive) (r.and ..short (R\wrap (list)))) - random-pair - random-id - random-quantified + random_pair + random_id + random_quantified (R\map (|>> #.Named) (r.and ..name (type' 0))) ))))) @@ -60,54 +60,54 @@ (r.Random Type) (..type' 0)) -(def: (valid-type? type) +(def: (valid_type? type) (-> Type Bit) (case type (#.Primitive name params) - (list.every? valid-type? params) + (list.every? valid_type? params) (#.Ex id) #1 (^template [<tag>] [(<tag> left right) - (and (valid-type? left) (valid-type? right))]) + (and (valid_type? left) (valid_type? right))]) ([#.Sum] [#.Product] [#.Function]) (#.Named name type') - (valid-type? type') + (valid_type? type') _ #0)) -(def: (type-checks? input) +(def: (type_checks? input) (-> (/.Check []) Bit) - (case (/.run /.fresh-context input) + (case (/.run /.fresh_context input) (#.Right []) #1 (#.Left error) #0)) -(def: (build-ring num-connections) +(def: (build_ring num_connections) (-> Nat (/.Check [[Nat Type] (List [Nat Type]) [Nat Type]])) (do {! /.monad} - [[head-id head-type] /.var - ids+types (monad.seq ! (list.repeat num-connections /.var)) - [tail-id tail-type] (monad.fold ! (function (_ [tail-id tail-type] [_head-id _head-type]) + [[head_id head_type] /.var + ids+types (monad.seq ! (list.repeat num_connections /.var)) + [tail_id tail_type] (monad.fold ! (function (_ [tail_id tail_type] [_head_id _head_type]) (do ! - [_ (/.check head-type tail-type)] - (wrap [tail-id tail-type]))) - [head-id head-type] + [_ (/.check head_type tail_type)] + (wrap [tail_id tail_type]))) + [head_id head_type] ids+types)] - (wrap [[head-id head-type] ids+types [tail-id tail-type]]))) + (wrap [[head_id head_type] ids+types [tail_id tail_type]]))) (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) ($_ _.and (do r.monad - [sample (r.filter ..valid-type? ..type)] + [sample (r.filter ..valid_type? ..type)] ($_ _.and (_.test "Any is the super-type of everything." (/.checks? Any sample)) @@ -119,23 +119,23 @@ (and (/.checks? Nothing Nothing) (/.checks? Any Any))) (_.test "Existential types only match with themselves." - (and (type-checks? (do /.monad + (and (type_checks? (do /.monad [[_ exT] /.existential] (/.check exT exT))) - (not (type-checks? (do /.monad + (not (type_checks? (do /.monad [[_ exTL] /.existential [_ exTR] /.existential] (/.check exTL exTR)))))) (_.test "Names do not affect type-checking." - (and (type-checks? (do /.monad + (and (type_checks? (do /.monad [[_ exT] /.existential] (/.check (#.Named ["module" "name"] exT) exT))) - (type-checks? (do /.monad + (type_checks? (do /.monad [[_ exT] /.existential] (/.check exT (#.Named ["module" "name"] exT)))) - (type-checks? (do /.monad + (type_checks? (do /.monad [[_ exT] /.existential] (/.check (#.Named ["module" "name"] exT) (#.Named ["module" "name"] exT)))))) @@ -154,9 +154,9 @@ (/.checks? (type.tuple (list meta data)) (|> Ann (#.Apply meta) (#.Apply data)))))) (do r.monad - [#let [gen-short (r.ascii 10)] - nameL gen-short - nameR (|> gen-short (r.filter (|>> (text\= nameL) not))) + [#let [gen_short (r.ascii 10)] + nameL gen_short + nameR (|> gen_short (r.filter (|>> (text\= nameL) not))) paramL ..type paramR (r.filter (|>> (/.checks? paramL) not) ..type)] ($_ _.and @@ -172,86 +172,86 @@ )) ($_ _.and (_.test "Type-vars check against themselves." - (type-checks? (do /.monad + (type_checks? (do /.monad [[id var] /.var] (/.check var var)))) (_.test "Can bind unbound type-vars by type-checking against them." - (and (type-checks? (do /.monad + (and (type_checks? (do /.monad [[id var] /.var] (/.check var .Any))) - (type-checks? (do /.monad + (type_checks? (do /.monad [[id var] /.var] (/.check .Any var))))) (_.test "Cannot rebind already bound type-vars." - (not (type-checks? (do /.monad + (not (type_checks? (do /.monad [[id var] /.var _ (/.check var .Bit)] (/.check var .Nat))))) (_.test "If the type bound to a var is a super-type to another, then the var is also a super-type." - (type-checks? (do /.monad + (type_checks? (do /.monad [[id var] /.var _ (/.check var Any)] (/.check var .Bit)))) (_.test "If the type bound to a var is a sub-type of another, then the var is also a sub-type." - (type-checks? (do /.monad + (type_checks? (do /.monad [[id var] /.var _ (/.check var Nothing)] (/.check .Bit var)))) ) (do {! r.monad} - [num-connections (|> r.nat (\ ! map (n.% 100))) + [num_connections (|> r.nat (\ ! map (n.% 100))) boundT (|> ..type (r.filter (|>> (case> (#.Var _) #0 _ #1)))) - pick-pcg (r.and r.nat r.nat)] + pick_pcg (r.and r.nat r.nat)] ($_ _.and (_.test "Can create rings of variables." - (type-checks? (do /.monad - [[[head-id head-type] ids+types [tail-id tail-type]] (build-ring num-connections) + (type_checks? (do /.monad + [[[head_id head_type] ids+types [tail_id tail_type]] (build_ring num_connections) #let [ids (list\map product.left ids+types)] - headR (/.ring head-id) - tailR (/.ring tail-id)] + headR (/.ring head_id) + tailR (/.ring tail_id)] (/.assert "" - (let [same-rings? (\ set.equivalence = headR tailR) - expected-size? (n.= (inc num-connections) (set.size headR)) - same-vars? (|> (set.to-list headR) + (let [same_rings? (\ set.equivalence = headR tailR) + expected_size? (n.= (inc num_connections) (set.size headR)) + same_vars? (|> (set.to_list headR) (list.sort n.<) - (\ (list.equivalence n.equivalence) = (list.sort n.< (#.Cons head-id ids))))] - (and same-rings? - expected-size? - same-vars?)))))) + (\ (list.equivalence n.equivalence) = (list.sort n.< (#.Cons head_id ids))))] + (and same_rings? + expected_size? + same_vars?)))))) (_.test "When a var in a ring is bound, all the ring is bound." - (type-checks? (do {! /.monad} - [[[head-id headT] ids+types tailT] (build-ring num-connections) + (type_checks? (do {! /.monad} + [[[head_id headT] ids+types tailT] (build_ring num_connections) #let [ids (list\map product.left ids+types)] _ (/.check headT boundT) - head-bound (/.read head-id) - tail-bound (monad.map ! /.read ids) - headR (/.ring head-id) + head_bound (/.read head_id) + tail_bound (monad.map ! /.read ids) + headR (/.ring head_id) tailR+ (monad.map ! /.ring ids)] - (let [rings-were-erased? (and (set.empty? headR) + (let [rings_were_erased? (and (set.empty? headR) (list.every? set.empty? tailR+)) - same-types? (list.every? (type\= boundT) (list& (maybe.default headT head-bound) - (list\map (function (_ [tail-id ?tailT]) - (maybe.default (#.Var tail-id) ?tailT)) - (list.zip/2 ids tail-bound))))] + same_types? (list.every? (type\= boundT) (list& (maybe.default headT head_bound) + (list\map (function (_ [tail_id ?tailT]) + (maybe.default (#.Var tail_id) ?tailT)) + (list.zip/2 ids tail_bound))))] (/.assert "" - (and rings-were-erased? - same-types?)))))) + (and rings_were_erased? + same_types?)))))) (_.test "Can merge multiple rings of variables." - (type-checks? (do /.monad - [[[head-idL headTL] ids+typesL [tail-idL tailTL]] (build-ring num-connections) - [[head-idR headTR] ids+typesR [tail-idR tailTR]] (build-ring num-connections) - headRL-pre (/.ring head-idL) - headRR-pre (/.ring head-idR) + (type_checks? (do /.monad + [[[head_idL headTL] ids+typesL [tail_idL tailTL]] (build_ring num_connections) + [[head_idR headTR] ids+typesR [tail_idR tailTR]] (build_ring num_connections) + headRL_pre (/.ring head_idL) + headRR_pre (/.ring head_idR) _ (/.check headTL headTR) - headRL-post (/.ring head-idL) - headRR-post (/.ring head-idR)] + headRL_post (/.ring head_idL) + headRR_post (/.ring head_idR)] (/.assert "" - (let [same-rings? (\ set.equivalence = headRL-post headRR-post) - expected-size? (n.= (n.* 2 (inc num-connections)) - (set.size headRL-post)) - union? (\ set.equivalence = headRL-post (set.union headRL-pre headRR-pre))] - (and same-rings? - expected-size? + (let [same_rings? (\ set.equivalence = headRL_post headRR_post) + expected_size? (n.= (n.* 2 (inc num_connections)) + (set.size headRL_post)) + union? (\ set.equivalence = headRL_post (set.union headRL_pre headRR_pre))] + (and same_rings? + expected_size? union?)))))) )) ))) diff --git a/stdlib/source/test/lux/type/dynamic.lux b/stdlib/source/test/lux/type/dynamic.lux index 960a8ab9d..4cb4e5093 100644 --- a/stdlib/source/test/lux/type/dynamic.lux +++ b/stdlib/source/test/lux/type/dynamic.lux @@ -14,7 +14,7 @@ (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) (do r.monad [expected r.nat #let [value (:dynamic expected)]] diff --git a/stdlib/source/test/lux/type/implicit.lux b/stdlib/source/test/lux/type/implicit.lux index 99e0c64ae..f78637b1b 100644 --- a/stdlib/source/test/lux/type/implicit.lux +++ b/stdlib/source/test/lux/type/implicit.lux @@ -20,7 +20,7 @@ (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) (do {! random.monad} [#let [digit (\ ! map (n.% 10) random.nat)] left digit diff --git a/stdlib/source/test/lux/type/resource.lux b/stdlib/source/test/lux/type/resource.lux index 298b95ad7..7f84dcd2b 100644 --- a/stdlib/source/test/lux/type/resource.lux +++ b/stdlib/source/test/lux/type/resource.lux @@ -16,39 +16,39 @@ (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) ($_ _.and (_.test "Can produce and consume keys in an ordered manner." (<| (n.= (n.+ 123 456)) io.run - /.run-sync + /.run_sync (do /.sync - [res|left (/.ordered-sync 123) - res|right (/.ordered-sync 456) - right (/.read-sync res|right) - left (/.read-sync res|left)] + [res|left (/.ordered_sync 123) + res|right (/.ordered_sync 456) + right (/.read_sync res|right) + left (/.read_sync res|left)] (wrap (n.+ left right))))) (_.test "Can exchange commutative keys." (<| (n.= (n.+ 123 456)) io.run - /.run-sync + /.run_sync (do /.sync - [res|left (/.commutative-sync 123) - res|right (/.commutative-sync 456) - _ (/.exchange-sync [1 0]) - left (/.read-sync res|left) - right (/.read-sync res|right)] + [res|left (/.commutative_sync 123) + res|right (/.commutative_sync 456) + _ (/.exchange_sync [1 0]) + left (/.read_sync res|left) + right (/.read_sync res|right)] (wrap (n.+ left right))))) (_.test "Can group and un-group keys." (<| (n.= (n.+ 123 456)) io.run - /.run-sync + /.run_sync (do /.sync - [res|left (/.commutative-sync 123) - res|right (/.commutative-sync 456) - _ (/.group-sync 2) - _ (/.un-group-sync 2) - right (/.read-sync res|right) - left (/.read-sync res|left)] + [res|left (/.commutative_sync 123) + res|right (/.commutative_sync 456) + _ (/.group_sync 2) + _ (/.un_group_sync 2) + right (/.read_sync res|right) + left (/.read_sync res|left)] (wrap (n.+ left right))))) ))) diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux index 56291563d..b7c7d3a50 100644 --- a/stdlib/source/test/lux/world/console.lux +++ b/stdlib/source/test/lux/world/console.lux @@ -17,22 +17,22 @@ (def: simulation (/.Simulation Bit) (structure - (def: (on-read dead?) + (def: (on_read dead?) (if dead? (exception.throw ..dead []) (#try.Success [dead? (char "a")]))) - (def: (on-read-line dead?) + (def: (on_read_line dead?) (if dead? (exception.throw ..dead []) (#try.Success [dead? "YOLO"]))) - (def: (on-write message dead?) + (def: (on_write message dead?) (if dead? (exception.throw ..dead []) (#try.Success dead?))) - (def: (on-close dead?) + (def: (on_close dead?) (if dead? (exception.throw ..dead []) (#try.Success true))))) diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux index 35706fa8a..173bd7586 100644 --- a/stdlib/source/test/lux/world/file.lux +++ b/stdlib/source/test/lux/world/file.lux @@ -30,37 +30,37 @@ [data ["_." binary]]]) -(def: truncate-millis +(def: truncate_millis (let [millis +1,000] (|>> (i./ millis) (i.* millis)))) -(def: (creation-and-deletion number) +(def: (creation_and_deletion number) (-> Nat Test) (r\wrap (do promise.monad [#let [path (format "temp_file_" (%.nat number))] result (promise.future (do (try.with io.monad) - [#let [check-existence! (: (IO (Try Bit)) + [#let [check_existence! (: (IO (Try Bit)) (try.lift io.monad (/.exists? io.monad /.default path)))] - pre! check-existence! - file (!.use (\ /.default create-file) path) - post! check-existence! + pre! check_existence! + file (!.use (\ /.default create_file) path) + post! check_existence! _ (!.use (\ file delete) []) - remains? check-existence!] + remains? check_existence!] (wrap (and (not pre!) post! (not remains?)))))] (_.assert "Can create/delete files." (try.default #0 result))))) -(def: (read-and-write number data) +(def: (read_and_write number data) (-> Nat Binary Test) (r\wrap (do promise.monad [#let [path (format "temp_file_" (%.nat number))] result (promise.future (do (try.with io.monad) - [file (!.use (\ /.default create-file) path) - _ (!.use (\ file over-write) data) + [file (!.use (\ /.default create_file) path) + _ (!.use (\ file over_write) data) content (!.use (\ file content) []) _ (!.use (\ file delete) [])] (wrap (\ binary.equivalence = data content))))] @@ -69,114 +69,114 @@ (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) (do {! r.monad} - [file-size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 10)))) - dataL (_binary.random file-size) - dataR (_binary.random file-size) - new-modified (|> r.int (\ ! map (|>> i.abs + [file_size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 10)))) + dataL (_binary.random file_size) + dataR (_binary.random file_size) + new_modified (|> r.int (\ ! map (|>> i.abs (i.% +10,000,000,000,000) - truncate-millis - duration.from-millis + truncate_millis + duration.from_millis instant.absolute)))] ($_ _.and - ## (..creation-and-deletion 0) - ## (..read-and-write 1 dataL) + ## (..creation_and_deletion 0) + ## (..read_and_write 1 dataL) ## (wrap (do promise.monad ## [#let [path "temp_file_2"] ## result (promise.future ## (do (try.with io.monad) - ## [file (!.use (\ /.default create-file) path) - ## _ (!.use (\ file over-write) dataL) - ## read-size (!.use (\ file size) []) + ## [file (!.use (\ /.default create_file) path) + ## _ (!.use (\ file over_write) dataL) + ## read_size (!.use (\ file size) []) ## _ (!.use (\ file delete) [])] - ## (wrap (n.= file-size read-size))))] + ## (wrap (n.= file_size read_size))))] ## (_.assert "Can read file size." ## (try.default #0 result)))) ## (wrap (do promise.monad ## [#let [path "temp_file_3"] ## result (promise.future ## (do (try.with io.monad) - ## [file (!.use (\ /.default create-file) path) - ## _ (!.use (\ file over-write) dataL) + ## [file (!.use (\ /.default create_file) path) + ## _ (!.use (\ file over_write) dataL) ## _ (!.use (\ file append) dataR) ## content (!.use (\ file content) []) - ## read-size (!.use (\ file size) []) + ## read_size (!.use (\ file size) []) ## _ (!.use (\ file delete) [])] - ## (wrap (and (n.= (n.* 2 file-size) read-size) + ## (wrap (and (n.= (n.* 2 file_size) read_size) ## (\ binary.equivalence = ## dataL - ## (try.assume (binary.slice 0 (dec file-size) content))) + ## (try.assume (binary.slice 0 (dec file_size) content))) ## (\ binary.equivalence = ## dataR - ## (try.assume (binary.slice file-size (dec read-size) content)))))))] + ## (try.assume (binary.slice file_size (dec read_size) content)))))))] ## (_.assert "Can append to files." ## (try.default #0 result)))) ## (wrap (do promise.monad ## [#let [path "temp_dir_4"] ## result (promise.future ## (do (try.with io.monad) - ## [#let [check-existence! (: (IO (Try Bit)) + ## [#let [check_existence! (: (IO (Try Bit)) ## (try.lift io.monad (/.exists? io.monad /.default path)))] - ## pre! check-existence! - ## dir (!.use (\ /.default create-directory) path) - ## post! check-existence! + ## pre! check_existence! + ## dir (!.use (\ /.default create_directory) path) + ## post! check_existence! ## _ (!.use (\ dir discard) []) - ## remains? check-existence!] + ## remains? check_existence!] ## (wrap (and (not pre!) ## post! ## (not remains?)))))] ## (_.assert "Can create/delete directories." ## (try.default #0 result)))) ## (wrap (do promise.monad - ## [#let [file-path "temp_file_5" - ## dir-path "temp_dir_5"] + ## [#let [file_path "temp_file_5" + ## dir_path "temp_dir_5"] ## result (promise.future ## (do (try.with io.monad) - ## [dir (!.use (\ /.default create-directory) dir-path) - ## file (!.use (\ /.default create-file) (format dir-path "/" file-path)) - ## _ (!.use (\ file over-write) dataL) - ## read-size (!.use (\ file size) []) + ## [dir (!.use (\ /.default create_directory) dir_path) + ## file (!.use (\ /.default create_file) (format dir_path "/" file_path)) + ## _ (!.use (\ file over_write) dataL) + ## read_size (!.use (\ file size) []) ## _ (!.use (\ file delete) []) ## _ (!.use (\ dir discard) [])] - ## (wrap (n.= file-size read-size))))] + ## (wrap (n.= file_size read_size))))] ## (_.assert "Can create files inside of directories." ## (try.default #0 result)))) ## (wrap (do promise.monad - ## [#let [file-path "temp_file_6" - ## dir-path "temp_dir_6" - ## inner-dir-path "inner_temp_dir_6"] + ## [#let [file_path "temp_file_6" + ## dir_path "temp_dir_6" + ## inner_dir_path "inner_temp_dir_6"] ## result (promise.future ## (do (try.with io.monad) - ## [dir (!.use (\ /.default create-directory) dir-path) - ## pre-files (!.use (\ dir files) []) - ## pre-directories (!.use (\ dir directories) []) + ## [dir (!.use (\ /.default create_directory) dir_path) + ## pre_files (!.use (\ dir files) []) + ## pre_directories (!.use (\ dir directories) []) - ## file (!.use (\ /.default create-file) (format dir-path "/" file-path)) - ## inner-dir (!.use (\ /.default create-directory) (format dir-path "/" inner-dir-path)) - ## post-files (!.use (\ dir files) []) - ## post-directories (!.use (\ dir directories) []) + ## file (!.use (\ /.default create_file) (format dir_path "/" file_path)) + ## inner_dir (!.use (\ /.default create_directory) (format dir_path "/" inner_dir_path)) + ## post_files (!.use (\ dir files) []) + ## post_directories (!.use (\ dir directories) []) ## _ (!.use (\ file delete) []) - ## _ (!.use (\ inner-dir discard) []) + ## _ (!.use (\ inner_dir discard) []) ## _ (!.use (\ dir discard) [])] - ## (wrap (and (and (n.= 0 (list.size pre-files)) - ## (n.= 0 (list.size pre-directories))) - ## (and (n.= 1 (list.size post-files)) - ## (n.= 1 (list.size post-directories)))))))] + ## (wrap (and (and (n.= 0 (list.size pre_files)) + ## (n.= 0 (list.size pre_directories))) + ## (and (n.= 1 (list.size post_files)) + ## (n.= 1 (list.size post_directories)))))))] ## (_.assert "Can list files/directories inside a directory." ## (try.default #0 result)))) ## (wrap (do promise.monad ## [#let [path "temp_file_7"] ## result (promise.future ## (do (try.with io.monad) - ## [file (!.use (\ /.default create-file) path) - ## _ (!.use (\ file over-write) dataL) - ## _ (!.use (\ file modify) new-modified) - ## current-modified (!.use (\ file last-modified) []) + ## [file (!.use (\ /.default create_file) path) + ## _ (!.use (\ file over_write) dataL) + ## _ (!.use (\ file modify) new_modified) + ## current_modified (!.use (\ file last_modified) []) ## _ (!.use (\ file delete) [])] - ## (wrap (\ instant.equivalence = new-modified current-modified))))] + ## (wrap (\ instant.equivalence = new_modified current_modified))))] ## (_.assert "Can change the time of last modification." ## (try.default #0 result)))) ## (wrap (do promise.monad @@ -184,16 +184,16 @@ ## path1 (format "temp_file_8+1")] ## result (promise.future ## (do (try.with io.monad) - ## [#let [check-existence! (: (-> Path (IO (Try Bit))) + ## [#let [check_existence! (: (_> Path (IO (Try Bit))) ## (|>> (/.exists? io.monad /.default) ## (try.lift io.monad)))] - ## file0 (!.use (\ /.default create-file) path0) - ## _ (!.use (\ file0 over-write) dataL) - ## pre! (check-existence! path0) + ## file0 (!.use (\ /.default create_file) path0) + ## _ (!.use (\ file0 over_write) dataL) + ## pre! (check_existence! path0) ## file1 (: (IO (Try (File IO))) ## TODO: Remove : ## (!.use (\ file0 move) path1)) - ## post! (check-existence! path0) - ## confirmed? (check-existence! path1) + ## post! (check_existence! path0) + ## confirmed? (check_existence! path1) ## _ (!.use (\ file1 delete) [])] ## (wrap (and pre! ## (not post!) diff --git a/stdlib/source/test/lux/world/file/watch.lux b/stdlib/source/test/lux/world/file/watch.lux index aa3a51e59..c0873b41a 100644 --- a/stdlib/source/test/lux/world/file/watch.lux +++ b/stdlib/source/test/lux/world/file/watch.lux @@ -74,16 +74,16 @@ (wrap (do promise.monad [?concern (\ watcher concern directory) ?stop (\ watcher stop directory)] - (_.cover' [/.not-being-watched] + (_.cover' [/.not_being_watched] (and (case ?concern (#try.Failure error) - (exception.match? /.not-being-watched error) + (exception.match? /.not_being_watched error) (#try.Success _) false) (case ?stop (#try.Failure error) - (exception.match? /.not-being-watched error) + (exception.match? /.not_being_watched error) (#try.Success _) false))))) @@ -101,23 +101,23 @@ [directory (random.ascii/alpha 5) #let [/ "/" [fs watcher] (/.mock /)] - expected-path (\ ! map (|>> (format directory /)) + expected_path (\ ! map (|>> (format directory /)) (random.ascii/alpha 5)) data (_binary.random 10)] (wrap (do {! promise.monad} [verdict (do (try.with !) - [_ (!.use (\ fs create-directory) [directory]) + [_ (!.use (\ fs create_directory) [directory]) _ (\ watcher start /.all directory) poll/0 (\ watcher poll []) - #let [no-events-prior-to-creation! + #let [no_events_prior_to_creation! (list.empty? poll/0)] - file (!.use (\ fs create-file) [expected-path]) + file (!.use (\ fs create_file) [expected_path]) poll/1 (\ watcher poll []) poll/1' (\ watcher poll []) - #let [after-creation! + #let [after_creation! (and (case poll/1 - (^ (list [actual-path concern])) - (and (text\= expected-path actual-path) + (^ (list [actual_path concern])) + (and (text\= expected_path actual_path) (and (/.creation? concern) (not (/.modification? concern)) (not (/.deletion? concern)))) @@ -125,14 +125,14 @@ _ false) (list.empty? poll/1'))] - _ (promise.delay 1 (#try.Success "Delay to make sure the over-write time-stamp always changes.")) - _ (!.use (\ file over-write) data) + _ (promise.delay 1 (#try.Success "Delay to make sure the over_write time-stamp always changes.")) + _ (!.use (\ file over_write) data) poll/2 (\ watcher poll []) poll/2' (\ watcher poll []) - #let [after-modification! + #let [after_modification! (and (case poll/2 - (^ (list [actual-path concern])) - (and (text\= expected-path actual-path) + (^ (list [actual_path concern])) + (and (text\= expected_path actual_path) (and (not (/.creation? concern)) (/.modification? concern) (not (/.deletion? concern)))) @@ -143,9 +143,9 @@ _ (!.use (\ file delete) []) poll/3 (\ watcher poll []) poll/3' (\ watcher poll []) - #let [after-deletion! + #let [after_deletion! (and (case poll/3 - (^ (list [actual-path concern])) + (^ (list [actual_path concern])) (and (not (/.creation? concern)) (not (/.modification? concern)) (/.deletion? concern)) @@ -153,10 +153,10 @@ _ false) (list.empty? poll/3'))]] - (wrap (and no-events-prior-to-creation! - after-creation! - after-modification! - after-deletion!)))] + (wrap (and no_events_prior_to_creation! + after_creation! + after_modification! + after_deletion!)))] (_.cover' [/.mock /.polling] (try.default false verdict))))) ))) diff --git a/stdlib/source/test/lux/world/shell.lux b/stdlib/source/test/lux/world/shell.lux index d3c7e24f8..1dbe5dcd5 100644 --- a/stdlib/source/test/lux/world/shell.lux +++ b/stdlib/source/test/lux/world/shell.lux @@ -32,65 +32,65 @@ (exception: dead) -(def: (simulation [environment working-directory command arguments]) +(def: (simulation [environment working_directory command arguments]) (-> [Environment Path /.Command (List /.Argument)] (/.Simulation Bit)) (structure - (def: (on-read dead?) + (def: (on_read dead?) (if dead? (exception.throw ..dead []) (do try.monad - [to-echo (try.from-maybe (list.head arguments))] - (wrap [dead? to-echo])))) + [to_echo (try.from_maybe (list.head arguments))] + (wrap [dead? to_echo])))) - (def: (on-error dead?) + (def: (on_error dead?) (if dead? (exception.throw ..dead []) (exception.return [dead? ""]))) - (def: (on-write message dead?) + (def: (on_write message dead?) (if dead? (exception.throw ..dead []) (#try.Success dead?))) - (def: (on-destroy dead?) + (def: (on_destroy dead?) (if dead? (exception.throw ..dead []) (#try.Success true))) - (def: (on-await dead?) + (def: (on_await dead?) (if dead? (exception.throw ..dead []) (#try.Success [true /.normal]))))) -(def: (io-shell command oops input destruction exit) +(def: (io_shell command oops input destruction exit) (-> /.Command Text Text Text /.Exit (/.Shell IO)) (structure (def: execute - ((debug.private /.can-execute) - (function (_ [environment working-directory command arguments]) + ((debug.private /.can_execute) + (function (_ [environment working_directory command arguments]) (io.io (#try.Success (: (/.Process IO) (structure (def: read - ((debug.private /.can-read) + ((debug.private /.can_read) (function (_ _) (io.io (#try.Success command))))) (def: error - ((debug.private /.can-read) + ((debug.private /.can_read) (function (_ _) (io.io (#try.Success oops))))) (def: write - ((debug.private /.can-write) + ((debug.private /.can_write) (function (_ message) (io.io (#try.Failure message))))) (def: destroy - ((debug.private /.can-destroy) + ((debug.private /.can_destroy) (function (_ _) (io.io (#try.Failure destruction))))) (def: await - ((debug.private /.can-wait) + ((debug.private /.can_wait) (function (_ _) (io.io (#try.Success exit)))))))))))))) @@ -109,7 +109,7 @@ input (random.ascii/alpha 5) destruction (random.ascii/alpha 5) exit random.int - #let [shell (/.async (..io-shell command oops input destruction exit))]] + #let [shell (/.async (..io_shell command oops input destruction exit))]] (wrap (do {! promise.monad} [verdict (do (try.with !) [process (!.use (\ shell execute) [environment.empty "~" command (list)]) @@ -137,6 +137,6 @@ wrote! destroyed! (i.= exit await))))] - (_.cover' [/.async /.Can-Write] + (_.cover' [/.async /.Can_Write] (try.default false verdict))))) ))) |