From b216900093c905b3b20dd45c69e577b192e2f7a3 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 25 Aug 2021 16:47:50 -0400 Subject: Updates to the Lua compiler. --- stdlib/source/test/aedifex/cli.lux | 10 +++-- stdlib/source/test/aedifex/input.lux | 2 +- stdlib/source/test/aedifex/project.lux | 10 ++--- stdlib/source/test/lux/control/function/memo.lux | 4 +- stdlib/source/test/lux/control/function/mixin.lux | 30 +++++++------- stdlib/source/test/lux/data/collection/array.lux | 49 +++++++++++------------ stdlib/source/test/lux/data/text.lux | 18 ++++----- stdlib/source/test/lux/math.lux | 4 +- stdlib/source/test/lux/type/check.lux | 8 ++-- 9 files changed, 68 insertions(+), 67 deletions(-) (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/aedifex/cli.lux b/stdlib/source/test/aedifex/cli.lux index 45ec92f4e..9712d8a93 100644 --- a/stdlib/source/test/aedifex/cli.lux +++ b/stdlib/source/test/aedifex/cli.lux @@ -12,7 +12,9 @@ [parser ["." cli]]] [data - ["." text ("#\." equivalence)]] + ["." text] + [collection + ["." list]]] [math ["." random (#+ Random) ("#\." monad)]]]] [\\program @@ -74,8 +76,8 @@ (|> expected ..format (cli.result /.command) - (case> (#try.Success [name actual]) - (and (text\= //.default name) + (case> (#try.Success [names actual]) + (and (\ (list.equivalence text.equivalence) = (list //.default) names) (\ /.equivalence = expected actual)) (#try.Failure error) @@ -92,7 +94,7 @@ (list& "with" expected_profile) (cli.result /.command) (case> (#try.Success [actual_profile actual_command]) - (and (text\= expected_profile actual_profile) + (and (\ (list.equivalence text.equivalence) = (list expected_profile //.default) actual_profile) (\ /.equivalence = expected_command actual_command)) (#try.Failure error) diff --git a/stdlib/source/test/aedifex/input.lux b/stdlib/source/test/aedifex/input.lux index 993e67088..905075adc 100644 --- a/stdlib/source/test/aedifex/input.lux +++ b/stdlib/source/test/aedifex/input.lux @@ -56,7 +56,7 @@ (\ utf8.codec encoded))] _ (\ fs write profile //project.file) actual (: (Async (Try Profile)) - (/.read async.monad fs //.default))] + (/.read async.monad fs (list //.default)))] (in (\ //.equivalence = (|> expected (revised@ #//.sources ..with_default_source) diff --git a/stdlib/source/test/aedifex/project.lux b/stdlib/source/test/aedifex/project.lux index ebf37db81..c11444355 100644 --- a/stdlib/source/test/aedifex/project.lux +++ b/stdlib/source/test/aedifex/project.lux @@ -73,24 +73,24 @@ (/.project sub_name (with@ #//.parents (list super_name) sub_profile)))]] ($_ _.and (_.cover [/.profile] - (and (|> (/.profile super_name project) + (and (|> (/.profile project super_name) (try\each (\ //.equivalence = super_profile)) (try.else false)) - (|> (/.profile dummy_name project) + (|> (/.profile project dummy_name) (try\each (\ //.equivalence = dummy_profile)) (try.else false)) - (|> (/.profile sub_name project) + (|> (/.profile project sub_name) (try\each (\ //.equivalence = (\ //.monoid composite sub_profile super_profile))) (try.else false)))) (_.cover [/.unknown_profile] - (case (/.profile fake_name project) + (case (/.profile project fake_name) (#try.Success _) false (#try.Failure error) (exception.match? /.unknown_profile error))) (_.cover [/.circular_dependency] - (case (/.profile sub_name circular) + (case (/.profile circular sub_name) (#try.Success _) false diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux index ca4d06e2d..266952896 100644 --- a/stdlib/source/test/lux/control/function/memo.lux +++ b/stdlib/source/test/lux/control/function/memo.lux @@ -101,8 +101,8 @@ memo_is_faster! incrementalism_is_faster!))))) (_.cover [/.memoization] - (let [memo (<| //.mixin - (//.with /.memoization) + (let [memo (<| //.fixed + (//.mixed /.memoization) (: (//.Mixin Nat (State (Dictionary Nat Nat) Nat)) (function (factorial delegate recur input) (case input diff --git a/stdlib/source/test/lux/control/function/mixin.lux b/stdlib/source/test/lux/control/function/mixin.lux index 533f88072..51c1157bc 100644 --- a/stdlib/source/test/lux/control/function/mixin.lux +++ b/stdlib/source/test/lux/control/function/mixin.lux @@ -31,8 +31,8 @@ .let [equivalence (: (Equivalence (/.Mixin Nat Nat)) (implementation (def: (= left right) - (n.= ((/.mixin left) input) - ((/.mixin right) input))))) + (n.= ((/.fixed left) input) + ((/.fixed right) input))))) generator (: (Random (/.Mixin Nat Nat)) (do ! [output random.nat] @@ -47,15 +47,15 @@ (_.for [/.monoid] ($monoid.spec equivalence /.monoid generator)) - (_.cover [/.mixin] - (let [factorial (/.mixin + (_.cover [/.fixed] + (let [factorial (/.fixed (function (_ delegate recur input) (case input (^or 0 1) 1 _ (n.* input (recur (-- input))))))] (n.= expected (factorial input)))) - (_.cover [/.with] + (_.cover [/.mixed] (let [bottom (: (/.Mixin Nat Nat) (function (_ delegate recur input) (case input @@ -64,7 +64,7 @@ multiplication (: (/.Mixin Nat Nat) (function (_ delegate recur input) (n.* input (recur (-- input))))) - factorial (/.mixin (/.with bottom multiplication))] + factorial (/.fixed (/.mixed bottom multiplication))] (n.= expected (factorial input)))) (_.cover [/.nothing] @@ -73,8 +73,8 @@ (case input (^or 0 1) 1 _ (n.* input (delegate (-- input)))))) - left (/.mixin (/.with /.nothing loop)) - right (/.mixin (/.with loop /.nothing))] + left (/.fixed (/.mixed /.nothing loop)) + right (/.fixed (/.mixed loop /.nothing))] (and (n.= expected (left input)) (n.= expected @@ -91,8 +91,8 @@ multiplication (: (/.Mixin Nat Nat) (function (_ delegate recur input) (n.* input (recur (-- input))))) - factorial (/.mixin (/.with (/.advice bottom? bottom) - multiplication))] + factorial (/.fixed (/.mixed (/.advice bottom? bottom) + multiplication))] (n.= expected (factorial input)))) (_.cover [/.before] @@ -104,8 +104,8 @@ (function (_ delegate recur input) (function (_ state) [state (n.+ state input)]))) - function (/.mixin (/.with (/.before state.monad implant) - meld))] + function (/.fixed (/.mixed (/.before state.monad implant) + meld))] (n.= (n.+ shift input) (|> input function (state.result dummy) product.right)))) (_.cover [/.after] @@ -117,14 +117,14 @@ (function (_ delegate recur input) (function (_ state) [state (n.+ state input)]))) - function (/.mixin (/.with (/.after state.monad implant) - meld))] + function (/.fixed (/.mixed (/.after state.monad implant) + meld))] (n.= (n.+ dummy input) (|> input function (state.result dummy) product.right)))) )) (_.for [/.Recursive] (_.cover [/.of_recursive] - (let [factorial (/.mixin + (let [factorial (/.fixed (/.of_recursive (function (_ recur input) (case input diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index 03ff479ff..08064ff74 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -59,7 +59,7 @@ (_.cover [/.example] (\ (maybe.equivalence n.equivalence) = (/.example n.even? the_array) - (list.example n.even? (/.list the_array)))) + (list.example n.even? (/.list #.None the_array)))) (_.cover [/.example+] (case [(/.example n.even? the_array) (/.example+ (function (_ idx member) @@ -81,11 +81,11 @@ false)) (_.cover [/.every?] (\ bit.equivalence = - (list.every? n.even? (/.list the_array)) + (list.every? n.even? (/.list #.None the_array)) (/.every? n.even? the_array))) (_.cover [/.any?] (\ bit.equivalence = - (list.any? n.even? (/.list the_array)) + (list.any? n.even? (/.list #.None the_array)) (/.any? n.even? the_array))) ))) @@ -182,12 +182,24 @@ (n.= size (n.+ (/.occupancy the_array) (/.vacancy the_array))))))) (do ! - [the_list (random.list size random.nat)] + [the_list (random.list size random.nat) + .let [the_array (/.clone the_array) + members (|> the_array (/.list #.None) (set.of_list n.hash))] + default (random.only (function (_ value) + (not (or (n.even? value) + (set.member? members value)))) + random.nat)] (_.cover [/.of_list /.list] - (and (|> the_list /.of_list /.list + (and (|> the_list /.of_list (/.list #.None) (\ (list.equivalence n.equivalence) = the_list)) - (|> the_array /.list /.of_list - (\ (/.equivalence n.equivalence) = the_array))))) + (|> the_array (/.list #.None) /.of_list + (\ (/.equivalence n.equivalence) = the_array)) + (exec + (/.filter! n.even? the_array) + (list.every? (function (_ value) + (or (n.even? value) + (same? default value))) + (/.list (#.Some default) the_array)))))) (do ! [amount (\ ! each (n.% (++ size)) random.nat)] (_.cover [/.copy!] @@ -195,31 +207,18 @@ (/.empty size))] (exec (/.copy! amount 0 the_array 0 copy) (\ (list.equivalence n.equivalence) = - (list.first amount (/.list the_array)) - (/.list copy)))))) + (list.first amount (/.list #.None the_array)) + (/.list #.None copy)))))) (_.cover [/.clone] (let [clone (/.clone the_array)] (and (not (same? the_array clone)) (\ (/.equivalence n.equivalence) = the_array clone)))) (let [the_array (/.clone the_array) - evens (|> the_array /.list (list.only n.even?)) - odds (|> the_array /.list (list.only n.odd?))] + evens (|> the_array (/.list #.None) (list.only n.even?)) + odds (|> the_array (/.list #.None) (list.only n.odd?))] (_.cover [/.filter!] (exec (/.filter! n.even? the_array) (and (n.= (list.size evens) (/.occupancy the_array)) (n.= (list.size odds) (/.vacancy the_array)) - (|> the_array /.list (\ (list.equivalence n.equivalence) = evens)))))) - (do ! - [.let [the_array (/.clone the_array) - members (|> the_array /.list (set.of_list n.hash))] - default (random.only (function (_ value) - (not (or (n.even? value) - (set.member? members value)))) - random.nat)] - (_.cover [/.list'] - (exec (/.filter! n.even? the_array) - (list.every? (function (_ value) - (or (n.even? value) - (same? default value))) - (/.list' default the_array))))) + (|> the_array (/.list #.None) (\ (list.equivalence n.equivalence) = evens)))))) )))) diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index df0c6000c..aa30ee356 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -96,22 +96,22 @@ (|> (/.index outer (\ /.monoid composite inner outer)) (maybe.else fake_index) (n.= 1)))) - (_.cover [/.index'] + (_.cover [/.index_since] (let [full (\ /.monoid composite inner outer)] - (and (|> (/.index' 0 inner full) + (and (|> (/.index_since 0 inner full) (maybe.else fake_index) (n.= 0)) - (|> (/.index' 1 inner full) + (|> (/.index_since 1 inner full) (maybe.else fake_index) (n.= fake_index)) - (|> (/.index' 0 outer full) + (|> (/.index_since 0 outer full) (maybe.else fake_index) (n.= 1)) - (|> (/.index' 1 outer full) + (|> (/.index_since 1 outer full) (maybe.else fake_index) (n.= 1)) - (|> (/.index' 2 outer full) + (|> (/.index_since 2 outer full) (maybe.else fake_index) (n.= fake_index))))) (_.cover [/.last_index] @@ -297,11 +297,11 @@ _ #0))) - (_.cover [/.clip /.clip'] + (_.cover [/.clip /.clip_since] (|> [(/.clip 0 sizeL sample) (/.clip sizeL (n.- sizeL (/.size sample)) sample) - (/.clip' sizeL sample) - (/.clip' 0 sample)] + (/.clip_since sizeL sample) + (/.clip_since 0 sample)] (case> [(#.Right _l) (#.Right _r) (#.Right _r') (#.Right _f)] (and (/\= sampleL _l) (/\= sampleR _r) diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux index da5cfd057..ca72f6882 100644 --- a/stdlib/source/test/lux/math.lux +++ b/stdlib/source/test/lux/math.lux @@ -98,11 +98,11 @@ (|> sample /.exp /.log (f.approximately? +0.000000000000001 sample))) (_.cover [/.e] (~= +1.0 (/.log /.e))) - (_.cover [/.pow /.log'] + (_.cover [/.pow /.log_by] (let [sample (f.abs sample)] (|> sample (/.pow power) - (/.log' sample) + (/.log_by sample) (~= power)))) )) (do {! random.monad} diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux index f4ee4b802..4674890ca 100644 --- a/stdlib/source/test/lux/type/check.lux +++ b/stdlib/source/test/lux/type/check.lux @@ -220,10 +220,10 @@ (do random.monad [nominal (random.ascii/upper 10) .let [expected (#.Primitive nominal (list))]] - (_.cover [/.read'] + (_.cover [/.peek] (and (|> (do /.monad [[var_id var_type] /.var] - (/.read' var_id)) + (/.peek var_id)) (/.result /.fresh_context) (case> (#try.Success #.None) true _ false)) @@ -231,14 +231,14 @@ [[var_id var/0] /.var [_ var/1] /.var _ (/.check var/0 var/1)] - (/.read' var_id)) + (/.peek var_id)) (/.result /.fresh_context) (case> (#try.Success #.None) true _ false)) (|> (do /.monad [[var_id var_type] /.var _ (/.bind expected var_id)] - (/.read' var_id)) + (/.peek var_id)) (/.result /.fresh_context) (case> (#try.Success (#.Some actual)) (same? expected actual) -- cgit v1.2.3