aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-05-15 23:36:50 -0700
committerHaibo Huang <hhb@google.com>2020-05-15 23:36:50 -0700
commit548c6a34835dd62b4f3dfee7b6a09194ad924bd6 (patch)
treeb2fe033e659be887071f4143958b76fabf563450 /tests
parent304b615e15a5f576a05a97708b502f0e83a417d0 (diff)
downloadsyn-548c6a34835dd62b4f3dfee7b6a09194ad924bd6.tar.gz
Upgrade rust/crates/syn to 1.0.22
Test: None Change-Id: Icb173886fa6b0ea21560d851ae40ca4897c27f4e
Diffstat (limited to 'tests')
-rw-r--r--tests/common/mod.rs9
-rw-r--r--tests/features/error.rs1
-rw-r--r--tests/features/mod.rs22
-rw-r--r--tests/test_asyncness.rs2
-rw-r--r--tests/test_attribute.rs2
-rw-r--r--tests/test_derive_input.rs2
-rw-r--r--tests/test_generics.rs2
-rw-r--r--tests/test_grouping.rs2
-rw-r--r--tests/test_ident.rs2
-rw-r--r--tests/test_iterators.rs2
-rw-r--r--tests/test_lit.rs32
-rw-r--r--tests/test_meta.rs2
-rw-r--r--tests/test_pat.rs2
-rw-r--r--tests/test_precedence.rs3
-rw-r--r--tests/test_receiver.rs2
-rw-r--r--tests/test_round_trip.rs3
-rw-r--r--tests/test_should_parse.rs2
-rw-r--r--tests/test_size.rs2
-rw-r--r--tests/test_token_trees.rs2
-rw-r--r--tests/test_visibility.rs2
20 files changed, 41 insertions, 57 deletions
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 8b784bee..1b0b23cc 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -1,5 +1,6 @@
#![allow(dead_code)]
+use rayon::ThreadPoolBuilder;
use std::env;
pub mod eq;
@@ -12,3 +13,11 @@ pub fn abort_after() -> usize {
Err(_) => usize::max_value(),
}
}
+
+/// Configure Rayon threadpool.
+pub fn rayon_init() {
+ ThreadPoolBuilder::new()
+ .stack_size(10 * 1024 * 1024)
+ .build_global()
+ .unwrap();
+}
diff --git a/tests/features/error.rs b/tests/features/error.rs
deleted file mode 100644
index 10ac8896..00000000
--- a/tests/features/error.rs
+++ /dev/null
@@ -1 +0,0 @@
-"Hello! You want: cargo test --release --all-features"
diff --git a/tests/features/mod.rs b/tests/features/mod.rs
deleted file mode 100644
index 83fbe13e..00000000
--- a/tests/features/mod.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-#[allow(unused_macros)]
-macro_rules! hide_from_rustfmt {
- ($mod:item) => {
- $mod
- };
-}
-
-#[cfg(not(all(
- feature = "derive",
- feature = "full",
- feature = "parsing",
- feature = "printing",
- feature = "visit",
- feature = "visit-mut",
- feature = "fold",
- feature = "clone-impls",
- feature = "extra-traits",
- feature = "proc-macro",
-)))]
-hide_from_rustfmt! {
- mod error;
-}
diff --git a/tests/test_asyncness.rs b/tests/test_asyncness.rs
index e09e816d..0efef597 100644
--- a/tests/test_asyncness.rs
+++ b/tests/test_asyncness.rs
@@ -1,5 +1,3 @@
-mod features;
-
#[macro_use]
mod macros;
diff --git a/tests/test_attribute.rs b/tests/test_attribute.rs
index e1b0142b..c26bd090 100644
--- a/tests/test_attribute.rs
+++ b/tests/test_attribute.rs
@@ -1,5 +1,3 @@
-mod features;
-
#[macro_use]
mod macros;
diff --git a/tests/test_derive_input.rs b/tests/test_derive_input.rs
index e3685aea..96563b7f 100644
--- a/tests/test_derive_input.rs
+++ b/tests/test_derive_input.rs
@@ -1,5 +1,3 @@
-mod features;
-
#[macro_use]
mod macros;
diff --git a/tests/test_generics.rs b/tests/test_generics.rs
index e863b779..9957c0e4 100644
--- a/tests/test_generics.rs
+++ b/tests/test_generics.rs
@@ -1,5 +1,3 @@
-mod features;
-
#[macro_use]
mod macros;
diff --git a/tests/test_grouping.rs b/tests/test_grouping.rs
index 4e43ab8a..c53ab346 100644
--- a/tests/test_grouping.rs
+++ b/tests/test_grouping.rs
@@ -1,5 +1,3 @@
-mod features;
-
#[macro_use]
mod macros;
diff --git a/tests/test_ident.rs b/tests/test_ident.rs
index 7578381e..ee01bfcc 100644
--- a/tests/test_ident.rs
+++ b/tests/test_ident.rs
@@ -1,5 +1,3 @@
-mod features;
-
use proc_macro2::{Ident, Span, TokenStream};
use std::str::FromStr;
use syn::Result;
diff --git a/tests/test_iterators.rs b/tests/test_iterators.rs
index f1072977..2c8359c1 100644
--- a/tests/test_iterators.rs
+++ b/tests/test_iterators.rs
@@ -1,8 +1,6 @@
use syn::punctuated::{Pair, Punctuated};
use syn::Token;
-mod features;
-
#[macro_use]
mod macros;
diff --git a/tests/test_lit.rs b/tests/test_lit.rs
index d4495ce4..7addc0fa 100644
--- a/tests/test_lit.rs
+++ b/tests/test_lit.rs
@@ -1,5 +1,3 @@
-mod features;
-
use proc_macro2::{Span, TokenStream, TokenTree};
use quote::ToTokens;
use std::str::FromStr;
@@ -46,6 +44,9 @@ fn strings() {
"contains\nnewlinesescaped newlines",
);
test_string("r\"raw\nstring\\\nhere\"", "raw\nstring\\\nhere");
+ test_string("\"...\"q", "...");
+ test_string("r\"...\"q", "...");
+ test_string("r##\"...\"##q", "...");
}
#[test]
@@ -75,6 +76,9 @@ fn byte_strings() {
b"contains\nnewlinesescaped newlines",
);
test_byte_string("br\"raw\nstring\\\nhere\"", b"raw\nstring\\\nhere");
+ test_byte_string("b\"...\"q", b"...");
+ test_byte_string("br\"...\"q", b"...");
+ test_byte_string("br##\"...\"##q", b"...");
}
#[test]
@@ -96,6 +100,7 @@ fn bytes() {
test_byte("b'\\t'", b'\t');
test_byte("b'\\''", b'\'');
test_byte("b'\"'", b'"');
+ test_byte("b'a'q", b'a');
}
#[test]
@@ -121,6 +126,7 @@ fn chars() {
test_char("'\\''", '\'');
test_char("'\"'", '"');
test_char("'\\u{1F415}'", '\u{1F415}');
+ test_char("'a'q", 'a');
}
#[test]
@@ -195,3 +201,25 @@ fn negative() {
assert_eq!("-1.5f32", LitFloat::new("-1.5f32", span).to_string());
assert_eq!("-1.5f64", LitFloat::new("-1.5f64", span).to_string());
}
+
+#[test]
+fn suffix() {
+ fn get_suffix(token: &str) -> String {
+ let lit = syn::parse_str::<Lit>(token).unwrap();
+ match lit {
+ Lit::Str(lit) => lit.suffix().to_owned(),
+ Lit::ByteStr(lit) => lit.suffix().to_owned(),
+ Lit::Byte(lit) => lit.suffix().to_owned(),
+ Lit::Char(lit) => lit.suffix().to_owned(),
+ _ => unimplemented!(),
+ }
+ }
+
+ assert_eq!(get_suffix("\"\"s"), "s");
+ assert_eq!(get_suffix("r\"\"r"), "r");
+ assert_eq!(get_suffix("b\"\"b"), "b");
+ assert_eq!(get_suffix("br\"\"br"), "br");
+ assert_eq!(get_suffix("r#\"\"#r"), "r");
+ assert_eq!(get_suffix("'c'c"), "c");
+ assert_eq!(get_suffix("b'b'b"), "b");
+}
diff --git a/tests/test_meta.rs b/tests/test_meta.rs
index 618296e2..d37dda94 100644
--- a/tests/test_meta.rs
+++ b/tests/test_meta.rs
@@ -1,5 +1,3 @@
-mod features;
-
#[macro_use]
mod macros;
diff --git a/tests/test_pat.rs b/tests/test_pat.rs
index cce4b809..8cba735f 100644
--- a/tests/test_pat.rs
+++ b/tests/test_pat.rs
@@ -1,5 +1,3 @@
-mod features;
-
use quote::quote;
use syn::Pat;
diff --git a/tests/test_precedence.rs b/tests/test_precedence.rs
index 0841f7cd..08d3c1e0 100644
--- a/tests/test_precedence.rs
+++ b/tests/test_precedence.rs
@@ -18,8 +18,6 @@ extern crate rustc_ast;
extern crate rustc_data_structures;
extern crate rustc_span;
-mod features;
-
use quote::quote;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use regex::Regex;
@@ -85,6 +83,7 @@ fn test_simple_precedence() {
/// Test expressions from rustc, like in `test_round_trip`.
#[test]
fn test_rustc_precedence() {
+ common::rayon_init();
repo::clone_rust();
let abort_after = common::abort_after();
if abort_after == 0 {
diff --git a/tests/test_receiver.rs b/tests/test_receiver.rs
index 7169891e..923df96b 100644
--- a/tests/test_receiver.rs
+++ b/tests/test_receiver.rs
@@ -1,5 +1,3 @@
-mod features;
-
use syn::{parse_quote, FnArg, Receiver, TraitItemMethod};
#[test]
diff --git a/tests/test_round_trip.rs b/tests/test_round_trip.rs
index d4f525b1..4dde5f25 100644
--- a/tests/test_round_trip.rs
+++ b/tests/test_round_trip.rs
@@ -9,8 +9,6 @@ extern crate rustc_parse as parse;
extern crate rustc_session;
extern crate rustc_span;
-mod features;
-
use quote::quote;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use rustc_ast::ast;
@@ -40,6 +38,7 @@ use common::eq::SpanlessEq;
#[test]
fn test_round_trip() {
+ common::rayon_init();
repo::clone_rust();
let abort_after = common::abort_after();
if abort_after == 0 {
diff --git a/tests/test_should_parse.rs b/tests/test_should_parse.rs
index d4f7ac34..180d8599 100644
--- a/tests/test_should_parse.rs
+++ b/tests/test_should_parse.rs
@@ -1,5 +1,3 @@
-mod features;
-
macro_rules! should_parse {
($name:ident, { $($in:tt)* }) => {
#[test]
diff --git a/tests/test_size.rs b/tests/test_size.rs
index 386d4df8..01e84011 100644
--- a/tests/test_size.rs
+++ b/tests/test_size.rs
@@ -1,7 +1,5 @@
#![cfg(target_pointer_width = "64")]
-mod features;
-
use std::mem;
use syn::*;
diff --git a/tests/test_token_trees.rs b/tests/test_token_trees.rs
index 5d7610bb..75c7e40c 100644
--- a/tests/test_token_trees.rs
+++ b/tests/test_token_trees.rs
@@ -1,5 +1,3 @@
-mod features;
-
#[macro_use]
mod macros;
diff --git a/tests/test_visibility.rs b/tests/test_visibility.rs
index 21c49c99..21f9adf2 100644
--- a/tests/test_visibility.rs
+++ b/tests/test_visibility.rs
@@ -1,5 +1,3 @@
-mod features;
-
use proc_macro2::TokenStream;
use syn::parse::{Parse, ParseStream};
use syn::{Result, Visibility};