]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/syntax-extension-source-utils.rs
Un-gate macro_rules
[rust.git] / src / test / run-pass / syntax-extension-source-utils.rs
1 // Copyright 2012-2013-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 // This test is brittle!
12 // ignore-pretty - the pretty tests lose path information, breaking include!
13
14 pub mod m1 {
15     pub mod m2 {
16         pub fn where_am_i() -> String {
17             (module_path!()).to_string()
18         }
19     }
20 }
21
22 macro_rules! indirect_line { () => ( line!() ) }
23
24 pub fn main() {
25     assert_eq!(line!(), 25);
26     //assert!((column!() == 11));
27     assert_eq!(indirect_line!(), 27);
28     assert!((file!().ends_with("syntax-extension-source-utils.rs")));
29     assert_eq!(stringify!((2*3) + 5).to_string(), "( 2 * 3 ) + 5".to_string());
30     assert!(include!("syntax-extension-source-utils-files/includeme.\
31                       fragment").to_string()
32            == "victory robot 6".to_string());
33
34     assert!(
35         include_str!("syntax-extension-source-utils-files/includeme.\
36                       fragment").to_string()
37         .as_slice()
38         .starts_with("/* this is for "));
39     assert!(
40         include_bytes!("syntax-extension-source-utils-files/includeme.fragment")
41         [1] == (42 as u8)); // '*'
42     // The Windows tests are wrapped in an extra module for some reason
43     assert!((m1::m2::where_am_i().as_slice().ends_with("m1::m2")));
44
45     assert!(match (45, "( 2 * 3 ) + 5") {
46         (line!(), stringify!((2*3) + 5)) => true,
47         _ => false
48     })
49 }