]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass-fulldeps/macro-quote-1.rs
Rollup merge of #41971 - japaric:pre-link-args, r=alexcrichton
[rust.git] / src / test / run-pass-fulldeps / macro-quote-1.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-stage1
12
13 #![feature(plugin)]
14 #![feature(rustc_private)]
15 #![plugin(proc_macro_plugin)]
16
17 extern crate syntax;
18 extern crate syntax_pos;
19
20 use syntax::ast::{Ident, Name};
21 use syntax::parse::token::{self, Token, Lit};
22 use syntax::tokenstream::TokenTree;
23
24 fn main() {
25     let true_tok = token::Ident(Ident::from_str("true"));
26     assert!(quote!(true).eq_unspanned(&true_tok.into()));
27
28     // issue #35829, extended check to proc_macro.
29     let triple_dot_tok = Token::DotDotDot;
30     assert!(quote!(...).eq_unspanned(&triple_dot_tok.into()));
31
32     let byte_str_tok = Token::Literal(Lit::ByteStr(Name::intern("one")), None);
33     assert!(quote!(b"one").eq_unspanned(&byte_str_tok.into()));
34
35     let byte_str_raw_tok = Token::Literal(Lit::ByteStrRaw(Name::intern("#\"two\"#"), 3), None);
36     assert!(quote!(br###"#"two"#"###).eq_unspanned(&byte_str_raw_tok.into()));
37
38     let str_raw_tok = Token::Literal(Lit::StrRaw(Name::intern("#\"three\"#"), 2), None);
39     assert!(quote!(r##"#"three"#"##).eq_unspanned(&str_raw_tok.into()));
40 }