File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ path = "../libcore/benches/lib.rs"
2121
2222[dev-dependencies ]
2323rand = " 0.6"
24+ cfg_if = " 1.0"
2425
2526[features ]
2627# Make panics and failed asserts immediately abort without formatting any message
Original file line number Diff line number Diff line change 1+ //! Test that overriding cfg_if with our own cfg_if macro does not break
2+ //! anything.
13#![ feature( cfg_if) ]
24
35macro_rules! cfg_if {
Original file line number Diff line number Diff line change 1+ //! Test that using cfg_if from the cfg_if crate does not break anything.
2+
3+ #[ macro_use( cfg_if) ]
4+ extern crate cfg_if;
5+
6+ cfg_if ! {
7+ if #[ cfg( test) ] {
8+ use core:: option:: Option as Option2 ;
9+ fn works1( ) -> Option2 <u32 > { Some ( 1 ) }
10+ } else {
11+ fn works1( ) -> Option <u32 > { None }
12+ }
13+ }
14+
15+ cfg_if ! {
16+ if #[ cfg( foo) ] {
17+ fn works2( ) -> bool { false }
18+ } else if #[ cfg( test) ] {
19+ fn works2( ) -> bool { true }
20+ } else {
21+ fn works2( ) -> bool { false }
22+ }
23+ }
24+
25+ cfg_if ! {
26+ if #[ cfg( foo) ] {
27+ fn works3( ) -> bool { false }
28+ } else {
29+ fn works3( ) -> bool { true }
30+ }
31+ }
32+
33+ cfg_if ! {
34+ if #[ cfg( test) ] {
35+ use core:: option:: Option as Option3 ;
36+ fn works4( ) -> Option3 <u32 > { Some ( 1 ) }
37+ }
38+ }
39+
40+ cfg_if ! {
41+ if #[ cfg( foo) ] {
42+ fn works5( ) -> bool { false }
43+ } else if #[ cfg( test) ] {
44+ fn works5( ) -> bool { true }
45+ }
46+ }
47+
48+ #[ test]
49+ fn it_works ( ) {
50+ assert ! ( works1( ) . is_some( ) ) ;
51+ assert ! ( works2( ) ) ;
52+ assert ! ( works3( ) ) ;
53+ assert ! ( works4( ) . is_some( ) ) ;
54+ assert ! ( works5( ) ) ;
55+ }
You can’t perform that action at this time.
0 commit comments