diff options
author | Eduardo Julian | 2017-05-07 15:26:09 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-05-07 15:26:09 -0400 |
commit | 08eb05f23914194c3adcc141664d4c2d7d88978c (patch) | |
tree | 73b61370c672f8b1a6bb9f7af429ef6a2617e9aa /stdlib/test | |
parent | db697bb636e2341d26bb188cc1b9981a1ab505d7 (diff) |
- Renamed "AST" to "Code".
Diffstat (limited to '')
-rw-r--r-- | stdlib/test/test/lux/data/format/json.lux | 2 | ||||
-rw-r--r-- | stdlib/test/test/lux/data/text/regex.lux | 2 | ||||
-rw-r--r-- | stdlib/test/test/lux/macro/code.lux (renamed from stdlib/test/test/lux/macro/ast.lux) | 8 | ||||
-rw-r--r-- | stdlib/test/test/lux/macro/syntax.lux | 114 | ||||
-rw-r--r-- | stdlib/test/tests.lux | 16 |
5 files changed, 73 insertions, 69 deletions
diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux index c481fa60e..7acddf750 100644 --- a/stdlib/test/test/lux/data/format/json.lux +++ b/stdlib/test/test/lux/data/format/json.lux @@ -17,7 +17,7 @@ [dict] [list])) [macro #+ with-gensyms] - (macro [ast] + (macro [code] [syntax #+ syntax:] [poly #+ derived:]) ["R" math/random] diff --git a/stdlib/test/test/lux/data/text/regex.lux b/stdlib/test/test/lux/data/text/regex.lux index 64be4766e..62953b20b 100644 --- a/stdlib/test/test/lux/data/text/regex.lux +++ b/stdlib/test/test/lux/data/text/regex.lux @@ -10,7 +10,7 @@ (text [lexer] ["&" regex])) [macro] - (macro [ast] + (macro [code] ["s" syntax #+ syntax:]) ["R" math/random]) lux/test) diff --git a/stdlib/test/test/lux/macro/ast.lux b/stdlib/test/test/lux/macro/code.lux index 8670ead71..2f05ad926 100644 --- a/stdlib/test/test/lux/macro/ast.lux +++ b/stdlib/test/test/lux/macro/code.lux @@ -6,15 +6,15 @@ text/format [number]) ["R" math/random] - (macro ["&" ast])) + (macro ["&" code])) lux/test) -(test: "AST" +(test: "Code" (with-expansions [<tests> (do-template [<expr> <text>] - [(assert (format "Can produce AST node: " <text>) + [(assert (format "Can produce Code node: " <text>) (and (T/= <text> (&;to-text <expr>)) - (:: &;Eq<AST> = <expr> <expr>)))] + (:: &;Eq<Code> = <expr> <expr>)))] [(&;bool true) "true"] [(&;bool false) "false"] diff --git a/stdlib/test/test/lux/macro/syntax.lux b/stdlib/test/test/lux/macro/syntax.lux index 41c372e15..f75a7117e 100644 --- a/stdlib/test/test/lux/macro/syntax.lux +++ b/stdlib/test/test/lux/macro/syntax.lux @@ -12,13 +12,13 @@ [error #- fail]) ["R" math/random] [macro] - (macro [ast] + (macro [code] ["s" syntax #+ syntax: Syntax])) lux/test) ## [Utils] (def: (enforced? parser input) - (-> (Syntax []) (List AST) Bool) + (-> (Syntax []) (List Code) Bool) (case (s;run input parser) (#;Right [_ []]) true @@ -27,7 +27,7 @@ false)) (def: (found? parser input) - (-> (Syntax Bool) (List AST) Bool) + (-> (Syntax Bool) (List Code) Bool) (case (s;run input parser) (#;Right [_ true]) true @@ -36,7 +36,7 @@ false)) (def: (is? Eq<a> test parser input) - (All [a] (-> (Eq a) a (Syntax a) (List AST) Bool)) + (All [a] (-> (Eq a) a (Syntax a) (List Code) Bool)) (case (s;run input parser) (#;Right [_ output]) (:: Eq<a> = test output) @@ -70,31 +70,31 @@ (found? (s;this? (<ctor> <value>)) (list (<ctor> <value>))) (enforced? (s;this! (<ctor> <value>)) (list (<ctor> <value>)))))] - ["Can parse Bool syntax." true ast;bool bool;Eq<Bool> s;bool] - ["Can parse Nat syntax." +123 ast;nat number;Eq<Nat> s;nat] - ["Can parse Int syntax." 123 ast;int number;Eq<Int> s;int] - ["Can parse Deg syntax." .123 ast;deg number;Eq<Deg> s;deg] - ["Can parse Real syntax." 123.0 ast;real number;Eq<Real> s;real] - ["Can parse Char syntax." #"\n" ast;char char;Eq<Char> s;char] - ["Can parse Text syntax." "\n" ast;text text;Eq<Text> s;text] - ["Can parse Symbol syntax." ["yolo" "lol"] ast;symbol ident;Eq<Ident> s;symbol] - ["Can parse Tag syntax." ["yolo" "lol"] ast;tag ident;Eq<Ident> s;tag] + ["Can parse Bool syntax." true code;bool bool;Eq<Bool> s;bool] + ["Can parse Nat syntax." +123 code;nat number;Eq<Nat> s;nat] + ["Can parse Int syntax." 123 code;int number;Eq<Int> s;int] + ["Can parse Deg syntax." .123 code;deg number;Eq<Deg> s;deg] + ["Can parse Real syntax." 123.0 code;real number;Eq<Real> s;real] + ["Can parse Char syntax." #"\n" code;char char;Eq<Char> s;char] + ["Can parse Text syntax." "\n" code;text text;Eq<Text> s;text] + ["Can parse Symbol syntax." ["yolo" "lol"] code;symbol ident;Eq<Ident> s;symbol] + ["Can parse Tag syntax." ["yolo" "lol"] code;tag ident;Eq<Ident> s;tag] )] ($_ seq <simple-tests> (assert "Can parse symbols belonging to the current namespace." (and (match "yolo" - (s;run (list (ast;local-symbol "yolo")) + (s;run (list (code;local-symbol "yolo")) s;local-symbol)) - (fails? (s;run (list (ast;symbol ["yolo" "lol"])) + (fails? (s;run (list (code;symbol ["yolo" "lol"])) s;local-symbol)))) (assert "Can parse tags belonging to the current namespace." (and (match "yolo" - (s;run (list (ast;local-tag "yolo")) + (s;run (list (code;local-tag "yolo")) s;local-tag)) - (fails? (s;run (list (ast;tag ["yolo" "lol"])) + (fails? (s;run (list (code;tag ["yolo" "lol"])) s;local-tag)))) ))) @@ -103,89 +103,89 @@ [<group-tests> (do-template [<type> <parser> <ctor>] [(assert (format "Can parse " <type> " syntax.") (and (match [true 123] - (s;run (list (<ctor> (list (ast;bool true) (ast;int 123)))) + (s;run (list (<ctor> (list (code;bool true) (code;int 123)))) (<parser> (s;seq s;bool s;int)))) (match true - (s;run (list (<ctor> (list (ast;bool true)))) + (s;run (list (<ctor> (list (code;bool true)))) (<parser> s;bool))) - (fails? (s;run (list (<ctor> (list (ast;bool true) (ast;int 123)))) + (fails? (s;run (list (<ctor> (list (code;bool true) (code;int 123)))) (<parser> s;bool))) (match (#;Left true) - (s;run (list (<ctor> (list (ast;bool true)))) + (s;run (list (<ctor> (list (code;bool true)))) (<parser> (s;alt s;bool s;int)))) (match (#;Right 123) - (s;run (list (<ctor> (list (ast;int 123)))) + (s;run (list (<ctor> (list (code;int 123)))) (<parser> (s;alt s;bool s;int)))) - (fails? (s;run (list (<ctor> (list (ast;real 123.0)))) + (fails? (s;run (list (<ctor> (list (code;real 123.0)))) (<parser> (s;alt s;bool s;int))))))] - ["form" s;form ast;form] - ["tuple" s;tuple ast;tuple])] + ["form" s;form code;form] + ["tuple" s;tuple code;tuple])] ($_ seq <group-tests> (assert "Can parse record syntax." (match [true 123] - (s;run (list (ast;record (list [(ast;bool true) (ast;int 123)]))) + (s;run (list (code;record (list [(code;bool true) (code;int 123)]))) (s;record (s;seq s;bool s;int))))) ))) (test: "Assertions" (assert "Can make assertions while parsing." (and (match [] - (s;run (list (ast;bool true) (ast;int 123)) + (s;run (list (code;bool true) (code;int 123)) (s;assert "yolo" true))) - (fails? (s;run (list (ast;bool true) (ast;int 123)) + (fails? (s;run (list (code;bool true) (code;int 123)) (s;assert "yolo" false)))))) (test: "Combinators [Part 1]" ($_ seq - (assert "Can parse any AST." + (assert "Can parse any Code." (match [_ (#;Bool true)] - (s;run (list (ast;bool true) (ast;int 123)) + (s;run (list (code;bool true) (code;int 123)) s;any))) (assert "Can optionally succeed with some parser." (and (match (#;Some +123) - (s;run (list (ast;nat +123)) + (s;run (list (code;nat +123)) (s;opt s;nat))) (match #;None - (s;run (list (ast;int -123)) + (s;run (list (code;int -123)) (s;opt s;nat))))) (assert "Can apply a parser 0 or more times." (and (match (list +123 +456 +789) - (s;run (list (ast;nat +123) (ast;nat +456) (ast;nat +789)) + (s;run (list (code;nat +123) (code;nat +456) (code;nat +789)) (s;some s;nat))) (match (list) - (s;run (list (ast;int -123)) + (s;run (list (code;int -123)) (s;some s;nat))))) (assert "Can apply a parser 1 or more times." (and (match (list +123 +456 +789) - (s;run (list (ast;nat +123) (ast;nat +456) (ast;nat +789)) + (s;run (list (code;nat +123) (code;nat +456) (code;nat +789)) (s;many s;nat))) (match (list +123) - (s;run (list (ast;nat +123)) + (s;run (list (code;nat +123)) (s;many s;nat))) - (fails? (s;run (list (ast;int -123)) + (fails? (s;run (list (code;int -123)) (s;many s;nat))))) (assert "Can use either parser." (and (match 123 - (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;either s;pos-int s;int))) (match -123 - (s;run (list (ast;int -123) (ast;int 456) (ast;int 789)) + (s;run (list (code;int -123) (code;int 456) (code;int 789)) (s;either s;pos-int s;int))) - (fails? (s;run (list (ast;bool true) (ast;int 456) (ast;int 789)) + (fails? (s;run (list (code;bool true) (code;int 456) (code;int 789)) (s;either s;pos-int s;int))))) (assert "Can create the opposite/negation of any parser." - (and (fails? (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (and (fails? (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;not s;int))) (match [] - (s;run (list (ast;bool true) (ast;int 456) (ast;int 789)) + (s;run (list (code;bool true) (code;int 456) (code;int 789)) (s;not s;int))))) )) @@ -196,59 +196,59 @@ (s;run (list) s;end?)) (match false - (s;run (list (ast;bool true)) + (s;run (list (code;bool true)) s;end?)))) (assert "Can ensure the end has been reached." (and (match [] (s;run (list) s;end!)) - (fails? (s;run (list (ast;bool true)) + (fails? (s;run (list (code;bool true)) s;end!)))) (assert "Can apply a parser N times." (and (match (list 123 456 789) - (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;exactly +3 s;int))) (match (list 123 456) - (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;exactly +2 s;int))) - (fails? (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (fails? (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;exactly +4 s;int))))) (assert "Can apply a parser at-least N times." (and (match (list 123 456 789) - (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;at-least +3 s;int))) (match (list 123 456 789) - (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;at-least +2 s;int))) - (fails? (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (fails? (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;at-least +4 s;int))))) (assert "Can apply a parser at-most N times." (and (match (list 123 456 789) - (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;at-most +3 s;int))) (match (list 123 456) - (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;at-most +2 s;int))) (match (list 123 456 789) - (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;at-most +4 s;int))))) (assert "Can apply a parser between N and M times." (and (match (list 123 456 789) - (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;between +3 +10 s;int))) - (fails? (s;run (list (ast;int 123) (ast;int 456) (ast;int 789)) + (fails? (s;run (list (code;int 123) (code;int 456) (code;int 789)) (s;between +4 +10 s;int))))) (assert "Can parse while taking separators into account." (and (match (list 123 456 789) - (s;run (list (ast;int 123) (ast;text "YOLO") (ast;int 456) (ast;text "YOLO") (ast;int 789)) + (s;run (list (code;int 123) (code;text "YOLO") (code;int 456) (code;text "YOLO") (code;int 789)) (s;sep-by (s;this! (' "YOLO")) s;int))) (match (list 123 456) - (s;run (list (ast;int 123) (ast;text "YOLO") (ast;int 456) (ast;int 789)) + (s;run (list (code;int 123) (code;text "YOLO") (code;int 456) (code;int 789)) (s;sep-by (s;this! (' "YOLO")) s;int))))) )) diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux index 4cb00c4a7..2b24bd70e 100644 --- a/stdlib/test/tests.lux +++ b/stdlib/test/tests.lux @@ -15,12 +15,14 @@ ["_;" promise] ["_;" stm]) (control ["_;" effect] + ["_;" exception] ["_;" interval] ["_;" pipe] ["_;" cont] ["_;" reader] ["_;" state] - ["_;" thunk]) + ["_;" thunk] + ) (data ["_;" bit] ["_;" bool] ["_;" char] @@ -35,7 +37,6 @@ ["_;" product] ["_;" sum] ["_;" text] - (error ["_;" exception]) (format ["_;" json] ["_;" xml]) (coll ["_;" array] @@ -50,15 +51,17 @@ ["_;" zipper]) ["_;" seq] ["_;" priority-queue] - ["_;" stream]) + ["_;" stream] + ) (text ["_;" format] ["_;" lexer] - ["_;" regex])) + ["_;" regex]) + ) ["_;" math] (math ["_;" simple] (logic ["_;" continuous] ["_;" fuzzy])) - (macro ["_;" ast] + (macro ["_;" code] ["_;" syntax] (poly ["poly_;" eq] ["poly_;" text-encoder] @@ -66,7 +69,8 @@ ["_;" type] (type ["_;" check] ["_;" auto]) - )) + ) + ) (lux (control [contract]) (data [env] [trace] |