diff options
Diffstat (limited to 'stdlib/source/test/lux/data')
-rw-r--r-- | stdlib/source/test/lux/data/text/regex.lux | 24 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/text/unicode/block.lux | 57 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/text/unicode/set.lux | 44 |
3 files changed, 69 insertions, 56 deletions
diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux index 52053f108..ea81e2c77 100644 --- a/stdlib/source/test/lux/data/text/regex.lux +++ b/stdlib/source/test/lux/data/text/regex.lux @@ -7,17 +7,17 @@ [control pipe ["." try] - ["p" parser - ["<.>" text (#+ Parser)] - ["s" code]]] + [parser + ["<.>" text (#+ Parser)]]] [data ["." text ("#\." equivalence) ["%" format (#+ format)]]] + ["." macro + [syntax (#+ syntax:)] + ["." code]] [math [number (#+ hex)] - ["." random]] - ["." macro - [syntax (#+ syntax:)]]]] + ["." random]]]] [\\library ["." /]]) @@ -269,6 +269,15 @@ "123-456-7890"))) )) +(syntax: (expands? form) + (function (_ lux) + (#try.Success [lux (list (code.bit (case (macro.single_expansion form lux) + (#try.Success _) + true + + (#try.Failure error) + false)))]))) + (def: #export test Test (<| (_.covering /._) @@ -299,4 +308,7 @@ _ false))) + (_.cover [/.incorrect_quantification] + (and (expands? (/.regex "a{1,2}")) + (not (expands? (/.regex "a{2,1}"))))) ))) diff --git a/stdlib/source/test/lux/data/text/unicode/block.lux b/stdlib/source/test/lux/data/text/unicode/block.lux index d08f41fa8..9588ce6ce 100644 --- a/stdlib/source/test/lux/data/text/unicode/block.lux +++ b/stdlib/source/test/lux/data/text/unicode/block.lux @@ -24,10 +24,10 @@ (def: #export random (Random /.Block) - (do random.monad - [start random.nat - end random.nat] - (in (/.block start end)))) + (do {! random.monad} + [start (\ ! map (n.% 1,000,000) random.nat) + additional (\ ! map (n.% 1,000,000) random.nat)] + (in (/.block start additional)))) (with_expansions [<blocks> (as_is [blocks/0 [/.basic_latin @@ -171,10 +171,12 @@ (_.for [/.Block]) (do {! random.monad} [#let [top_start (hex "AC00") - top_end (hex "D7AF")] + top_end (hex "D7AF") + end_range (n.- top_start top_end)] start (\ ! map (|>> (n.% top_start) inc) random.nat) - end (\ ! map (|>> (n.% top_end) inc) random.nat) - #let [sample (/.block start end) + end (\ ! map (|>> (n.% end_range) (n.+ top_start)) random.nat) + #let [additional (n.- start end) + sample (/.block start additional) size (/.size sample)] inside (\ ! map (|>> (n.% size) @@ -188,27 +190,24 @@ (_.for [/.monoid] ($monoid.spec /.equivalence /.monoid ..random)) - (_.cover [/.block] - (\ /.equivalence = - (/.block start end) - (/.block end start))) - (_.cover [/.start] - (n.= (n.min start end) - (/.start (/.block start end)))) - (_.cover [/.end] - (n.= (n.max start end) - (/.end (/.block start end)))) - (_.cover [/.size] - (n.= (inc (n.- (n.min start end) - (n.max start end))) - (/.size (/.block start end)))) - (_.cover [/.within?] - (and (/.within? sample inside) - (not (/.within? sample (dec (/.start sample)))) - (not (/.within? sample (inc (/.end sample)))))) - (~~ (template [<definition> <part>] - [<definition>] - - <blocks>)) + (_.for [/.block] + ($_ _.and + (_.cover [/.start] + (n.= start + (/.start sample))) + (_.cover [/.end] + (n.= end + (/.end sample))) + (_.cover [/.size] + (n.= (inc additional) + (/.size sample))) + (_.cover [/.within?] + (and (/.within? sample inside) + (not (/.within? sample (dec (/.start sample)))) + (not (/.within? sample (inc (/.end sample)))))) + (~~ (template [<definition> <part>] + [<definition>] + + <blocks>)))) ))))) ) diff --git a/stdlib/source/test/lux/data/text/unicode/set.lux b/stdlib/source/test/lux/data/text/unicode/set.lux index 054c6c6f7..cd74a038c 100644 --- a/stdlib/source/test/lux/data/text/unicode/set.lux +++ b/stdlib/source/test/lux/data/text/unicode/set.lux @@ -48,34 +48,36 @@ (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) - (_.cover [/.range] - (let [[start end] (/.range (/.set [left (list right)]))] - (and (n.= (n.min (block.start left) - (block.start right)) - start) - (n.= (n.max (block.end left) - (block.end right)) - end)))) + (_.cover [/.set] + (and (n.= (block.start left) + (/.start (/.set [left (list)]))) + (n.= (block.end left) + (/.end (/.set [left (list)]))))) + (_.cover [/.start] + (n.= (n.min (block.start left) + (block.start right)) + (/.start (/.set [left (list right)])))) + (_.cover [/.end] + (n.= (n.max (block.end left) + (block.end right)) + (/.end (/.set [left (list right)])))) (_.cover [/.member?] (bit\= (block.within? block inside) (/.member? (/.set [block (list)]) inside))) (_.cover [/.compose] - (\ equivalence = - [(n.min (block.start left) - (block.start right)) - (n.max (block.end left) - (block.end right))] - (/.range (/.compose (/.set [left (list)]) - (/.set [right (list)]))))) - (_.cover [/.set] - (\ equivalence = - (/.range (/.compose (/.set [left (list)]) - (/.set [right (list)]))) - (/.range (/.set [left (list right)])))) + (let [composed (/.compose (/.set [left (list)]) + (/.set [right (list)]))] + (and (n.= (n.min (block.start left) + (block.start right)) + (/.start composed)) + (n.= (n.max (block.end left) + (block.end right)) + (/.end composed))))) (~~ (template [<set>] [(do random.monad [char (random.char <set>) - #let [[start end] (/.range <set>)]] + #let [start (/.start <set>) + end (/.end <set>)]] (_.cover [<set>] (and (/.member? <set> char) (not (/.member? <set> (dec start))) |