aboutsummaryrefslogtreecommitdiff
path: root/tests/test.rs
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-06-01 18:03:45 -0700
committerHaibo Huang <hhb@google.com>2020-06-01 18:03:45 -0700
commitacb37241b70393c39d0dfcc569df9d0c0a78ff8e (patch)
treedf51dc823d773d80c6c78c527dd2b8c403a4d66c /tests/test.rs
parentd821995c2c98e720a41476932b436209506abc51 (diff)
downloadproc-macro2-acb37241b70393c39d0dfcc569df9d0c0a78ff8e.tar.gz
Upgrade rust/crates/proc-macro2 to 1.0.18
Change-Id: I2e474c5ade42619065e92227367d0588a936c43c
Diffstat (limited to 'tests/test.rs')
-rw-r--r--tests/test.rs35
1 files changed, 28 insertions, 7 deletions
diff --git a/tests/test.rs b/tests/test.rs
index a0133f6..8bd6bf9 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -118,6 +118,27 @@ fn literal_suffix() {
}
#[test]
+fn literal_iter_negative() {
+ let negative_literal = Literal::i32_suffixed(-3);
+ let tokens = TokenStream::from(TokenTree::Literal(negative_literal));
+ let mut iter = tokens.into_iter();
+ match iter.next().unwrap() {
+ TokenTree::Punct(punct) => {
+ assert_eq!(punct.as_char(), '-');
+ assert_eq!(punct.spacing(), Spacing::Alone);
+ }
+ unexpected => panic!("unexpected token {:?}", unexpected),
+ }
+ match iter.next().unwrap() {
+ TokenTree::Literal(literal) => {
+ assert_eq!(literal.to_string(), "3i32");
+ }
+ unexpected => panic!("unexpected token {:?}", unexpected),
+ }
+ assert!(iter.next().is_none());
+}
+
+#[test]
fn roundtrip() {
fn roundtrip(p: &str) {
println!("parse: {}", p);
@@ -278,11 +299,11 @@ fn raw_identifier() {
fn test_debug_ident() {
let ident = Ident::new("proc_macro", Span::call_site());
- #[cfg(not(procmacro2_semver_exempt))]
+ #[cfg(not(span_locations))]
let expected = "Ident(proc_macro)";
- #[cfg(procmacro2_semver_exempt)]
- let expected = "Ident { sym: proc_macro, span: bytes(0..0) }";
+ #[cfg(span_locations)]
+ let expected = "Ident { sym: proc_macro }";
assert_eq!(expected, format!("{:?}", ident));
}
@@ -291,7 +312,7 @@ fn test_debug_ident() {
fn test_debug_tokenstream() {
let tts = TokenStream::from_str("[a + 1]").unwrap();
- #[cfg(not(procmacro2_semver_exempt))]
+ #[cfg(not(span_locations))]
let expected = "\
TokenStream [
Group {
@@ -312,7 +333,7 @@ TokenStream [
]\
";
- #[cfg(not(procmacro2_semver_exempt))]
+ #[cfg(not(span_locations))]
let expected_before_trailing_commas = "\
TokenStream [
Group {
@@ -333,7 +354,7 @@ TokenStream [
]\
";
- #[cfg(procmacro2_semver_exempt)]
+ #[cfg(span_locations)]
let expected = "\
TokenStream [
Group {
@@ -358,7 +379,7 @@ TokenStream [
]\
";
- #[cfg(procmacro2_semver_exempt)]
+ #[cfg(span_locations)]
let expected_before_trailing_commas = "\
TokenStream [
Group {