]> git.lizzy.rs Git - rust.git/blob - src/test/run-fail-fulldeps/qquote.rs
Fix BTreeMap example typo
[rust.git] / src / test / run-fail-fulldeps / qquote.rs
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-cross-compile
12
13 // error-pattern:expected expression, found statement (`let`)
14
15 #![feature(quote, rustc_private)]
16
17 extern crate syntax;
18
19 use syntax::ast;
20 use syntax::codemap::{self, DUMMY_SP};
21 use syntax::parse;
22 use syntax::print::pprust;
23
24 fn main() {
25     let ps = syntax::parse::ParseSess::new();
26     let mut feature_gated_cfgs = vec![];
27     let mut cx = syntax::ext::base::ExtCtxt::new(
28         &ps, vec![],
29         syntax::ext::expand::ExpansionConfig::default("qquote".to_string()),
30         &mut feature_gated_cfgs);
31     cx.bt_push(syntax::codemap::ExpnInfo {
32         call_site: DUMMY_SP,
33         callee: syntax::codemap::NameAndSpan {
34             format: syntax::codemap::MacroBang(parse::token::intern("")),
35             allow_internal_unstable: false,
36             span: None,
37         }
38     });
39     let cx = &mut cx;
40
41     assert_eq!(pprust::expr_to_string(&*quote_expr!(&cx, 23)), "23");
42
43     let expr = quote_expr!(&cx, let x isize = 20;);
44     assert_eq!(pprust::expr_to_string(&*expr), "let x isize = 20;");
45 }