Also emit TokenKind in debug

Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
Marcel Müller 2026-03-08 20:05:54 +01:00
parent 13eb4ca1d0
commit 08b480705b
14 changed files with 205 additions and 205 deletions

View file

@ -254,7 +254,7 @@ pub struct TemplateToken {
impl std::fmt::Debug for TemplateToken {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.source())
write!(f, "[{:?}]{:?}", self.kind(), self.source())
}
}
@ -495,7 +495,7 @@ mod tests {
Ok(
ParsedTemplate {
tokens: [
"Hello There" (0..11),
[Content]"Hello There" (0..11),
],
},
)
@ -511,13 +511,13 @@ mod tests {
Ok(
ParsedTemplate {
tokens: [
"Hello" (0..5),
" " (5..6),
"{{" (6..8),
" " (8..9),
"there" (9..14),
" " (14..15),
"}}" (15..17),
[Content]"Hello" (0..5),
[Whitespace]" " (5..6),
[LeftDelim]"{{" (6..8),
[Whitespace]" " (8..9),
[Ident]"there" (9..14),
[Whitespace]" " (14..15),
[RightDelim]"}}" (15..17),
],
},
)
@ -567,29 +567,29 @@ mod tests {
Ok(
ParsedTemplate {
tokens: [
"{{" (0..2),
" " (2..3),
"if" (3..5),
" " (5..6),
"true" (6..10),
" " (10..11),
"}}" (11..13),
" " (13..14),
"Hello!" (14..20),
" " (20..21),
"{{" (21..23),
" " (23..24),
"else" (24..28),
" " (28..29),
"}}" (29..31),
" " (31..32),
"Bye" (32..35),
" " (35..36),
"{{" (36..38),
" " (38..39),
"end" (39..42),
" " (42..43),
"}}" (43..45),
[LeftDelim]"{{" (0..2),
[Whitespace]" " (2..3),
[ConditionalIf]"if" (3..5),
[Whitespace]" " (5..6),
[Literal(Bool(true))]"true" (6..10),
[Whitespace]" " (10..11),
[RightDelim]"}}" (11..13),
[Whitespace]" " (13..14),
[Content]"Hello!" (14..20),
[Whitespace]" " (20..21),
[LeftDelim]"{{" (21..23),
[Whitespace]" " (23..24),
[ConditionalElse]"else" (24..28),
[Whitespace]" " (28..29),
[RightDelim]"}}" (29..31),
[Whitespace]" " (31..32),
[Content]"Bye" (32..35),
[Whitespace]" " (35..36),
[LeftDelim]"{{" (36..38),
[Whitespace]" " (38..39),
[End]"end" (39..42),
[Whitespace]" " (42..43),
[RightDelim]"}}" (43..45),
],
},
)