move test

This commit is contained in:
Aleksey Kladov 2021-10-09 14:45:52 +03:00
parent f4ee0d736c
commit 5ecda802f1
2 changed files with 23 additions and 21 deletions

View File

@ -180,6 +180,7 @@ macro_rules! m {
let _ = 1000;
let _ = 12E+99_f64;
let _ = "rust1";
let _ = -92;
}
}
fn f() {
@ -193,6 +194,7 @@ macro_rules! m {
let _ = 1000;
let _ = 12E+99_f64;
let _ = "rust1";
let _ = -92;
}
}
fn f() {
@ -200,6 +202,7 @@ fn f() {
let_ = 1000;
let_ = 12E+99_f64;
let_ = "rust1";
let_ = -92;
}
"#]],
);
@ -224,3 +227,23 @@ macro_rules! m2 { ($x:ident) => {} }
"#]],
)
}
#[test]
fn unary_minus_is_a_literal() {
check(
r#"
macro_rules! m { ($x:literal) => (literal!()); ($x:tt) => (not_a_literal!()); }
m!(92);
m!(-92);
m!(-9.2);
m!(--92);
"#,
expect![[r#"
macro_rules! m { ($x:literal) => (literal!()); ($x:tt) => (not_a_literal!()); }
literal!()
literal!()
literal!()
/* error: leftover tokens */not_a_literal!()
"#]],
)
}

View File

@ -181,24 +181,3 @@ fn convert_leaf(leaf: &tt::Leaf) -> TtToken {
tt::Leaf::Punct(punct) => convert_punct(*punct),
}
}
#[cfg(test)]
mod tests {
use super::{convert_literal, TtToken};
use parser::Token;
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 {
tt: Token { kind: SyntaxKind::FLOAT_NUMBER, is_jointed_to_next: false },
text: SmolStr::new("-42.0")
}
);
}
}