]>
Commit | Line | Data |
---|---|---|
d9579d0f AL |
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 | #![feature(quote, rustc_private)] | |
14 | ||
15 | extern crate syntax; | |
3157f602 | 16 | extern crate syntax_pos; |
d9579d0f AL |
17 | |
18 | use syntax::ast; | |
d9579d0f | 19 | use syntax::print::pprust; |
476ff2be | 20 | use syntax::symbol::Symbol; |
3157f602 | 21 | use syntax_pos::DUMMY_SP; |
d9579d0f AL |
22 | |
23 | fn main() { | |
62682a34 | 24 | let ps = syntax::parse::ParseSess::new(); |
9e0c209e | 25 | let mut resolver = syntax::ext::base::DummyResolver; |
d9579d0f | 26 | let mut cx = syntax::ext::base::ExtCtxt::new( |
c30ab7b3 | 27 | &ps, |
9cc50fc6 | 28 | syntax::ext::expand::ExpansionConfig::default("qquote".to_string()), |
9e0c209e | 29 | &mut resolver); |
d9579d0f AL |
30 | cx.bt_push(syntax::codemap::ExpnInfo { |
31 | call_site: DUMMY_SP, | |
32 | callee: syntax::codemap::NameAndSpan { | |
476ff2be | 33 | format: syntax::codemap::MacroBang(Symbol::intern("")), |
d9579d0f AL |
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 | ||
32a655c1 | 42 | let expr = quote_expr!(&cx, 2 - $abcd + 7); //~ ERROR cannot find value `abcd` in this scope |
d9579d0f AL |
43 | assert_eq!(pprust::expr_to_string(&*expr), "2 - $abcd + 7"); |
44 | } |