Skip to content

Commit

Permalink
Improving test coverage [part 7]
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Sep 28, 2024
1 parent 2e10b7d commit 33491c1
Show file tree
Hide file tree
Showing 30 changed files with 705 additions and 554 deletions.
132 changes: 36 additions & 96 deletions stdlib/source/library/lux.lux
Original file line number Diff line number Diff line change
Expand Up @@ -1959,32 +1959,32 @@
..no_provenance
(code#text value))))

(the' .public UnQuote
(the' .private UnQuote
Type
{#Named [..prelude "UnQuote"]
{#Nominal ".Macro/UnQuote" (.list#)}})

(the' .public (unquote it)
(the' .private (unquote it)
(-> Macro
UnQuote)
(.as# (-> Macro UnQuote) it))

(the' .public (unquote_macro it)
(the' .private (unquote_macro it)
(-> UnQuote
Macro')
(.as# (-> UnQuote Macro') it))

(the' .public Spliced_UnQuote
(the' .private Spliced_UnQuote
Type
{#Named [..prelude "Spliced_UnQuote"]
{#Nominal ".Macro/Spliced_UnQuote" (.list#)}})

(the' .public (spliced_unquote it)
(the' .private (spliced_unquote it)
(-> Macro
Spliced_UnQuote)
(.as# (-> Macro Spliced_UnQuote) it))

(the' .public (spliced_unquote_macro it)
(the' .private (spliced_unquote_macro it)
(-> Spliced_UnQuote
Macro')
(.as# (-> Spliced_UnQuote Macro') it))
Expand Down Expand Up @@ -2998,8 +2998,7 @@

[[?#variant #Variant]
[?#tuple #Tuple]
[?#form #Form]]
)
[?#form #Form]])

(the' .private (?#binding tape)
($ Projection (And Text Code))
Expand Down Expand Up @@ -3065,8 +3064,7 @@
[[?#bit Bit #Bit]
[?#natural Natural #Natural]
[?#text Text #Text]
[?#name Name #Name]]
)
[?#name Name #Name]])

(the' .private (?#this_name reference tape)
(-> Name
Expand Down Expand Up @@ -3365,10 +3363,6 @@
(monad#each meta#monad normal_type parameters))])
(meta#return lux (type_reification abstraction parameters))))

(the' .public type_must_have_singular_expansion
Error
"The expansion of the type-syntax has to yield a single element.")

(the' .private (expanded_type_reification normal_type @ binding parameters)
(-> (-> Code ($ Meta Code)) Provenance Name ($ List Code)
($ Meta Code))
Expand All @@ -3383,7 +3377,7 @@
(meta#return lux (` (..type (, singular))))

else
(meta#failure ..type_must_have_singular_expansion)))
(meta#failure "The expansion of the type-syntax has to yield a single element.")))

{#None}
((normal_type_reification normal_type {#Name @ binding} parameters) lux))))
Expand Down Expand Up @@ -3597,8 +3591,7 @@
<side>))]

[[product#left left]
[product#right right]]
)
[product#right right]])

(the' .private (generated_name prefix state)
(-> Text
Expand Down Expand Up @@ -4067,8 +4060,7 @@
(` <nullary>))))))]

[[0b (if (, pre) 1b (, post)) or]
[1b (if (, pre) (, post) 0b) and]]
)
[1b (if (, pre) (, post) 0b) and]])

... https://en.wikipedia.org/wiki/Halting_problem
(the .public (halt! message)
Expand Down Expand Up @@ -4317,56 +4309,6 @@
{#None}
{#Left "Not expecting any type."}))))

(the \n
Text
(.int_char# +10))

(the (provenance#as it)
(-> Provenance
Text)
(let [... https://en.wikipedia.org/wiki/Delimiter
delimiter ","
[file line column] it]
(text "@"
(text#as file) delimiter
(natural#as line) delimiter
(natural#as column))))

(the (provenance#with provenance error)
(-> Provenance
(Change Text))
(text (provenance#as provenance) \n
error))

(the provenance#here
(macro (_ tokens compiler)
(when tokens
(list)
(let [[..#info _
..#source _
..#current_module _
..#modules _
..#scopes _
..#type_context _
..#seed _
..#expected _
..#provenance provenance
..#eval _] compiler
[.#module module .#line line .#column column] provenance]
{#Right [compiler
(list (` (.is .Provenance
[.#module (, {..#Text ..provenance#dummy module})
.#line (, {..#Natural ..provenance#dummy line})
.#column (, {..#Natural ..provenance#dummy column})])))]})

_
{#Left ..wrong_syntax})))

(the .public invalid_implementation_member
Error
(provenance#with (provenance#here)
"Invalid implementation member."))

(the .public implementation
(macro (_ tokens)
(with_monad meta#monad
Expand Down Expand Up @@ -4399,10 +4341,10 @@
(pure (list tag value))

_
(failure (text "Unknown implementation member: " slot_name)))
(failure (text "Unknown member of implementation: " slot_name)))

_
(failure ..invalid_implementation_member))))
(failure "Invalid member of implementation."))))
(list#conjoint tokens'))]
(pure (list (code#tuple (list#conjoint members)))))))

Expand Down Expand Up @@ -4459,11 +4401,6 @@
(?#and ?#simple_global_declaration
?#any))

(the .public improper_type_definition
Error
(provenance#with (provenance#here)
"Improper type definition syntax."))

(the (declaration_of_type it)
(-> Code
(Meta [Code (Maybe (Either (List Text) (List Text)))]))
Expand All @@ -4479,21 +4416,21 @@
(meta#pure [type {#Some {#Left tags}}])

{#None}
(failure ..improper_type_definition))
(failure ..wrong_syntax))

(list type {#Tuple _ slots})
(when (?#value slots (?#some ?#text))
{#Some slots}
(meta#pure [type {#Some {#Right slots}}])

{#None}
(failure ..improper_type_definition))
(failure ..wrong_syntax))

(list type)
(meta#pure [it {#None}])

_
(failure ..improper_type_definition)))
(failure ..wrong_syntax)))

else
(meta#pure [it {#None}])))
Expand Down Expand Up @@ -4771,6 +4708,10 @@
(.text_size# input))]
(.text_clip# after_offset after_length input))))))

(the \n
Text
(.int_char# +10))

(the (absolute_module_name nested? relative_root module)
(-> Bit Text Text
(Meta Text))
Expand Down Expand Up @@ -5390,15 +5331,7 @@
{#None}
(failure ..wrong_syntax))))

(the (imported_by? import_name module_name)
(-> Text Text
(Meta Bit))
(with_monad meta#monad
[module (module module_name)
.let [[..#module_hash _ ..#module_aliases _ ..#definitions _ ..#imports imports ..#module_state _] module]]
(pure (list#member? imports import_name))))

(the .public refer
(the refer
(macro (_ tokens)
(when (?#value tokens
(all ?#and
Expand Down Expand Up @@ -5662,8 +5595,7 @@
(|>> (<extension> 1)))]

[[++ .i64_+#]
[-- .i64_-#]]
)
[-- .i64_-#]])

(the (interleaved left right)
(for_any (_ it)
Expand Down Expand Up @@ -5829,6 +5761,17 @@
_
(failure ..wrong_syntax))))

(the (provenance#as it)
(-> Provenance
Text)
(let [... https://en.wikipedia.org/wiki/Delimiter
delimiter ","
[file line column] it]
(text "@"
(text#as file) delimiter
(natural#as line) delimiter
(natural#as column))))

(the .public undefined
(let [provenance (is (Meta Provenance)
(function (_ compiler)
Expand Down Expand Up @@ -5945,8 +5888,7 @@
[[i64 ..I64]
[natural ..Natural]
[integer ..Integer]
[revolution ..Revolution]]
)
[revolution ..Revolution]])

(the .public character
(macro (_ tokens compiler)
Expand Down Expand Up @@ -5993,8 +5935,7 @@
[c++ "C++"]
[common_lisp "Common Lisp"]
[php "PHP"]
[r "R"]]
)
[r "R"]])

(the .public for
(let [target (is (Meta Target)
Expand Down Expand Up @@ -6219,8 +6160,7 @@
[[Analysis]
[Synthesis]
[Translation]
[Declaration]]
)
[Declaration]])

(the .public alias
(macro (_ tokens)
Expand Down
3 changes: 1 addition & 2 deletions stdlib/source/library/lux/abstract/functor.lux
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@

(the .public (recursive body)
(for_any (_ it)
(-> (-> (Functor it)
(Functor it))
(-> (Change (Functor it))
(Functor it)))
(implementation
(the (each value it)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/source/library/lux/abstract/projection.lux
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@

(the .public (when condition next)
(for_any (_ state it)
(-> Bit (Projection state it)
(Projection state it)))
(-> Bit
(Change (Projection state it))))
(function (_ state)
(if condition
(next state)
Expand Down
3 changes: 1 addition & 2 deletions stdlib/source/library/lux/data/format/json.lux
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,7 @@

(the .public (recursive context)
(for_any (_ it)
(-> (-> (Format JSON it)
(Format JSON it))
(-> (Change (Format JSON it))
(Format JSON it)))
(implementation
(the (as it)
Expand Down
1 change: 1 addition & 0 deletions stdlib/source/library/lux/error.lux
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
(the .public not_known)
(the .public empty)
(the .public no_instance)
(the .public not_available)
9 changes: 3 additions & 6 deletions stdlib/source/library/lux/macro/pattern.lux
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

(.using
[library
[lux (.except UnQuote unquote unquote_macro
Spliced_UnQuote spliced_unquote spliced_unquote_macro
or let |>)
[lux (.except or let |>)
[abstract
["[0]" monad]]
[control
Expand All @@ -22,7 +20,7 @@
["[0]" vocabulary]
["[0]" expansion]])

(the with_template (.in_module# .prelude .with_template))
(the with_template (.in_module# .prelude with_template))

(with_template [<name>]
[(the <name> (.in_module# .prelude <name>))]
Expand Down Expand Up @@ -59,8 +57,7 @@
[?#any]
[?#name]
[?#local]
[?#tuple]]
)
[?#tuple]])

(the .public or
(pattern
Expand Down
2 changes: 1 addition & 1 deletion stdlib/source/library/lux/math/number/64/rational.lux
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
(the arithmetic_of_module_2/2
(template.macro (_ ,*variables)
[(every .public Exponent
Integer)
fraction.Exponent)

... https://en.wikipedia.org/wiki/Exponentiation
... https://en.wikipedia.org/wiki/Exponentiation_by_squaring
Expand Down
6 changes: 4 additions & 2 deletions stdlib/source/library/lux/math/number/big/fraction.lux
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
["[0]" list
["?[1]" \\projection]]]]
[math
["[0]" random (.only Random) (.use "[1]#[0]" functor)]]]]
["[0]" random (.only Random) (.use "[1]#[0]" functor)]]
[aspect
["[0]" case]]]]
[//
["//" natural]
[//
[/64
["/" fraction]]]])

(/.module //.Number //.small
(/.module //.Number (case.some //.small)
//.= //.< //.greatest_common_divisor
//.zero //.one
//.+ //.- //.x //./ //.%
Expand Down
Loading

0 comments on commit 33491c1

Please sign in to comment.