From 820ffc0a87d7960e62508fc451d9df7a94a6afa7 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 19 Oct 2022 19:34:33 -0400 Subject: Migrating default extensions to the new format [Part 2] --- stdlib/source/test/lux.lux | 2 +- stdlib/source/test/lux/data/text.lux | 2 +- .../compiler/language/lux/analysis/inference.lux | 10 +-- .../meta/compiler/language/lux/phase/analysis.lux | 4 +- .../language/lux/phase/analysis/function.lux | 4 +- .../language/lux/phase/extension/analysis/lux.lux | 78 ++++++++++------------ 6 files changed, 47 insertions(+), 53 deletions(-) (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index dbd4166fa..8a5383eea 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -438,7 +438,7 @@ (_.coverage [/.Source] (..found_crosshair?)))) ... (_.coverage [/.require] - ... (`` (with_expansions [ ("lux in-module" "library/lux" library/lux.refer) + ... (`` (with_expansions [ (.in_module# "library/lux" library/lux.refer) ... (static.random code.text (random.lower_case 1)) ... (static.random code.local (random.lower_case 1)) ... (static.random code.text (random.lower_case 2)) diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index 97fe18d59..8d560a409 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -165,7 +165,7 @@ right (random.unicode 5)] (_.coverage [\\format.format] (/#= (\\format.format left mid right) - (all "lux text concat" left mid right)))) + (all .text_composite# left mid right)))) ..codec (,, (with_template [ ] [(do random.monad diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux index 9fa7c48ba..511285350 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux @@ -182,7 +182,7 @@ (try.else false)) (|> (/.general archive.empty ..analysis (type_literal (Ex (_ a) (-> a a))) - (list (` ("lux io error" "")))) + (list (` (.error# "")))) //type.inferring (//module.with 0 (product.left name)) (/phase#each (|>> product.right product.left (check.clean (list)) //type.check)) @@ -275,7 +275,7 @@ [(bit#= (variant? variantT arity arbitrary_right? ))] [#0 term/0] - [#1 (` ("lux io error" ""))])))) + [#1 (` (.error# ""))])))) can_handle_universal_quantification! (and (variant?' (type_literal (All (_ a) (Maybe a))) @@ -298,7 +298,7 @@ [(bit#= (variant?' (type_literal (Ex (_ a) (Maybe a))) {.#None} 0 #1 ))] [#0 term/0] - [#1 (` ("lux io error" ""))]))))] + [#1 (` (.error# ""))]))))] (and can_match_case! names_do_not_matter! @@ -377,13 +377,13 @@ 2 (list term/0 term/1))) (record? (Ex (_ a) (Tuple type/0 a)) {.#None} - 2 (list term/0 (` ("lux io error" "")))) + 2 (list term/0 (` (.error# "")))) (not (record? (Ex (_ a) (Tuple a type/0)) {.#Some (Tuple type/1 type/0)} 2 (list term/1 term/0))) (record? (Ex (_ a) (Tuple a type/0)) {.#None} - 2 (list (` ("lux io error" "")) term/0)))] + 2 (list (` (.error# "")) term/0)))] (and can_infer_record! names_do_not_matter! can_handle_universal_quantification! diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux index 06fc6be98..f459b1735 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux @@ -639,12 +639,12 @@ (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux]] (|> (do phase.monad - [[:it: it] (|> (` ("lux text concat" (, (code.text text/0)) (, (code.text text/0)))) + [[:it: it] (|> (` (.text_composite# (, (code.text text/0)) (, (code.text text/0)))) (/.phase ..expander archive.empty) //type.inferring)] (in (and (type#= .Text :it:) (when it - {//.#Extension "lux text concat" (list (//.text left) (//.text right))} + {//.#Extension (symbol .text_composite#) (list (//.text left) (//.text right))} (and (same? text/0 left) (same? text/0 right)) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux index 48a85af95..bfc7e48a8 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux @@ -175,7 +175,7 @@ ... (inferring? (All (_ a) (-> a a)) $argument/0) ... (inferring? (All (_ @0) (-> @0 @0 (And .Bit @0))) ... (` ([(, $function/1) (, $argument/1)] - ... [("lux is" (, $argument/0) (, $argument/1)) + ... [(.is?# (, $argument/0) (, $argument/1)) ... (, $argument/1)])))))) (_.coverage [/.cannot_analyse] (|> (do //phase.monad @@ -233,7 +233,7 @@ ... (reification? (All (_ a) (-> a a a)) (list term/0) (-> input/0 input/0)) ... (reification? (All (_ a) (-> input/0 a)) (list term/0) .Nothing) ... (reification? (All (_ a b) (-> a b a)) (list term/0) (All (_ b) (-> b input/0))) - ... (reification? (Ex (_ a) (-> a input/0)) (list (` ("lux io error" ""))) input/0) + ... (reification? (Ex (_ a) (-> a input/0)) (list (` (.error# ""))) input/0) ... (reification? (Ex (_ a) (-> input/0 a)) (list term/0) .Any)))) (_.coverage [/.cannot_apply] (|> (do //phase.monad diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux index f100c1e07..38cf80869 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux @@ -64,12 +64,12 @@ (r.only (|>> product.left (type#= primT) not)))] (all _.and (_.test "Can test for reference equality." - (check_success+ "lux is" (list primC primC) Bit)) + (check_success+ (` .is?#) (list primC primC) Bit)) (_.test "Reference equality must be done with elements of the same type." - (check_failure+ "lux is" (list primC antiC) Bit)) + (check_failure+ (` .is?#) (list primC antiC) Bit)) (_.test "Can 'try' risky IO computations." - (check_success+ "lux try" - (list (` ("lux io error" "YOLO"))) + (check_success+ (` .try#) + (list (` (.error# "YOLO"))) (type_literal (Either Text primT)))) ))) @@ -81,23 +81,23 @@ paramC (|> r.nat (at ! each code.nat))] (all _.and (_.test "i64 'and'." - (check_success+ "lux i64 and" (list paramC subjectC) Nat)) + (check_success+ (symbol .i64_and#) (list paramC subjectC) Nat)) (_.test "i64 'or'." - (check_success+ "lux i64 or" (list paramC subjectC) Nat)) + (check_success+ (symbol .i64_or#) (list paramC subjectC) Nat)) (_.test "i64 'xor'." - (check_success+ "lux i64 xor" (list paramC subjectC) Nat)) + (check_success+ (symbol .i64_xor#) (list paramC subjectC) Nat)) (_.test "i64 left-shift." - (check_success+ "lux i64 left-shift" (list paramC subjectC) Nat)) + (check_success+ (symbol .i64_left#) (list paramC subjectC) Nat)) (_.test "i64 logical-right-shift." (check_success+ "lux i64 logical-right-shift" (list paramC subjectC) Nat)) (_.test "i64 arithmetic-right-shift." (check_success+ "lux i64 arithmetic-right-shift" (list paramC signedC) Int)) (_.test "i64 equivalence." - (check_success+ "lux i64 =" (list paramC subjectC) Bit)) + (check_success+ (symbol .i64_=#) (list paramC subjectC) Bit)) (_.test "i64 addition." - (check_success+ "lux i64 +" (list paramC subjectC) Int)) + (check_success+ (symbol .i64_+#) (list paramC subjectC) Int)) (_.test "i64 subtraction." - (check_success+ "lux i64 -" (list paramC subjectC) Int)) + (check_success+ (symbol .i64_-#) (list paramC subjectC) Int)) ))) (def int @@ -107,17 +107,17 @@ paramC (|> r.int (at ! each code.int))] (all _.and (_.test "Can multiply integers." - (check_success+ "lux i64 *" (list paramC subjectC) Int)) + (check_success+ (symbol .int_*#) (list paramC subjectC) Int)) (_.test "Can divide integers." - (check_success+ "lux i64 /" (list paramC subjectC) Int)) + (check_success+ (symbol .int_/#) (list paramC subjectC) Int)) (_.test "Can calculate remainder of integers." - (check_success+ "lux i64 %" (list paramC subjectC) Int)) + (check_success+ (symbol .int_%#) (list paramC subjectC) Int)) (_.test "Can compare integers." - (check_success+ "lux i64 <" (list paramC subjectC) Bit)) + (check_success+ (symbol .int_<#) (list paramC subjectC) Bit)) (_.test "Can convert integer to text." - (check_success+ "lux i64 char" (list subjectC) Text)) + (check_success+ (symbol .int_char#) (list subjectC) Text)) (_.test "Can convert integer to fraction." - (check_success+ "lux i64 f64" (list subjectC) Frac)) + (check_success+ (symbol .int_f64#) (list subjectC) Frac)) ))) (def frac @@ -128,31 +128,25 @@ encodedC (|> r.safe_frac (at ! each (|>> %.frac code.text)))] (all _.and (_.test "Can add frac numbers." - (check_success+ "lux f64 +" (list paramC subjectC) Frac)) + (check_success+ (symbol .f64_+#) (list paramC subjectC) Frac)) (_.test "Can subtract frac numbers." - (check_success+ "lux f64 -" (list paramC subjectC) Frac)) + (check_success+ (symbol .f64_-#) (list paramC subjectC) Frac)) (_.test "Can multiply frac numbers." - (check_success+ "lux f64 *" (list paramC subjectC) Frac)) + (check_success+ (symbol .f64_*#) (list paramC subjectC) Frac)) (_.test "Can divide frac numbers." - (check_success+ "lux f64 /" (list paramC subjectC) Frac)) + (check_success+ (symbol .f64_/#) (list paramC subjectC) Frac)) (_.test "Can calculate remainder of frac numbers." - (check_success+ "lux f64 %" (list paramC subjectC) Frac)) + (check_success+ (symbol .f64_%#) (list paramC subjectC) Frac)) (_.test "Can test equivalence of frac numbers." - (check_success+ "lux f64 =" (list paramC subjectC) Bit)) + (check_success+ (symbol .f64_=#) (list paramC subjectC) Bit)) (_.test "Can compare frac numbers." - (check_success+ "lux f64 <" (list paramC subjectC) Bit)) - (_.test "Can obtain minimum frac number." - (check_success+ "lux f64 min" (list) Frac)) - (_.test "Can obtain maximum frac number." - (check_success+ "lux f64 max" (list) Frac)) - (_.test "Can obtain smallest frac number." - (check_success+ "lux f64 smallest" (list) Frac)) + (check_success+ (symbol .f64_<#) (list paramC subjectC) Bit)) (_.test "Can convert frac number to integer." - (check_success+ "lux f64 i64" (list subjectC) Int)) + (check_success+ (symbol .f64_int#) (list subjectC) Int)) (_.test "Can convert frac number to text." - (check_success+ "lux f64 encode" (list subjectC) Text)) + (check_success+ (symbol .f64_encoded#) (list subjectC) Text)) (_.test "Can convert text to frac number." - (check_success+ "lux f64 decode" (list encodedC) (type_literal (Maybe Frac)))) + (check_success+ (symbol .f64_decoded#) (list encodedC) (type_literal (Maybe Frac)))) ))) (def text @@ -165,19 +159,19 @@ toC (|> r.nat (at ! each code.nat))] (all _.and (_.test "Can test text equivalence." - (check_success+ "lux text =" (list paramC subjectC) Bit)) + (check_success+ (symbol .text_=#) (list paramC subjectC) Bit)) (_.test "Compare texts in lexicographical order." - (check_success+ "lux text <" (list paramC subjectC) Bit)) + (check_success+ (symbol .text_<#) (list paramC subjectC) Bit)) (_.test "Can concatenate one text to another." - (check_success+ "lux text concat" (list subjectC paramC) Text)) + (check_success+ (symbol .text_composite#) (list subjectC paramC) Text)) (_.test "Can find the index of a piece of text inside a larger one that (may) contain it." - (check_success+ "lux text index" (list fromC paramC subjectC) (type_literal (Maybe Nat)))) + (check_success+ (symbol .text_index#) (list fromC paramC subjectC) (type_literal (Maybe Nat)))) (_.test "Can query the size/length of a text." - (check_success+ "lux text size" (list subjectC) Nat)) + (check_success+ (symbol .text_size#) (list subjectC) Nat)) (_.test "Can obtain the character code of a text at a given index." - (check_success+ "lux text char" (list fromC subjectC) Nat)) + (check_success+ (symbol .text_char#) (list fromC subjectC) Nat)) (_.test "Can clip a piece of text between 2 indices." - (check_success+ "lux text clip" (list fromC toC subjectC) Text)) + (check_success+ (symbol .text_clip#) (list fromC toC subjectC) Text)) ))) (def io @@ -187,9 +181,9 @@ exitC (|> r.int (at ! each code.int))] (all _.and (_.test "Can log messages to standard output." - (check_success+ "lux io log" (list logC) Any)) + (check_success+ (symbol .log#) (list logC) Any)) (_.test "Can throw a run-time error." - (check_success+ "lux io error" (list logC) Nothing)) + (check_success+ (symbol .error#) (list logC) Nothing)) ))) (def .public test -- cgit v1.2.3