]> git.lizzy.rs Git - rust.git/blob - src/test/run-fail-fulldeps/qquote.rs
4251579bbdcd1ba21334bb2de131a762ebc7a3dc
[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 identifier, found keyword `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 cx = syntax::ext::base::ExtCtxt::new(
27         &ps, vec![],
28         syntax::ext::expand::ExpansionConfig::default("qquote".to_string()));
29     cx.bt_push(syntax::codemap::ExpnInfo {
30         call_site: DUMMY_SP,
31         callee: syntax::codemap::NameAndSpan {
32             name: "".to_string(),
33             format: syntax::codemap::MacroBang,
34             allow_internal_unstable: false,
35             span: None,
36         }
37     });
38     let cx = &mut cx;
39
40     assert_eq!(pprust::expr_to_string(&*quote_expr!(&cx, 23)), "23");
41
42     let expr = quote_expr!(&cx, let x isize = 20;);
43     assert_eq!(pprust::expr_to_string(&*expr), "let x isize = 20;");
44 }