From 5b36c00da8a21c5d70adec4b50ef573e12dc5cf8 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 11 Jun 2022 00:10:52 -0400 Subject: De-sigil-ification: : [Part 2] --- stdlib/source/test/lux.lux | 163 +++++++++++++++++++++++---------------------- 1 file changed, 83 insertions(+), 80 deletions(-) (limited to 'stdlib/source/test/lux.lux') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index d83a447f5..056d93079 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -25,7 +25,7 @@ [dictionary ["[0]" plist]]]] ["[0]" macro (.only) - [syntax (.only syntax:)] + [syntax (.only syntax)] ["^" pattern] ["[0]" code (.open: "[1]#[0]" equivalence)] ["[0]" template]] @@ -1055,26 +1055,28 @@ @.python @.ruby))) -(syntax: (for_meta|Info []) - (function (_ lux) - (let [info (the .#info lux) - - conforming_target! - (set.member? ..possible_targets (the .#target info)) - - compiling! - (case (the .#mode info) - {.#Build} true - _ false)] - {.#Right [lux (list (code.bit (and conforming_target! - compiling!)))]}))) - -(syntax: (for_meta|Module_State []) - (do meta.monad - [prelude_module (meta.module .prelude_module)] - (in (list (code.bit (case (the .#module_state prelude_module) - {.#Active} false - _ true)))))) +(def: for_meta|Info + (syntax (_ []) + (function (_ lux) + (let [info (the .#info lux) + + conforming_target! + (set.member? ..possible_targets (the .#target info)) + + compiling! + (case (the .#mode info) + {.#Build} true + _ false)] + {.#Right [lux (list (code.bit (and conforming_target! + compiling!)))]})))) + +(def: for_meta|Module_State + (syntax (_ []) + (do meta.monad + [prelude_module (meta.module .prelude_module)] + (in (list (code.bit (case (the .#module_state prelude_module) + {.#Active} false + _ true))))))) (def: for_meta Test @@ -1096,65 +1098,66 @@ )) (for @.old (these) - (these (syntax: (for_bindings|test lux_state - [fn/0 .local - var/0 .local - let/0 .local - - fn/1 .local - var/1 .local - let/1 .local - - fn/2 .local - var/2 .local - let/2 .local - - let/3 .local]) - (in (list (code.bit (case (the .#scopes lux_state) - (pattern (partial_list scope/2 _)) - (let [locals/2 (the .#locals scope/2) - expected_locals/2 (set.of_list text.hash (list fn/2 var/2 let/2 - let/3)) - actual_locals/2 (|> locals/2 - (the .#mappings) - (list#each product.left) - (set.of_list text.hash)) - - correct_locals! - (and (n.= 4 (the .#counter locals/2)) - (set#= expected_locals/2 - actual_locals/2)) - - captured/2 (the .#captured scope/2) - - local? (is (-> Ref Bit) - (function (_ ref) - (case ref - {.#Local _} true - {.#Captured _} false))) - captured? (is (-> Ref Bit) - (|>> local? not)) - binding? (is (-> (-> Ref Bit) Text Bit) - (function (_ is? name) - (|> captured/2 - (the .#mappings) - (plist.value name) - (maybe#each (|>> product.right is?)) - (maybe.else false)))) - - correct_closure! - (and (n.= 6 (the .#counter captured/2)) - (binding? local? fn/1) - (binding? local? var/1) - (binding? local? let/1) - (binding? captured? fn/0) - (binding? captured? var/0) - (binding? captured? let/0))] - (and correct_locals! - correct_closure!)) - - _ - false))))) + (these (def: for_bindings|test + (syntax (_ lux_state + [fn/0 .local + var/0 .local + let/0 .local + + fn/1 .local + var/1 .local + let/1 .local + + fn/2 .local + var/2 .local + let/2 .local + + let/3 .local]) + (in (list (code.bit (case (the .#scopes lux_state) + (pattern (partial_list scope/2 _)) + (let [locals/2 (the .#locals scope/2) + expected_locals/2 (set.of_list text.hash (list fn/2 var/2 let/2 + let/3)) + actual_locals/2 (|> locals/2 + (the .#mappings) + (list#each product.left) + (set.of_list text.hash)) + + correct_locals! + (and (n.= 4 (the .#counter locals/2)) + (set#= expected_locals/2 + actual_locals/2)) + + captured/2 (the .#captured scope/2) + + local? (is (-> Ref Bit) + (function (_ ref) + (case ref + {.#Local _} true + {.#Captured _} false))) + captured? (is (-> Ref Bit) + (|>> local? not)) + binding? (is (-> (-> Ref Bit) Text Bit) + (function (_ is? name) + (|> captured/2 + (the .#mappings) + (plist.value name) + (maybe#each (|>> product.right is?)) + (maybe.else false)))) + + correct_closure! + (and (n.= 6 (the .#counter captured/2)) + (binding? local? fn/1) + (binding? local? var/1) + (binding? local? let/1) + (binding? captured? fn/0) + (binding? captured? var/0) + (binding? captured? let/0))] + (and correct_locals! + correct_closure!)) + + _ + false)))))) (def: for_bindings Test -- cgit v1.2.3