From 27798ee575a975a1806ced86aca8aea407897851 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 6 Oct 2020 22:11:18 +0200 Subject: Added unit test for negative number literals in macros. --- crates/mbe/src/subtree_source.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'crates/mbe/src') diff --git a/crates/mbe/src/subtree_source.rs b/crates/mbe/src/subtree_source.rs index 8941da0f1..226dc3bec 100644 --- a/crates/mbe/src/subtree_source.rs +++ b/crates/mbe/src/subtree_source.rs @@ -202,3 +202,24 @@ fn convert_leaf(leaf: &tt::Leaf) -> TtToken { tt::Leaf::Punct(punct) => convert_punct(*punct), } } + +#[cfg(test)] +mod tests { + use super::{convert_literal, TtToken}; + use syntax::{SmolStr, SyntaxKind}; + + #[test] + fn test_negative_literal() { + assert_eq!( + convert_literal(&tt::Literal { + id: tt::TokenId::unspecified(), + text: SmolStr::new("-42.0") + }), + TtToken { + kind: SyntaxKind::FLOAT_NUMBER, + is_joint_to_next: false, + text: SmolStr::new("-42.0") + } + ); + } +} -- cgit v1.2.3