diff options
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux/control/parser.lux | 5 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/text/regex.lux | 5 | ||||
-rw-r--r-- | stdlib/source/test/lux/macro/syntax.lux | 69 |
3 files changed, 42 insertions, 37 deletions
diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index da6c0a381..01dbd1415 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -9,6 +9,9 @@ ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]}] + [control + [parser + ["s" code (#+ Parser)]]] [data ["." error (#+ Error)] [number @@ -21,7 +24,7 @@ ["r" random]] [macro ["." code] - ["s" syntax (#+ Syntax syntax:)]]] + [syntax (#+ syntax:)]]] {1 ["." / (#+ Parser)]}) diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux index f456aac73..3a9fc740d 100644 --- a/stdlib/source/test/lux/data/text/regex.lux +++ b/stdlib/source/test/lux/data/text/regex.lux @@ -6,7 +6,8 @@ [control pipe ["p" parser - ["<.>" text (#+ Parser)]]] + ["<.>" text (#+ Parser)] + ["s" code]]] [data [number (#+ hex)] ["." error] @@ -14,7 +15,7 @@ [math ["r" random]] ["." macro - ["s" syntax (#+ syntax:)]]] + [syntax (#+ syntax:)]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/macro/syntax.lux b/stdlib/source/test/lux/macro/syntax.lux index 92ba86d4d..8422bb4e1 100644 --- a/stdlib/source/test/lux/macro/syntax.lux +++ b/stdlib/source/test/lux/macro/syntax.lux @@ -7,7 +7,8 @@ [abstract [equivalence (#+ Equivalence)]] [control - ["p" parser]] + ["p" parser + ["s" code (#+ Parser)]]] [data ["." bit] ["." name] @@ -21,10 +22,10 @@ ["." macro ["." code]]] {1 - ["." / (#+ syntax: Syntax)]}) + ["." / (#+ syntax:)]}) (def: (enforced? parser input) - (-> (Syntax []) (List Code) Bit) + (-> (Parser []) (List Code) Bit) (case (p.run input parser) (#.Right [_ []]) #1 @@ -33,7 +34,7 @@ #0)) (def: (found? parser input) - (-> (Syntax Bit) (List Code) Bit) + (-> (Parser Bit) (List Code) Bit) (case (p.run input parser) (#.Right [_ #1]) #1 @@ -42,7 +43,7 @@ #0)) (def: (equals? Equivalence<a> reference parser input) - (All [a] (-> (Equivalence a) a (Syntax a) (List Code) Bit)) + (All [a] (-> (Equivalence a) a (Parser a) (List Code) Bit)) (case (p.run input parser) (#.Right [_ output]) (:: Equivalence<a> = reference output) @@ -73,30 +74,30 @@ (~~ (template [<assertion> <value> <ctor> <Equivalence> <get>] [(_.test <assertion> (and (equals? <Equivalence> <value> <get> (list (<ctor> <value>))) - (found? (/.this? (<ctor> <value>)) (list (<ctor> <value>))) - (enforced? (/.this (<ctor> <value>)) (list (<ctor> <value>)))))] + (found? (s.this? (<ctor> <value>)) (list (<ctor> <value>))) + (enforced? (s.this (<ctor> <value>)) (list (<ctor> <value>)))))] - ["Can parse Bit syntax." #1 code.bit bit.equivalence /.bit] - ["Can parse Nat syntax." 123 code.nat nat.equivalence /.nat] - ["Can parse Int syntax." +123 code.int int.equivalence /.int] - ["Can parse Rev syntax." .123 code.rev rev.equivalence /.rev] - ["Can parse Frac syntax." +123.0 code.frac frac.equivalence /.frac] - ["Can parse Text syntax." text.new-line code.text text.equivalence /.text] - ["Can parse Identifier syntax." ["yolo" "lol"] code.identifier name.equivalence /.identifier] - ["Can parse Tag syntax." ["yolo" "lol"] code.tag name.equivalence /.tag] + ["Can parse Bit syntax." #1 code.bit bit.equivalence s.bit] + ["Can parse Nat syntax." 123 code.nat nat.equivalence s.nat] + ["Can parse Int syntax." +123 code.int int.equivalence s.int] + ["Can parse Rev syntax." .123 code.rev rev.equivalence s.rev] + ["Can parse Frac syntax." +123.0 code.frac frac.equivalence s.frac] + ["Can parse Text syntax." text.new-line code.text text.equivalence s.text] + ["Can parse Identifier syntax." ["yolo" "lol"] code.identifier name.equivalence s.identifier] + ["Can parse Tag syntax." ["yolo" "lol"] code.tag name.equivalence s.tag] )) (_.test "Can parse identifiers belonging to the current namespace." (and (match "yolo" (p.run (list (code.local-identifier "yolo")) - /.local-identifier)) + s.local-identifier)) (fails? (p.run (list (code.identifier ["yolo" "lol"])) - /.local-identifier)))) + s.local-identifier)))) (_.test "Can parse tags belonging to the current namespace." (and (match "yolo" (p.run (list (code.local-tag "yolo")) - /.local-tag)) + s.local-tag)) (fails? (p.run (list (code.tag ["yolo" "lol"])) - /.local-tag)))) + s.local-tag)))) ))) (def: complex-values @@ -106,32 +107,32 @@ [(_.test (format "Can parse " <type> " syntax.") (and (match [#1 +123] (p.run (list (<ctor> (list (code.bit #1) (code.int +123)))) - (<parser> (p.and /.bit /.int)))) + (<parser> (p.and s.bit s.int)))) (match #1 (p.run (list (<ctor> (list (code.bit #1)))) - (<parser> /.bit))) + (<parser> s.bit))) (fails? (p.run (list (<ctor> (list (code.bit #1) (code.int +123)))) - (<parser> /.bit))) + (<parser> s.bit))) (match (#.Left #1) (p.run (list (<ctor> (list (code.bit #1)))) - (<parser> (p.or /.bit /.int)))) + (<parser> (p.or s.bit s.int)))) (match (#.Right +123) (p.run (list (<ctor> (list (code.int +123)))) - (<parser> (p.or /.bit /.int)))) + (<parser> (p.or s.bit s.int)))) (fails? (p.run (list (<ctor> (list (code.frac +123.0)))) - (<parser> (p.or /.bit /.int))))))] + (<parser> (p.or s.bit s.int))))))] - ["form" /.form code.form] - ["tuple" /.tuple code.tuple])) + ["form" s.form code.form] + ["tuple" s.tuple code.tuple])) (_.test "Can parse record syntax." (match [#1 +123] (p.run (list (code.record (list [(code.bit #1) (code.int +123)]))) - (/.record (p.and /.bit /.int))))) + (s.record (p.and s.bit s.int))))) ))) (def: #export test Test - (<| (_.context (%name (name-of /._))) + (<| (_.context (name.module (name-of /._))) ($_ _.and ..simple-values ..complex-values @@ -139,18 +140,18 @@ (_.test "Can parse any Code." (match [_ (#.Bit #1)] (p.run (list (code.bit #1) (code.int +123)) - /.any))) + s.any))) (_.test "Can check whether the end has been reached." (and (match #1 (p.run (list) - /.end?)) + s.end?)) (match #0 (p.run (list (code.bit #1)) - /.end?)))) + s.end?)))) (_.test "Can ensure the end has been reached." (and (match [] (p.run (list) - /.end!)) + s.end!)) (fails? (p.run (list (code.bit #1)) - /.end!)))) + s.end!)))) )))) |