From 29922d1411a75f9fb4259d66e427070aae72b3d3 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 12 Aug 2022 17:49:40 -0400 Subject: Fixed test suite. --- stdlib/source/library/lux.lux | 62 ++++++++++++++++++---- stdlib/source/library/lux/meta/macro/expansion.lux | 8 +-- stdlib/source/library/lux/test/unit.lux | 37 +++++++------ 3 files changed, 79 insertions(+), 28 deletions(-) (limited to 'stdlib/source/library') 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 [ ] [(def .public - (.macro (_ tokens) - (let [[module _] (.symbol .._) - [_ short] (.symbol ) - macro_name [module short]] + (let [[module _] (.symbol .._) + [_ short] (.symbol ) + 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 [ ] + [(def + (-> Text Test) + (|>> (format ) + [] + async#in)) + + (def .public + (-> Text Test) + (|>> %.text ))] + + ["[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]))))) -- cgit v1.2.3