Skip to content

Commit

Permalink
Move passing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kijewski committed Jun 28, 2024
1 parent e84e1a6 commit cf4f514
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 22 deletions.
37 changes: 37 additions & 0 deletions testing/tests/let_destructoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,40 @@ fn test_has_rest_pattern() {
};
assert_eq!(t.render().unwrap(), "hello 0hello 1hello 0");
}

struct X {
a: u32,
b: u32,
}

#[derive(Template)]
#[template(source = "
{%- if let X { a, .. } = x -%}hello {{ a }}{%- endif -%}
", ext = "html")]
struct T1 {
x: X,
}

#[test]
fn test_t1() {
let t = T1 {
x: X { a: 1, b: 2 },
};
assert_eq!(t.render().unwrap(), "hello 1");
}

#[derive(Template)]
#[template(source = "
{%- if let X { .. } = x -%}hello{%- endif -%}
", ext = "html")]
struct T2 {
x: X,
}

#[test]
fn test_t2() {
let t = T2 {
x: X { a: 1, b: 2 },
};
assert_eq!(t.render().unwrap(), "hello");
}
14 changes: 3 additions & 11 deletions testing/tests/ui/let_destructuring_has_rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,26 @@ struct X {

#[derive(Template)]
#[template(source = "
{%- if let X { a, .. } = x -%}hello {{ a }}{%- endif -%}
{%- if let X { a, .., } = x -%}hello {{ a }}{%- endif -%}
", ext = "html")]
struct T1 {
x: X,
}

#[derive(Template)]
#[template(source = "
{%- if let X { a, .., } = x -%}hello {{ a }}{%- endif -%}
{%- if let X { a .. } = x -%}hello {{ a }}{%- endif -%}
", ext = "html")]
struct T2 {
x: X,
}

#[derive(Template)]
#[template(source = "
{%- if let X { a .. } = x -%}hello {{ a }}{%- endif -%}
{%- if let X { a, 1 } = x -%}hello {{ a }}{%- endif -%}
", ext = "html")]
struct T3 {
x: X,
}

#[derive(Template)]
#[template(source = "
{%- if let X { .. } = x -%}hello {{ a }}{%- endif -%}
", ext = "html")]
struct T4 {
x: X,
}

fn main() {}
24 changes: 13 additions & 11 deletions testing/tests/ui/let_destructuring_has_rest.stderr
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
error: unexpected `,` character after `..`
failed to parse template source at row 2, column 20 near:
", } = x -%}hello {{ a }}{%- endif -%}\n"
--> tests/ui/let_destructuring_has_rest.rs:8:10
|
8 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected `,` for more members, or `}` as terminator
failed to parse template source at row 2, column 17 near:
".. } = x -%}hello {{ a }}{%- endif -%}\n"
--> tests/ui/let_destructuring_has_rest.rs:16:10
|
16 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected `,` for more members, or `}` as terminator
failed to parse template source at row 2, column 17 near:
".. } = x -%}hello {{ a }}{%- endif -%}\n"
error: expected member, or `}` as terminator
failed to parse template source at row 2, column 18 near:
"1 } = x -%}hello {{ a }}{%- endif -%}\n"
--> tests/ui/let_destructuring_has_rest.rs:24:10
|
24 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0609]: no field `a` on type `&T4`
--> tests/ui/let_destructuring_has_rest.rs:32:10
|
32 | #[derive(Template)]
| ^^^^^^^^ unknown field
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

0 comments on commit cf4f514

Please sign in to comment.