Skip to content

Commit

Permalink
(test) add assertion for error message
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed May 3, 2021
1 parent 0b87103 commit 6534e67
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl Parameter {
Template::parse_param(s, &mut it, s.len() - 1)
}

fn into_debug_name(&self) -> String {
fn debug_name(&self) -> String {
if let Some(name) = self.as_name() {
name.to_owned()
} else {
Expand Down Expand Up @@ -645,8 +645,8 @@ impl Template {
} else {
return Err(TemplateError::of(
TemplateErrorReason::MismatchingClosedHelper(
h.name.into_debug_name(),
exp.name.into_debug_name(),
h.name.debug_name(),
exp.name.debug_name(),
),
)
.at(source, line_no, col_no));
Expand All @@ -667,8 +667,8 @@ impl Template {
} else {
return Err(TemplateError::of(
TemplateErrorReason::MismatchingClosedDecorator(
d.name.into_debug_name(),
exp.name.into_debug_name(),
d.name.debug_name(),
exp.name.debug_name(),
),
)
.at(source, line_no, col_no));
Expand Down Expand Up @@ -1144,5 +1144,7 @@ fn test_decorator() {
#[test]
fn test_panic_with_tag_name() {
let s = "{{#>(X)}}{{/X}}";
assert!(Template::compile(s).is_err());
let result = Template::compile(s);
assert!(result.is_err());
assert_eq!("decorator \"Subexpression(Subexpression { element: Expression(HelperTemplate { name: Path(Relative(([Named(\\\"X\\\")], \\\"X\\\"))), params: [], hash: {}, block_param: None, template: None, inverse: None, block: false }) })\" was opened, but \"X\" is closing", format!("{}", result.unwrap_err().reason));
}

0 comments on commit 6534e67

Please sign in to comment.