aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/extension.lux125
-rw-r--r--stdlib/source/test/lux/tool.lux4
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/archive/descriptor.lux56
-rw-r--r--stdlib/source/test/lux/type/check.lux106
4 files changed, 194 insertions, 97 deletions
diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux
index a48460778..5537bc855 100644
--- a/stdlib/source/test/lux/extension.lux
+++ b/stdlib/source/test/lux/extension.lux
@@ -1,64 +1,66 @@
-(.using
- [library
- [lux "*"
- ["[0]" debug]
- ["@" target
- ["[0]" js]
- ["[0]" python]
- ["[0]" lua]
- ["[0]" ruby]
- ["[0]" php]
- ["[0]" scheme]
- ["[0]" jvm
- ["[0]" class]
- ["[0]" version]
- [encoding
- ["[0]" name]]]]
- [abstract
- ["[0]" monad {"+" do}]]
- [control
- ["[0]" try ("[1]#[0]" functor)]
- ["<>" parser
- ["<[0]>" code]
- ["<[0]>" analysis]
- ["<[0]>" synthesis]]]
- [data
- ["[0]" binary]
- ["[0]" product]
- ["[0]" text ("[1]#[0]" equivalence)
- ["%" format {"+" format}]]
- [collection
- ["[0]" sequence]
- ["[0]" list ("[1]#[0]" functor)]]
- [format
- ["[0]F" binary]]]
- [macro
- ["[0]" template]]
- [math
- ["[0]" random]
- [number
- ["n" nat]]]
- [tool
- [compiler
- ["[0]" phase]
- [meta
- [archive
- ["[0]" artifact]]]
- [language
- [lux
- ["[0]" analysis]
- ["[0]" synthesis]
- ["[0]" generation]
- ["[0]" directive]
- [phase
- [analysis
- ["[0]" type]]
- [generation
- ["[0]" jvm "_"
- ["[1]/[0]" runtime]]]]]]]]
- ["_" test {"+" Test}]]]
- [\\library
- ["[0]" / {"+" analysis: synthesis: generation: directive:}]])
+(.`` (.`` (.using
+ [library
+ [lux "*"
+ ["[0]" debug]
+ ["@" target
+ ["[0]" js]
+ ["[0]" python]
+ ["[0]" lua]
+ ["[0]" ruby]
+ ["[0]" php]
+ ["[0]" scheme]
+ ["[0]" jvm
+ (~~ (.for ["JVM" (~~ (.as_is ["[0]" class]
+ ["[0]" version]
+ [encoding
+ ["[0]" name]]))]
+ (~~ (.as_is))))]]
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [control
+ ["[0]" try ("[1]#[0]" functor)]
+ ["<>" parser
+ ["<[0]>" code]
+ ["<[0]>" analysis]
+ ["<[0]>" synthesis]]]
+ [data
+ ["[0]" binary]
+ ["[0]" product]
+ ["[0]" text ("[1]#[0]" equivalence)
+ ["%" format {"+" format}]]
+ [collection
+ ["[0]" sequence]
+ ["[0]" list ("[1]#[0]" functor)]]
+ [format
+ ["[0]F" binary]]]
+ [macro
+ ["[0]" template]]
+ [math
+ ["[0]" random]
+ [number
+ ["n" nat]]]
+ [tool
+ [compiler
+ ["[0]" phase]
+ [meta
+ [archive
+ ["[0]" artifact]]]
+ [language
+ [lux
+ ["[0]" analysis]
+ ["[0]" synthesis]
+ ["[0]" generation]
+ ["[0]" directive]
+ [phase
+ [analysis
+ ["[0]" type]]
+ [generation
+ (~~ (.for ["JVM" (~~ (.as_is ["[0]" jvm "_"
+ ["[1]/[0]" runtime]]))]
+ (~~ (.as_is))))]]]]]]
+ ["_" test {"+" Test}]]]
+ [\\library
+ ["[0]" / {"+" analysis: synthesis: generation: directive:}]])))
(def: dummy_generation "dummy generation")
@@ -163,6 +165,7 @@
(try#each (binaryF.result class.writer))
(class.class version.v6_0 class.public
(name.internal $class)
+ {.#None}
(name.internal "java.lang.Object")
(list)
(list)
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
index 219151d6c..25f869808 100644
--- a/stdlib/source/test/lux/tool.lux
+++ b/stdlib/source/test/lux/tool.lux
@@ -24,7 +24,8 @@
["[1]/[0]" signature]
["[1]/[0]" key]
["[1]/[0]" document]
- ["[1]/[0]" registry]]]
+ ["[1]/[0]" registry]
+ ["[1]/[0]" descriptor]]]
]])
(def: .public test
@@ -40,6 +41,7 @@
/meta/archive/key.test
/meta/archive/document.test
/meta/archive/registry.test
+ /meta/archive/descriptor.test
/phase/extension.test
/phase/analysis/simple.test
... /syntax.test
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/descriptor.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/descriptor.lux
new file mode 100644
index 000000000..d9d0e09a2
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/meta/archive/descriptor.lux
@@ -0,0 +1,56 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]
+ [\\specification
+ ["$[0]" equivalence]]]
+ [control
+ ["[0]" try ("[1]#[0]" functor)]
+ [parser
+ ["<[0]>" binary]]]
+ [data
+ ["[0]" text]
+ [format
+ ["[0]" binary]]]
+ [math
+ ["[0]" random {"+" Random} ("[1]#[0]" monad)]]]]
+ [\\library
+ ["[0]" /]])
+
+(def: random_module_state
+ (Random Module_State)
+ ($_ random.or
+ (random#in [])
+ (random#in [])
+ (random#in [])
+ ))
+
+(def: .public (random imports)
+ (-> Nat (Random /.Descriptor))
+ ($_ random.and
+ (random.ascii/lower 1)
+ (random.ascii/lower 1)
+ random.nat
+ ..random_module_state
+ (random.set text.hash imports (random.ascii/lower 2))
+ ))
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Descriptor /.Module])
+ (do random.monad
+ [expected (..random 5)])
+ ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence (..random 1)))
+
+ (_.cover [/.writer /.parser]
+ (|> expected
+ (binary.result /.writer)
+ (<binary>.result /.parser)
+ (try#each (|>> (# /.equivalence = (with@ /.#state {.#Cached} expected))))
+ (try.else false)))
+ )))
diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux
index 843dd01e4..9d38c6f6d 100644
--- a/stdlib/source/test/lux/type/check.lux
+++ b/stdlib/source/test/lux/type/check.lux
@@ -114,37 +114,84 @@
($monad.spec ..injection ..comparison /.monad))
))
+(def: (primitive_type parameters)
+ (-> Nat (Random Type))
+ (do random.monad
+ [primitive (random.ascii/upper 3)
+ parameters (random.list parameters (primitive_type (-- parameters)))]
+ (in {.#Primitive primitive parameters})))
+
+(def: clean_type
+ (Random Type)
+ (primitive_type 2))
+
(exception: yolo)
(def: error_handling
Test
- ($_ _.and
- (do random.monad
- [expected (random.ascii/upper 10)]
- (_.cover [/.failure]
+ (do random.monad
+ [left ..clean_type
+ right ..clean_type
+ ex random.nat]
+ ($_ _.and
+ (do random.monad
+ [expected (random.ascii/upper 10)]
+ (_.cover [/.failure]
+ (case (/.result /.fresh_context
+ (: (/.Check Any)
+ (/.failure expected)))
+ {try.#Success _} false
+ {try.#Failure actual} (same? expected actual))))
+ (do random.monad
+ [expected (random.ascii/upper 10)]
+ (_.cover [/.assertion]
+ (and (case (/.result /.fresh_context
+ (: (/.Check Any)
+ (/.assertion expected true)))
+ {try.#Success _} true
+ {try.#Failure actual} false)
+ (case (/.result /.fresh_context (/.assertion expected false))
+ {try.#Success _} false
+ {try.#Failure actual} (same? expected actual)))))
+ (_.cover [/.except]
(case (/.result /.fresh_context
(: (/.Check Any)
- (/.failure expected)))
+ (/.except ..yolo [])))
{try.#Success _} false
- {try.#Failure actual} (same? expected actual))))
- (do random.monad
- [expected (random.ascii/upper 10)]
- (_.cover [/.assertion]
- (and (case (/.result /.fresh_context
- (: (/.Check Any)
- (/.assertion expected true)))
- {try.#Success _} true
- {try.#Failure actual} false)
- (case (/.result /.fresh_context (/.assertion expected false))
- {try.#Success _} false
- {try.#Failure actual} (same? expected actual)))))
- (_.cover [/.except]
- (case (/.result /.fresh_context
- (: (/.Check Any)
- (/.except ..yolo [])))
- {try.#Success _} false
- {try.#Failure error} (exception.match? ..yolo error)))
- ))
+ {try.#Failure error} (exception.match? ..yolo error)))
+ (let [scenario (: (-> (-> Text Bit) Type Type Bit)
+ (function (_ ? <left> <right>)
+ (and (|> (/.check <left> <right>)
+ (: (/.Check Any))
+ (/.result /.fresh_context)
+ (case> {try.#Failure error} (? error)
+ {try.#Success _} false))
+ (|> (/.check <right> <left>)
+ (: (/.Check Any))
+ (/.result /.fresh_context)
+ (case> {try.#Failure error} (? error)
+ {try.#Success _} false)))))]
+ ($_ _.and
+ (_.cover [/.type_check_failed]
+ (let [scenario (scenario (exception.match? /.type_check_failed))]
+ (and (scenario (Tuple left right) left)
+ (scenario (Tuple left right) (Or left right))
+ (scenario (Tuple left right) (-> left right))
+ (scenario (Tuple left right) {.#Ex ex})
+
+ (scenario (Or left right) left)
+ (scenario (Or left right) (-> left right))
+ (scenario (Or left right) {.#Ex ex})
+
+ (scenario (-> left right) left)
+ (scenario (-> left right) {.#Ex ex})
+
+ (scenario {.#Ex ex} left)
+ )))
+ (_.cover [/.invalid_type_application]
+ (let [scenario (scenario (text.contains? (value@ exception.#label /.invalid_type_application)))]
+ (scenario {.#Apply left right} left)))))
+ )))
(def: var
Test
@@ -700,17 +747,6 @@
(try.else false))
))))
-(def: (primitive_type parameters)
- (-> Nat (Random Type))
- (do random.monad
- [primitive (random.ascii/upper 3)
- parameters (random.list parameters (primitive_type (-- parameters)))]
- (in {.#Primitive primitive parameters})))
-
-(def: clean_type
- (Random Type)
- (primitive_type 2))
-
(def: for_subsumption|ultimate
(Random Bit)
(do random.monad