Skip to content

Commit 15ea1f3

Browse files
committed
Add functional #[cfg(version)] test
1 parent 2dd6488 commit 15ea1f3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ run-pass
2+
//@ rustc-env:RUSTC_OVERRIDE_VERSION_STRING=1.50.3
3+
4+
#[cfg(version("1.49.0"))]
5+
const ON_1_49_0: bool = true;
6+
#[cfg(version("1.50"))]
7+
const ON_1_50_0: bool = true;
8+
#[cfg(not(version("1.51")))]
9+
const ON_1_51_0: bool = false;
10+
11+
fn main() {
12+
assert!(ON_1_49_0);
13+
assert!(ON_1_50_0);
14+
assert!(!ON_1_51_0);
15+
assert!(cfg!(version("1.1")));
16+
assert!(cfg!(version("1.49")));
17+
assert!(!cfg!(version("1.51")));
18+
assert!(!cfg!(version("1.52")));
19+
assert!(!cfg!(version("1.100")));
20+
}

0 commit comments

Comments
 (0)