Skip to content

Commit

Permalink
Update tests to API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed May 17, 2019
1 parent e3fe4cf commit f62c5cc
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 46 deletions.
10 changes: 5 additions & 5 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2739,7 +2739,7 @@ mod tests {
// When the user supplies --test we should implicitly supply --cfg test
#[test]
fn test_switch_implies_cfg_test() {
syntax::with_globals(|| {
syntax::with_globals(&[], || {
let matches = &match optgroups().parse(&["--test".to_string()]) {
Ok(m) => m,
Err(f) => panic!("test_switch_implies_cfg_test: {}", f),
Expand All @@ -2757,7 +2757,7 @@ mod tests {
#[test]
fn test_switch_implies_cfg_test_unless_cfg_test() {
use syntax::symbol::sym;
syntax::with_globals(|| {
syntax::with_globals(&[], || {
let matches = &match optgroups().parse(&["--test".to_string(),
"--cfg=test".to_string()]) {
Ok(m) => m,
Expand All @@ -2775,15 +2775,15 @@ mod tests {

#[test]
fn test_can_print_warnings() {
syntax::with_globals(|| {
syntax::with_globals(&[], || {
let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
let registry = errors::registry::Registry::new(&[]);
let (sessopts, _) = build_session_options_and_crate_config(&matches);
let sess = build_session(sessopts, None, registry);
assert!(!sess.diagnostic().flags.can_emit_warnings);
});

syntax::with_globals(|| {
syntax::with_globals(&[], || {
let matches = optgroups()
.parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()])
.unwrap();
Expand All @@ -2793,7 +2793,7 @@ mod tests {
assert!(sess.diagnostic().flags.can_emit_warnings);
});

syntax::with_globals(|| {
syntax::with_globals(&[], || {
let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
let registry = errors::registry::Registry::new(&[]);
let (sessopts, _) = build_session_options_and_crate_config(&matches);
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ mod tests {

// make sure idents get transformed everywhere
#[test] fn ident_transformation () {
with_globals(|| {
with_globals(&[], || {
let mut zz_visitor = ToZzIdentMutVisitor;
let mut krate = string_to_crate(
"#[a] mod b {fn c (d : e, f : g) {h!(i,j,k);l;m}}".to_string());
Expand All @@ -1358,7 +1358,7 @@ mod tests {

// even inside macro defs....
#[test] fn ident_transformation_in_defs () {
with_globals(|| {
with_globals(&[], || {
let mut zz_visitor = ToZzIdentMutVisitor;
let mut krate = string_to_crate(
"macro_rules! a {(b $c:expr $(d $e:token)f+ => \
Expand Down
26 changes: 13 additions & 13 deletions src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ mod tests {

#[test]
fn t1() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
let mut string_reader = setup(&sm,
Expand Down Expand Up @@ -1649,7 +1649,7 @@ mod tests {

#[test]
fn doublecolonparsing() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(setup(&sm, &sh, "a b".to_string()),
Expand All @@ -1659,7 +1659,7 @@ mod tests {

#[test]
fn dcparsing_2() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(setup(&sm, &sh, "a::b".to_string()),
Expand All @@ -1669,7 +1669,7 @@ mod tests {

#[test]
fn dcparsing_3() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(setup(&sm, &sh, "a ::b".to_string()),
Expand All @@ -1679,7 +1679,7 @@ mod tests {

#[test]
fn dcparsing_4() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(setup(&sm, &sh, "a:: b".to_string()),
Expand All @@ -1689,7 +1689,7 @@ mod tests {

#[test]
fn character_a() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "'a'".to_string()).next_token().tok,
Expand All @@ -1699,7 +1699,7 @@ mod tests {

#[test]
fn character_space() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "' '".to_string()).next_token().tok,
Expand All @@ -1709,7 +1709,7 @@ mod tests {

#[test]
fn character_escaped() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "'\\n'".to_string()).next_token().tok,
Expand All @@ -1719,7 +1719,7 @@ mod tests {

#[test]
fn lifetime_name() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "'abc".to_string()).next_token().tok,
Expand All @@ -1729,7 +1729,7 @@ mod tests {

#[test]
fn raw_string() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string())
Expand All @@ -1741,7 +1741,7 @@ mod tests {

#[test]
fn literal_suffixes() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
macro_rules! test {
Expand Down Expand Up @@ -1787,7 +1787,7 @@ mod tests {

#[test]
fn nested_block_comments() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
let mut lexer = setup(&sm, &sh, "/* /* */ */'a'".to_string());
Expand All @@ -1802,7 +1802,7 @@ mod tests {

#[test]
fn crlf_comments() {
with_globals(|| {
with_globals(&[], || {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
let mut lexer = setup(&sm, &sh, "// test\r\n/// test\r\n".to_string());
Expand Down
22 changes: 11 additions & 11 deletions src/libsyntax/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,15 @@ mod tests {

#[should_panic]
#[test] fn bad_path_expr_1() {
with_globals(|| {
with_globals(&[], || {
string_to_expr("::abc::def::return".to_string());
})
}

// check the token-tree-ization of macros
#[test]
fn string_to_tts_macro () {
with_globals(|| {
with_globals(&[], || {
use crate::symbol::sym;

let tts: Vec<_> =
Expand Down Expand Up @@ -447,7 +447,7 @@ mod tests {

#[test]
fn string_to_tts_1() {
with_globals(|| {
with_globals(&[], || {
let tts = string_to_stream("fn a (b : i32) { b; }".to_string());

let expected = TokenStream::new(vec![
Expand Down Expand Up @@ -480,7 +480,7 @@ mod tests {
}

#[test] fn parse_use() {
with_globals(|| {
with_globals(&[], || {
let use_s = "use foo::bar::baz;";
let vitem = string_to_item(use_s.to_string()).unwrap();
let vitem_s = item_to_string(&vitem);
Expand All @@ -494,7 +494,7 @@ mod tests {
}

#[test] fn parse_extern_crate() {
with_globals(|| {
with_globals(&[], || {
let ex_s = "extern crate foo;";
let vitem = string_to_item(ex_s.to_string()).unwrap();
let vitem_s = item_to_string(&vitem);
Expand Down Expand Up @@ -531,7 +531,7 @@ mod tests {
}

#[test] fn span_of_self_arg_pat_idents_are_correct() {
with_globals(|| {
with_globals(&[], || {

let srcs = ["impl z { fn a (&self, &myarg: i32) {} }",
"impl z { fn a (&mut self, &myarg: i32) {} }",
Expand All @@ -551,15 +551,15 @@ mod tests {
}

#[test] fn parse_exprs () {
with_globals(|| {
with_globals(&[], || {
// just make sure that they parse....
string_to_expr("3 + 4".to_string());
string_to_expr("a::z.froob(b,&(987+3))".to_string());
})
}

#[test] fn attrs_fix_bug () {
with_globals(|| {
with_globals(&[], || {
string_to_item("pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
-> Result<Box<Writer>, String> {
#[cfg(windows)]
Expand All @@ -576,7 +576,7 @@ mod tests {
}

#[test] fn crlf_doc_comments() {
with_globals(|| {
with_globals(&[], || {
use crate::symbol::sym;

let sess = ParseSess::new(FilePathMapping::empty());
Expand Down Expand Up @@ -613,7 +613,7 @@ mod tests {
new_parser_from_source_str(sess, name, source).parse_expr()
}

with_globals(|| {
with_globals(&[], || {
let sess = ParseSess::new(FilePathMapping::empty());
let expr = parse_expr_from_source_str(PathBuf::from("foo").into(),
"foo!( fn main() { body } )".to_string(), &sess).unwrap();
Expand All @@ -637,7 +637,7 @@ mod tests {
// See `recurse_into_file_modules` in the parser.
#[test]
fn out_of_line_mod() {
with_globals(|| {
with_globals(&[], || {
let sess = ParseSess::new(FilePathMapping::empty());
let item = parse_item_from_source_str(
PathBuf::from("foo").into(),
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3151,7 +3151,7 @@ mod tests {

#[test]
fn test_fun_to_string() {
with_globals(|| {
with_globals(&[], || {
let abba_ident = ast::Ident::from_str("abba");

let decl = ast::FnDecl {
Expand Down Expand Up @@ -3179,7 +3179,7 @@ mod tests {

#[test]
fn test_variant_to_string() {
with_globals(|| {
with_globals(&[], || {
let ident = ast::Ident::from_str("principal_skinner");

let var = source_map::respan(syntax_pos::DUMMY_SP, ast::Variant_ {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/test_snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<T: Write> Write for Shared<T> {
}

fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &str) {
with_globals(|| {
with_globals(&[], || {
let output = Arc::new(Mutex::new(Vec::new()));

let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
Expand Down
16 changes: 8 additions & 8 deletions src/libsyntax/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ mod tests {

#[test]
fn test_concat() {
with_globals(|| {
with_globals(&[], || {
let test_res = string_to_ts("foo::bar::baz");
let test_fst = string_to_ts("foo::bar");
let test_snd = string_to_ts("::baz");
Expand All @@ -585,7 +585,7 @@ mod tests {

#[test]
fn test_to_from_bijection() {
with_globals(|| {
with_globals(&[], || {
let test_start = string_to_ts("foo::bar(baz)");
let test_end = test_start.trees().collect();
assert_eq!(test_start, test_end)
Expand All @@ -594,7 +594,7 @@ mod tests {

#[test]
fn test_eq_0() {
with_globals(|| {
with_globals(&[], || {
let test_res = string_to_ts("foo");
let test_eqs = string_to_ts("foo");
assert_eq!(test_res, test_eqs)
Expand All @@ -603,7 +603,7 @@ mod tests {

#[test]
fn test_eq_1() {
with_globals(|| {
with_globals(&[], || {
let test_res = string_to_ts("::bar::baz");
let test_eqs = string_to_ts("::bar::baz");
assert_eq!(test_res, test_eqs)
Expand All @@ -612,7 +612,7 @@ mod tests {

#[test]
fn test_eq_3() {
with_globals(|| {
with_globals(&[], || {
let test_res = string_to_ts("");
let test_eqs = string_to_ts("");
assert_eq!(test_res, test_eqs)
Expand All @@ -621,7 +621,7 @@ mod tests {

#[test]
fn test_diseq_0() {
with_globals(|| {
with_globals(&[], || {
let test_res = string_to_ts("::bar::baz");
let test_eqs = string_to_ts("bar::baz");
assert_eq!(test_res == test_eqs, false)
Expand All @@ -630,7 +630,7 @@ mod tests {

#[test]
fn test_diseq_1() {
with_globals(|| {
with_globals(&[], || {
let test_res = string_to_ts("(bar,baz)");
let test_eqs = string_to_ts("bar,baz");
assert_eq!(test_res == test_eqs, false)
Expand All @@ -639,7 +639,7 @@ mod tests {

#[test]
fn test_is_empty() {
with_globals(|| {
with_globals(&[], || {
let test0: TokenStream = Vec::<TokenTree>::new().into_iter().collect();
let test1: TokenStream =
TokenTree::Token(sp(0, 1), Token::Ident(Ident::from_str("a"), false)).into();
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/util/lev_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn test_lev_distance() {
#[test]
fn test_find_best_match_for_name() {
use crate::with_globals;
with_globals(|| {
with_globals(&[], || {
let input = vec![Symbol::intern("aaab"), Symbol::intern("aaabc")];
assert_eq!(
find_best_match_for_name(input.iter(), "aaaa", None),
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn reject_stmt_parse(es: &str) {
}

fn main() {
syntax::with_globals(|| run());
syntax::with_globals(&[], || run());
}

fn run() {
Expand Down
Loading

0 comments on commit f62c5cc

Please sign in to comment.