From f623de52d76ad8ec96feb048cd95a3fb150717e1 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 5 Jun 2022 01:39:29 -0400 Subject: De-sigil-ification: : [Part 1] --- stdlib/source/test/lux.lux | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) (limited to 'stdlib/source/test/lux.lux') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index ac59df0cc..d83a447f5 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -24,7 +24,7 @@ ["[0]" set (.only Set) (.open: "[1]#[0]" equivalence)] [dictionary ["[0]" plist]]]] - ["[0]" macro + ["[0]" macro (.only) [syntax (.only syntax:)] ["^" pattern] ["[0]" code (.open: "[1]#[0]" equivalence)] @@ -375,31 +375,17 @@ (location#= location.dummy))) ))) -(/.macro: (identity_macro tokens) - (at meta.monad in tokens)) +(def: identity_macro + (/.macro (_ tokens) + (at meta.monad in tokens))) (def: crosshair "This is an arbitrary text whose only purpose is to be found, somewhere, in the source-code.") -(/.macro: (found_crosshair? tokens lux) - (let [[_ _ source_code] (the .#source lux)] - {.#Right [lux (list (code.bit (text.contains? ..crosshair source_code)))]})) - -(/.macro: (sum tokens) - (loop (again [tokens tokens - output 0]) - (case tokens - {.#End} - (meta#in (list (code.nat output))) - - {.#Item [_ {.#Nat head}] tail} - (again tail (n.+ head output)) - - _ - (meta.failure "")))) - -(/.macro: (sum' tokens lux) - ((/.macro ..sum) tokens lux)) +(def: found_crosshair? + (macro (_ tokens lux) + (let [[_ _ source_code] (the .#source lux)] + {.#Right [lux (list (code.bit (text.contains? ..crosshair source_code)))]}))) (def: for_macro Test @@ -419,17 +405,11 @@ (is /.Macro) (is Any) (same? (is Any macro)))) - (_.coverage [/.macro:] + (_.coverage [/.macro] (same? expected (..identity_macro expected))) (~~ (for @.old (~~ (these)) (_.coverage [/.Source] (..found_crosshair?)))) - (_.coverage [/.macro] - (with_expansions [n/0 (static.random_nat) - n/1 (static.random_nat) - n/1 (static.random_nat)] - (n.= (..sum n/0 n/1 n/1) - (..sum' n/0 n/1 n/1)))) (_.coverage [/.using] (`` (with_expansions [ ("lux in-module" "library/lux" library/lux.refer) (static.random code.text (random.lower_case 1)) -- cgit v1.2.3