Skip to content

Commit 27798ee

Browse files
committed
Added unit test for negative number literals in macros.
1 parent 8cf9362 commit 27798ee

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crates/mbe/src/subtree_source.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,24 @@ fn convert_leaf(leaf: &tt::Leaf) -> TtToken {
202202
tt::Leaf::Punct(punct) => convert_punct(*punct),
203203
}
204204
}
205+
206+
#[cfg(test)]
207+
mod tests {
208+
use super::{convert_literal, TtToken};
209+
use syntax::{SmolStr, SyntaxKind};
210+
211+
#[test]
212+
fn test_negative_literal() {
213+
assert_eq!(
214+
convert_literal(&tt::Literal {
215+
id: tt::TokenId::unspecified(),
216+
text: SmolStr::new("-42.0")
217+
}),
218+
TtToken {
219+
kind: SyntaxKind::FLOAT_NUMBER,
220+
is_joint_to_next: false,
221+
text: SmolStr::new("-42.0")
222+
}
223+
);
224+
}
225+
}

0 commit comments

Comments
 (0)