diff options
Diffstat (limited to 'stdlib/source/library')
-rw-r--r-- | stdlib/source/library/lux.lux | 62 | ||||
-rw-r--r-- | stdlib/source/library/lux/meta/macro/expansion.lux | 8 | ||||
-rw-r--r-- | stdlib/source/library/lux/test/unit.lux | 37 |
3 files changed, 79 insertions, 28 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 84f0ddf14..df7b4ef66 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -4298,6 +4298,56 @@ bound (type_variable idx bindings')))) +(def (clean_type variables it) + (-> (List [Nat (Maybe Type)]) Type Type) + (when it + {#Primitive name parameters} + {#Primitive name (list#each (clean_type variables) parameters)} + + {#Sum left right} + {#Sum (clean_type variables left) + (clean_type variables right)} + + {#Product left right} + {#Product (clean_type variables left) + (clean_type variables right)} + + {#Function left right} + {#Function (clean_type variables left) + (clean_type variables right)} + + {#Apply left right} + {#Apply (clean_type variables left) + (clean_type variables right)} + + {#UnivQ environment unquantified} + {#UnivQ (list#each (clean_type variables) environment) + (clean_type variables unquantified)} + + {#ExQ environment unquantified} + {#ExQ (list#each (clean_type variables) environment) + (clean_type variables unquantified)} + + {#Named name anonymous} + it + + {#Parameter _} + it + + {#Ex _} + it + + {#Var id} + (when (type_variable id variables) + {#None} + it + + {#Some {#Var _}} + it + + {#Some it} + (clean_type variables it)))) + (def (type_definition full_name) (-> Symbol (Meta Type)) (do meta#monad @@ -4324,22 +4374,16 @@ _ {#Left (all text#composite "Unknown var: " (symbol#encoded full_name))})))] (when temp - {#Right [compiler {#Var type_id}]} + {#Right [compiler temp]} (let [[..#info _ ..#source _ ..#current_module _ ..#modules _ ..#scopes _ ..#type_context type_context ..#host _ ..#seed _ ..#expected _ ..#location _ ..#extensions extensions ..#scope_type_vars _ ..#eval _eval] compiler [..#ex_counter _ ..#var_counter _ ..#var_bindings var_bindings] type_context] - (when (type_variable type_id var_bindings) - {#None} - temp - - {#Some actualT} - {#Right [compiler actualT]})) + {#Right [compiler (clean_type var_bindings temp)]}) _ - temp)) - ))) + temp))))) (def (list#all choice items) (All (_ a b) (-> (-> a (Maybe b)) (List a) (List b))) diff --git a/stdlib/source/library/lux/meta/macro/expansion.lux b/stdlib/source/library/lux/meta/macro/expansion.lux index 9364ecc77..62c4e6905 100644 --- a/stdlib/source/library/lux/meta/macro/expansion.lux +++ b/stdlib/source/library/lux/meta/macro/expansion.lux @@ -104,10 +104,10 @@ (with_template [<macro> <func>] [(def .public <macro> - (.macro (_ tokens) - (let [[module _] (.symbol .._) - [_ short] (.symbol <macro>) - macro_name [module short]] + (let [[module _] (.symbol .._) + [_ short] (.symbol <macro>) + macro_name [module short]] + (.macro (_ tokens) (when (is (Maybe [Bit Code]) (when tokens (list [_ {.#Text "omit"}] diff --git a/stdlib/source/library/lux/test/unit.lux b/stdlib/source/library/lux/test/unit.lux index 02e063447..62e075537 100644 --- a/stdlib/source/library/lux/test/unit.lux +++ b/stdlib/source/library/lux/test/unit.lux @@ -59,23 +59,30 @@ (-> Text Test Test) (|>> %.text context')) -(def .public failure - (-> Text Test) - (|>> (format "[Failure] ") - [tally.failure] - async#in)) - -(def .public success - (-> Text Test) - (|>> (format "[Success] ") - [tally.success] - async#in)) +(with_template [<prefix> <tally> <raw> <quoted>] + [(def <raw> + (-> Text Test) + (|>> (format <prefix>) + [<tally>] + async#in)) + + (def .public <quoted> + (-> Text Test) + (|>> %.text <raw>))] + + ["[Failure] " tally.failure failure' failure] + ["[Success] " tally.success success' success] + ) + +(def (test' message condition) + (-> Text Bit Test) + (if condition + (success' message) + (failure' message))) (def .public (test message condition) (-> Text Bit Test) - (if condition - (success message) - (failure message))) + (test' (%.text message) condition)) (def definition_separator " & ") @@ -91,7 +98,7 @@ (list#each ..coverage_format) (text.interposed ..definition_separator)) coverage (set.of_list symbol.hash coverage)] - (|> (..test message condition) + (|> (..test' message condition) (async#each (function (_ [tally documentation]) [(revised tally.#actual (set.union coverage) tally) documentation]))))) |