aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world
diff options
context:
space:
mode:
authorEduardo Julián2021-07-14 14:44:53 -0400
committerGitHub2021-07-14 14:44:53 -0400
commit89ca40f2f101b2b38187eab5cf905371cd47eb57 (patch)
treef05fd1677a70988c6b39c07e52d031d86eff28f1 /stdlib/source/test/lux/world
parent2431e767a09894c2f685911ba7f1ba0b7de2a165 (diff)
parent8252bdb938a0284dd12e7365b4eb84b5357bacac (diff)
Merge pull request #58 from LuxLang/hierarchy_normalization
Hierarchy normalization
Diffstat (limited to 'stdlib/source/test/lux/world')
-rw-r--r--stdlib/source/test/lux/world/console.lux29
-rw-r--r--stdlib/source/test/lux/world/file.lux19
-rw-r--r--stdlib/source/test/lux/world/file/watch.lux39
-rw-r--r--stdlib/source/test/lux/world/input/keyboard.lux35
-rw-r--r--stdlib/source/test/lux/world/net/http/client.lux55
-rw-r--r--stdlib/source/test/lux/world/net/http/status.lux25
-rw-r--r--stdlib/source/test/lux/world/output/video/resolution.lux35
-rw-r--r--stdlib/source/test/lux/world/program.lux74
-rw-r--r--stdlib/source/test/lux/world/shell.lux45
9 files changed, 206 insertions, 150 deletions
diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux
index b153e84e9..055ee1466 100644
--- a/stdlib/source/test/lux/world/console.lux
+++ b/stdlib/source/test/lux/world/console.lux
@@ -1,18 +1,19 @@
(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]]
- [control
- ["." io]
- ["." try (#+ Try)]
- ["." exception (#+ exception:)]]
- [data
- ["." text ("#\." equivalence)
- ["%" format (#+ format)]]]
- [math
- ["." random]]]
- [\\
+ [library
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]]
+ [control
+ ["." io]
+ ["." try (#+ Try)]
+ ["." exception (#+ exception:)]]
+ [data
+ ["." text ("#\." equivalence)
+ ["%" format (#+ format)]]]
+ [math
+ ["." random]]]]
+ [\\library
["." /]]
[\\spec
["$." /]])
diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux
index 0e5c61c8f..1074749f4 100644
--- a/stdlib/source/test/lux/world/file.lux
+++ b/stdlib/source/test/lux/world/file.lux
@@ -1,15 +1,16 @@
(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]]
- [control
- ["." io]]
- [math
- ["." random]]]
+ [library
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]]
+ [control
+ ["." io]]
+ [math
+ ["." random]]]]
["." / #_
["#." watch]]
- [\\
+ [\\library
["." /]]
[\\spec
["$." /]])
diff --git a/stdlib/source/test/lux/world/file/watch.lux b/stdlib/source/test/lux/world/file/watch.lux
index 9b9937a25..a4a8748ed 100644
--- a/stdlib/source/test/lux/world/file/watch.lux
+++ b/stdlib/source/test/lux/world/file/watch.lux
@@ -1,23 +1,24 @@
(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [predicate (#+ Predicate)]
- [monad (#+ do)]]
- [control
- ["." try (#+ Try)]
- ["." exception]
- [concurrency
- ["." promise (#+ Promise)]]]
- [data
- ["." binary (#+ Binary) ("#\." equivalence)]
- ["." text ("#\." equivalence)
- ["%" format (#+ format)]]
- [collection
- ["." list]]]
- [math
- ["." random (#+ Random) ("#\." monad)]]]
- [\\
+ [library
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [predicate (#+ Predicate)]
+ [monad (#+ do)]]
+ [control
+ ["." try (#+ Try)]
+ ["." exception]
+ [concurrency
+ ["." promise (#+ Promise)]]]
+ [data
+ ["." binary (#+ Binary) ("#\." equivalence)]
+ ["." text ("#\." equivalence)
+ ["%" format (#+ format)]]
+ [collection
+ ["." list]]]
+ [math
+ ["." random (#+ Random) ("#\." monad)]]]]
+ [\\library
["." /
["/#" //]]]
[////
diff --git a/stdlib/source/test/lux/world/input/keyboard.lux b/stdlib/source/test/lux/world/input/keyboard.lux
index b58bff96f..f75907fad 100644
--- a/stdlib/source/test/lux/world/input/keyboard.lux
+++ b/stdlib/source/test/lux/world/input/keyboard.lux
@@ -1,21 +1,22 @@
(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]]
- [data
- ["." bit ("#\." equivalence)]
- ["." maybe]
- [collection
- ["." list]
- ["." set (#+ Set)]]]
- [macro
- ["." template]]
- [math
- ["." random (#+ Random)]
- [number
- ["n" nat]]]]
- [\\
+ [library
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]]
+ [data
+ ["." bit ("#\." equivalence)]
+ ["." maybe]
+ [collection
+ ["." list]
+ ["." set (#+ Set)]]]
+ [macro
+ ["." template]]
+ [math
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]]
+ [\\library
["." /]])
(with_expansions [<groups> (as_is [keys/commands
diff --git a/stdlib/source/test/lux/world/net/http/client.lux b/stdlib/source/test/lux/world/net/http/client.lux
index 612d599ff..c784d9cbe 100644
--- a/stdlib/source/test/lux/world/net/http/client.lux
+++ b/stdlib/source/test/lux/world/net/http/client.lux
@@ -1,25 +1,28 @@
(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]]
- [control
- [pipe (#+ do>)]
- ["." io (#+ IO)]
- ["." try]
- ["." function]]
- [data
- ["." binary]
- ["." product]
- [text
- ["%" format (#+ format)]
- [encoding
- ["." utf8]]]]
- [math
- ["." random (#+ Random)]
- [number
- ["." nat]]]]
- [\\
+ [library
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]]
+ [control
+ [pipe (#+ do>)]
+ ["." io (#+ IO)]
+ ["." try]
+ ["." function]]
+ [data
+ ["." binary]
+ ["." product]
+ ["." text
+ ["%" format (#+ format)]
+ [encoding
+ ["." utf8]]]
+ [collection
+ ["." dictionary]]]
+ [math
+ ["." random (#+ Random)]
+ [number
+ ["." nat]]]]]
+ [\\library
["." /
["/#" //
["#." status]]]])
@@ -28,7 +31,7 @@
Test
(<| (_.covering /._)
(_.for [/.Client])
- (do random.monad
+ (do {! random.monad}
[on_post random.nat
on_get random.nat
on_put random.nat
@@ -38,6 +41,8 @@
on_connect random.nat
on_options random.nat
on_trace random.nat
+ num_headers (\ ! map (nat.% 10) random.nat)
+ headers (random.dictionary text.hash num_headers (random.ascii/lower 3) (random.ascii/lower 3))
#let [mock (: (/.Client IO)
(implementation
(def: (request method url headers data)
@@ -81,4 +86,10 @@
[/.options on_options]
[/.trace on_trace]
))
+ (_.cover [/.headers]
+ (nat.= (dictionary.size headers)
+ (|> headers
+ dictionary.entries
+ /.headers
+ dictionary.size)))
)))))
diff --git a/stdlib/source/test/lux/world/net/http/status.lux b/stdlib/source/test/lux/world/net/http/status.lux
index 84fbf4b2c..b051d8e8e 100644
--- a/stdlib/source/test/lux/world/net/http/status.lux
+++ b/stdlib/source/test/lux/world/net/http/status.lux
@@ -1,16 +1,17 @@
(.module:
- [lux #*
- ["_" test (#+ Test)]
- [data
- [collection
- ["." list]
- ["." set (#+ Set)]]]
- [macro
- ["." template]]
- [math
- [number
- ["n" nat]]]]
- [\\
+ [library
+ [lux #*
+ ["_" test (#+ Test)]
+ [data
+ [collection
+ ["." list]
+ ["." set (#+ Set)]]]
+ [macro
+ ["." template]]
+ [math
+ [number
+ ["n" nat]]]]]
+ [\\library
["." /
["/#" //]]])
diff --git a/stdlib/source/test/lux/world/output/video/resolution.lux b/stdlib/source/test/lux/world/output/video/resolution.lux
index ebeec3a65..1cfcd0ae8 100644
--- a/stdlib/source/test/lux/world/output/video/resolution.lux
+++ b/stdlib/source/test/lux/world/output/video/resolution.lux
@@ -1,21 +1,22 @@
(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]
- [\spec
- ["$." equivalence]
- ["$." hash]]]
- [data
- ["." maybe]
- [collection
- ["." list]
- ["." set (#+ Set)]]]
- [math
- ["." random (#+ Random)]
- [number
- ["n" nat]]]]
- [\\
+ [library
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]
+ [\\spec
+ ["$." equivalence]
+ ["$." hash]]]
+ [data
+ ["." maybe]
+ [collection
+ ["." list]
+ ["." set (#+ Set)]]]
+ [math
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]]
+ [\\library
["." /]])
(with_expansions [<resolutions> (as_is /.svga
diff --git a/stdlib/source/test/lux/world/program.lux b/stdlib/source/test/lux/world/program.lux
index d91d7fc62..fafda5f91 100644
--- a/stdlib/source/test/lux/world/program.lux
+++ b/stdlib/source/test/lux/world/program.lux
@@ -1,25 +1,36 @@
(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]]
- [control
- [parser
- [environment (#+ Environment)]]]
- [data
- ["." text]]
- [math
- ["." random (#+ Random)]]]
- [\\
+ [library
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]]
+ [control
+ [pipe (#+ case>)]
+ ["." io]
+ ["." try]
+ ["." exception]
+ [parser
+ [environment (#+ Environment)]]]
+ [data
+ ["." maybe ("#\." functor)]
+ ["." text ("#\." equivalence)]
+ [collection
+ ["." dictionary]
+ ["." list]]]
+ [math
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]]
+ [\\library
["." /
[//
[file (#+ Path)]]]]
[\\spec
["$." /]])
-(def: environment
- (Random Environment)
- (random.dictionary text.hash 5
+(def: (environment env_size)
+ (-> Nat (Random Environment))
+ (random.dictionary text.hash env_size
(random.ascii/alpha 5)
(random.ascii/alpha 5)))
@@ -30,11 +41,38 @@
(def: #export test
Test
(<| (_.covering /._)
- (do random.monad
- [environment ..environment
+ (do {! random.monad}
+ [env_size (\ ! map (|>> (n.% 10) inc) random.nat)
+ environment (..environment env_size)
home ..path
- directory ..path]
+ directory ..path
+
+ unknown (random.ascii/alpha 1)]
($_ _.and
(_.for [/.mock /.async]
($/.spec (/.async (/.mock environment home directory))))
+ (_.cover [/.environment]
+ (let [program (/.mock environment home directory)]
+ (io.run
+ (do io.monad
+ [actual (/.environment io.monad program)]
+ (wrap (and (n.= (dictionary.size environment)
+ (dictionary.size actual))
+ (|> actual
+ dictionary.entries
+ (list.every? (function (_ [key value])
+ (|> environment
+ (dictionary.get key)
+ (maybe\map (text\= value))
+ (maybe.default false)))))))))))
+ (_.cover [/.unknown_environment_variable]
+ (let [program (/.mock environment home directory)]
+ (|> unknown
+ (\ program variable)
+ io.run
+ (case> (#try.Success _)
+ false
+
+ (#try.Failure error)
+ (exception.match? /.unknown_environment_variable error)))))
))))
diff --git a/stdlib/source/test/lux/world/shell.lux b/stdlib/source/test/lux/world/shell.lux
index 4cbdb27ed..8d117eefa 100644
--- a/stdlib/source/test/lux/world/shell.lux
+++ b/stdlib/source/test/lux/world/shell.lux
@@ -1,26 +1,27 @@
(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]]
- [control
- ["." try (#+ Try)]
- ["." exception (#+ exception:)]
- ["." io (#+ IO)]
- [concurrency
- ["." promise (#+ Promise)]]
- [parser
- ["." environment (#+ Environment)]]]
- [data
- ["." text ("#\." equivalence)]
- [collection
- ["." list]]]
- [math
- ["." random]
- [number
- ["n" nat]
- ["i" int]]]]
- [\\
+ [library
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]]
+ [control
+ ["." try (#+ Try)]
+ ["." exception (#+ exception:)]
+ ["." io (#+ IO)]
+ [concurrency
+ ["." promise (#+ Promise)]]
+ [parser
+ ["." environment (#+ Environment)]]]
+ [data
+ ["." text ("#\." equivalence)]
+ [collection
+ ["." list]]]
+ [math
+ ["." random]
+ [number
+ ["n" nat]
+ ["i" int]]]]]
+ [\\library
["." /
[//
[file (#+ Path)]]]]