11// run-pass
2- // ignore-cloudabi no processes
3- // ignore-emscripten no processes
4- // ignore-sgx no processes
2+ // check-run-results
53
64// Tests ensuring that `dbg!(expr)` has the expected run-time behavior.
75// as well as some compile time properties we expect.
@@ -18,7 +16,7 @@ struct Point<T> {
1816#[ derive( Debug , PartialEq ) ]
1917struct NoCopy ( usize ) ;
2018
21- fn test ( ) {
19+ fn main ( ) {
2220 let a: Unit = dbg ! ( Unit ) ;
2321 let _: Unit = dbg ! ( a) ;
2422 // We can move `a` because it's Copy.
@@ -67,81 +65,3 @@ fn test() {
6765 assert_eq ! ( ( 1u8 , 2u32 , "Yeah" ) , dbg!( 1u8 , 2u32 ,
6866 "Yeah" , ) ) ;
6967}
70-
71- fn validate_stderr ( stderr : Vec < String > ) {
72- assert_eq ! ( stderr, & [
73- ":22] Unit = Unit" ,
74-
75- ":23] a = Unit" ,
76-
77- ":29] Point{x: 42, y: 24,} = Point {" ,
78- " x: 42," ,
79- " y: 24," ,
80- "}" ,
81-
82- ":30] b = Point {" ,
83- " x: 42," ,
84- " y: 24," ,
85- "}" ,
86-
87- ":38]" ,
88-
89- ":42] &a = NoCopy(" ,
90- " 1337," ,
91- ")" ,
92-
93- ":42] dbg!(& a) = NoCopy(" ,
94- " 1337," ,
95- ")" ,
96- ":47] f(&42) = 42" ,
97-
98- "before" ,
99- ":52] { foo += 1; eprintln!(\" before\" ); 7331 } = 7331" ,
100-
101- ":60] (\" Yeah\" ,) = (" ,
102- " \" Yeah\" ," ,
103- ")" ,
104-
105- ":63] 1 = 1" ,
106- ":63] 2 = 2" ,
107-
108- ":67] 1u8 = 1" ,
109- ":67] 2u32 = 2" ,
110- ":67] \" Yeah\" = \" Yeah\" " ,
111- ] ) ;
112- }
113-
114- fn main ( ) {
115- // The following is a hack to deal with compiletest's inability
116- // to check the output (to stdout) of run-pass tests.
117- use std:: env;
118- use std:: process:: Command ;
119-
120- let mut args = env:: args ( ) ;
121- let prog = args. next ( ) . unwrap ( ) ;
122- let child = args. next ( ) ;
123- if let Some ( "child" ) = child. as_ref ( ) . map ( |s| & * * s) {
124- // Only run the test if we've been spawned as 'child'
125- test ( )
126- } else {
127- // This essentially spawns as 'child' to run the tests
128- // and then it collects output of stderr and checks the output
129- // against what we expect.
130- let out = Command :: new ( & prog) . arg ( "child" ) . output ( ) . unwrap ( ) ;
131- assert ! ( out. status. success( ) ) ;
132- assert ! ( out. stdout. is_empty( ) ) ;
133-
134- let stderr = String :: from_utf8 ( out. stderr ) . unwrap ( ) ;
135- let stderr = stderr. lines ( ) . map ( |mut s| {
136- if s. starts_with ( "[" ) {
137- // Strip `[` and file path:
138- s = s. trim_start_matches ( "[" ) ;
139- assert ! ( s. starts_with( file!( ) ) ) ;
140- s = s. trim_start_matches ( file ! ( ) ) ;
141- }
142- s. to_owned ( )
143- } ) . collect ( ) ;
144-
145- validate_stderr ( stderr) ;
146- }
147- }
0 commit comments