summaryrefslogtreecommitdiff
path: root/tests/parser
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-02-03 15:05:34 +0100
committerLaurenz <laurmaedje@gmail.com>2020-02-03 15:05:34 +0100
commitec60795575c29ee7fc2ea7507cfcc38958fe67bf (patch)
tree89c47763188e24d6c9ef7afd9148949716c6b277 /tests/parser
parent3150fd56437ecf8b2a5902c18e3f9ace800b768c (diff)
Port tests 🚁
Diffstat (limited to 'tests/parser')
-rw-r--r--tests/parser/tokens.rs77
-rw-r--r--tests/parser/trees.rs46
2 files changed, 0 insertions, 123 deletions
diff --git a/tests/parser/tokens.rs b/tests/parser/tokens.rs
deleted file mode 100644
index 66e44ac5..00000000
--- a/tests/parser/tokens.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-// Whitespace.
-t "" => []
-t " " => [S(0)]
-t " " => [S(0)]
-t "\t" => [S(0)]
-t " \t" => [S(0)]
-t "\n" => [S(1)]
-t "\n " => [S(1)]
-t " \n" => [S(1)]
-t " \n " => [S(1)]
-t " \n\t \n " => [S(2)]
-t "\r\n" => [S(1)]
-t " \r\r\n \x0D" => [S(3)]
-t "\n\r" => [S(2)]
-
-// Comments.
-t "a // bc\n " => [T("a"), S(0), LC(" bc"), S(1)]
-t "a //a//b\n " => [T("a"), S(0), LC("a//b"), S(1)]
-t "a //a//b\r\n" => [T("a"), S(0), LC("a//b"), S(1)]
-t "a //a//b\n\nhello" => [T("a"), S(0), LC("a//b"), S(2), T("hello")]
-t "/**/" => [BC("")]
-t "_/*_/*a*/*/" => [Underscore, BC("_/*a*/")]
-t "/*/*/" => [BC("/*/")]
-t "abc*/" => [T("abc"), Invalid("*/")]
-
-// Header only tokens.
-th "[" => [Func("", None, false)]
-th "]" => [Invalid("]")]
-th "(){}:=," => [LP, RP, LB, RB, Colon, Equals, Comma]
-th "a:b" => [Id("a"), Colon, Id("b")]
-th "=" => [Equals]
-th "," => [Comma]
-th r#""hello\"world""# => [Str(r#"hello\"world"#)]
-th r#""hi", 12pt"# => [Str("hi"), Comma, S(0), Size(12.0)]
-th "\"hi\"" => [T("\"hi"), T("\"")]
-th "a: true, x=1" => [Id("a"), Colon, S(0), Bool(true), Comma, S(0),
- Id("x"), Equals, Num(1.0)]
-th "120%" => [Num(1.2)]
-th "🌓, 🌍," => [T("🌓"), Comma, S(0), T("🌍"), Comma]
-tb "a: b" => [T("a"), T(":"), S(0), T("b")]
-tb "c=d, " => [T("c"), T("=d"), T(","), S(0)]
-
-// Body only tokens.
-tb "_*`" => [Underscore, Star, Backtick]
-tb "[func]*bold*" => [Func("func", None, true), Star, T("bold"), Star]
-tb "hi_you_ there" => [T("hi"), Underscore, T("you"), Underscore, S(0), T("there")]
-th "_*`" => [Invalid("_"), Invalid("*"), Invalid("`")]
-
-// Nested functions.
-tb "[f: [=][*]]" => [Func("f: [=][*]", None, true)]
-tb "[_][[,],]," => [Func("_", Some("[,],"), true), T(",")]
-tb "[=][=][=]" => [Func("=", Some("="), true), Func("=", None, true)]
-tb "[=][[=][=][=]]" => [Func("=", Some("[=][=][=]")), true]
-
-// Escapes.
-tb r"\[" => [T("[")]
-tb r"\]" => [T("]")]
-tb r"\\" => [T(r"\")]
-tb r"\/" => [T("/")]
-tb r"\*" => [T("*")]
-tb r"\_" => [T("_")]
-tb r"\`" => [T("`")]
-
-// Unescapable special symbols.
-th r"\:" => [T(r"\"), T(":")]
-th r"\=" => [T(r"\"), T("=")]
-th r"\:" => [T(r"\"), Colon]
-th r"\=" => [T(r"\"), Equals]
-th r"\," => [T(r"\"), Comma]
-
-// Spans.
-tbs "hello" => [(0:0, 0:5, T("hello"))]
-tbs "ab\r\nc" => [(0:0, 0:2, T("ab")), (0:2, 1:0, S(1)), (1:0, 1:1, T("c"))]
-tbs "[x = \"(1)\"]*" => [(0:0, 0:11, Func("x = \"(1)\"", None, true)), (0:11, 0:12, Star)]
-tbs "// ab\r\n\nf" => [(0:0, 0:5, LC(" ab")), (0:5, 2:0, S(2)), (2:0, 2:1, T("f"))]
-tbs "/*b*/_" => [(0:0, 0:5, BC("b")), (0:5, 0:6, Underscore)]
-ths "a=10" => [(0:0, 0:1, Id("a")), (0:1, 0:2, Equals), (0:2, 0:4, Num(10.0))]
diff --git a/tests/parser/trees.rs b/tests/parser/trees.rs
deleted file mode 100644
index d761fe24..00000000
--- a/tests/parser/trees.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Basics.
-p "" => []
-p "hi" => [T("hi")]
-p "hi you" => [T("hi"), S, T("you")]
-p "❤\n\n 🌍" => [T("❤"), N, T("🌍")]
-
-// Functions.
-p "[func]" => [func!("func"; None)]
-p "[tree][hi *you*]" => [func!("tree"; Some([T("hi"), S, B, T("you"), B]))]
-p "from [align: left] to" => [
- T("from"), S, func!("align", pos: [ID("left")]; None), S, T("to"),
-]
-p "[f: left, 12pt, false]" => [
- func!("f", pos: [ID("left"), SIZE(Size::pt(12.0)), BOOL(false)]; None)
-]
-p "[f: , hi, * \"du\"]" => [func!("f", pos: [ID("hi"), STR("du")]; None)]
-p "[box: x=1.2pt, false][a b c] bye" => [
- func!(
- "box",
- pos: [BOOL(false)],
- key: ["x" => SIZE(Size::pt(1.2))];
- Some([T("a"), S, T("b"), S, T("c")])
- ),
- S, T("bye"),
-]
-
-// Errors.
-e "[f: , hi, * \"du\"]" => [
- (0:4, 0:5, "expected value, found comma"),
- (0:10, 0:11, "expected value, found invalid identifier"),
-]
-e "[f:, , ,]" => [
- (0:3, 0:4, "expected value, found comma"),
- (0:5, 0:6, "expected value, found comma"),
- (0:7, 0:8, "expected value, found comma"),
-]
-e "[f:" => [(0:3, 0:3, "expected closing bracket")]
-e "[f: hi" => [(0:6, 0:6, "expected closing bracket")]
-e "[f: hey 12pt]" => [(0:7, 0:7, "expected comma")]
-e "[box: x=, false y=z=4" => [
- (0:8, 0:9, "expected value, found comma"),
- (0:15, 0:15, "expected comma"),
- (0:19, 0:19, "expected comma"),
- (0:19, 0:20, "expected value, found equals sign"),
- (0:21, 0:21, "expected closing bracket"),
-]