]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/syntax-extension-source-utils.rs
New upstream version 1.14.0+dfsg1
[rustc.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 // ignore-pretty issue #37195
12
13 pub mod m1 {
14 pub mod m2 {
15 pub fn where_am_i() -> String {
16 (module_path!()).to_string()
17 }
18 }
19 }
20
21 macro_rules! indirect_line { () => ( line!() ) }
22
23 pub fn main() {
24 assert_eq!(line!(), 24);
25 assert_eq!(column!(), 4);
26 assert_eq!(indirect_line!(), 26);
27 assert!((file!().ends_with("syntax-extension-source-utils.rs")));
28 assert_eq!(stringify!((2*3) + 5).to_string(), "( 2 * 3 ) + 5".to_string());
29 assert!(include!("syntax-extension-source-utils-files/includeme.\
30 fragment").to_string()
31 == "victory robot 6".to_string());
32
33 assert!(
34 include_str!("syntax-extension-source-utils-files/includeme.\
35 fragment").to_string()
36 .starts_with("/* this is for "));
37 assert!(
38 include_bytes!("syntax-extension-source-utils-files/includeme.fragment")
39 [1] == (42 as u8)); // '*'
40 // The Windows tests are wrapped in an extra module for some reason
41 assert!((m1::m2::where_am_i().ends_with("m1::m2")));
42
43 assert_eq!((43, "( 2 * 3 ) + 5"), (line!(), stringify!((2*3) + 5)));
44 }