diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-01-14 17:28:03 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-01-14 17:30:22 +0100 |
| commit | 73b25bdad0f0dda66f0a73c8b980e0ddb1a59553 (patch) | |
| tree | 307561099ae30c19a1a7515c0d3b65baed265b5e /src/parse | |
| parent | cfcb36b159e3f65aff8cbdac6b537b40c22507c0 (diff) | |
Move bracket function tests to integration 🚚
Diffstat (limited to 'src/parse')
| -rw-r--r-- | src/parse/tests.rs | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/src/parse/tests.rs b/src/parse/tests.rs index bb102476..c87d43f7 100644 --- a/src/parse/tests.rs +++ b/src/parse/tests.rs @@ -262,128 +262,6 @@ fn test_parse_blocks() { } #[test] -fn test_parse_bracket_funcs() { - // Basic. - t!("[function]" Call!("function")); - t!("[ v ]" Call!("v")); - - // Body and no body. - t!("[v][[f]]" Call!("v", Args![Template![Call!("f")]])); - t!("[v][v][v]" Call!("v", Args![Template![Text("v")]]), Call!("v")); - t!("[v] [f]" Call!("v"), Space, Call!("f")); - - // Spans. - t!("[v 1][📐]" - nodes: [S(0..11, Call!(S(1..2, "v"), S(3..4, Args![ - S(3..4, Int(1)), - S(5..11, Template![S(6..10, Text("📐"))]), - ])))], - spans: true); - - // No name and no closing bracket. - t!("[" - nodes: [Call!("")], - errors: [S(1..1, "expected function name"), - S(1..1, "expected closing bracket")]); - - // No name. - t!("[]" - nodes: [Call!("")], - errors: [S(1..1, "expected function name")]); - - // Bad name. - t!("[# 1]" - nodes: [Call!("", Args![Int(1)])], - errors: [S(1..2, "expected function name, found hex value")]); - - // String in header eats closing bracket. - t!(r#"[v "]"# - nodes: [Call!("v", Args![Str("]")])], - errors: [S(5..5, "expected quote"), - S(5..5, "expected closing bracket")]); - - // Raw in body eats closing bracket. - t!("[v][`a]`" - nodes: [Call!("v", Args![Template![Raw(None, &["a]"], true)]])], - errors: [S(8..8, "expected closing bracket")]); -} - -#[test] -fn test_parse_chaining() { - // Basic. - t!("[a | b]" Call!("a", Args![Template![Call!("b")]])); - t!("[a|b|c]" Call!("a", Args![Template![ - Call!("b", Args![Template![Call!("c")]]) - ]])); - - // With body and spans. - t!("[a|b][💕]" - nodes: [S(0..11, Call!(S(1..2, "a"), S(2..2, Args![ - S(3..11, Template![S(3..11, Call!(S(3..4, "b"), S(4..4, Args![ - S(5..11, Template![S(6..10, Text("💕"))]) - ])))]) - ])))], - spans: true); - - // No name in second subheader. - t!("[a 1|]" - nodes: [Call!("a", Args![Int(1), Template![Call!("")]])], - errors: [S(5..5, "expected function name")]); - - // No name in first subheader. - t!("[|a true]" - nodes: [Call!("", Args![Template![Call!("a", Args![Bool(true)])]])], - errors: [S(1..1, "expected function name")]); -} - -#[test] -fn test_parse_arguments() { - // Bracket functions. - t!("[v a]" Call!("v", Args![Id("a")])); - t!("[v 1,]" Call!("v", Args![Int(1)])); - t!("[v a:2]" Call!("v", Args!["a" => Int(2)])); - - // Parenthesized function with nested array literal. - t!(r#"{f(1, a: (2, 3), #004, b: "five")}"# Block!(Call!(@"f", Args![ - Int(1), - "a" => Array![Int(2), Int(3)], - Color(RgbaColor::new(0, 0, 0x44, 0xff)), - "b" => Str("five"), - ]))); - - // Bad expression. - t!("[v */]" - nodes: [Call!("v", Args![])], - errors: [S(3..5, "expected expression, found end of block comment")]); - - // Bad expression. - t!("[v a:1:]" - nodes: [Call!("v", Args!["a" => Int(1)])], - errors: [S(6..7, "expected expression, found colon")]); - - // Missing comma between arguments. - t!("[v 1 2]" - nodes: [Call!("v", Args![Int(1), Int(2)])], - errors: [S(4..4, "expected comma")]); - - // Name has to be identifier. - t!("[v 1:]" - nodes: [Call!("v", Args![])], - errors: [S(3..4, "expected identifier"), - S(5..5, "expected expression")]); - - // Name has to be identifier. - t!("[v 1:2]" - nodes: [Call!("v", Args![])], - errors: [S(3..4, "expected identifier")]); - - // Name has to be identifier. - t!("[v (x):1]" - nodes: [Call!("v", Args![])], - errors: [S(3..6, "expected identifier")]); -} - -#[test] fn test_parse_expressions() { // Parentheses. t!("{(x)}{(1)}" Block!(Group(Id("x"))), Block!(Group(Int(1)))); |
