• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 extern crate autocfg;
2 
main()3 pub fn main() {
4     let cfg = autocfg::AutoCfg::new().unwrap();
5 
6     //
7     // tests
8     //
9 
10     // always true
11     cfg.emit_rustc_version(1, 0);
12     // should always be false
13     cfg.emit_rustc_version(7, std::u32::MAX as usize);
14 
15     // always true
16     cfg.emit_has_path("std::vec::Vec");
17     cfg.emit_path_cfg("std::vec::Vec", "has_path_std_vec");
18     // always false
19     cfg.emit_has_path("dummy::DummyPath");
20     cfg.emit_path_cfg("dummy::DummyPath", "has_path_dummy");
21 
22     // always true
23     cfg.emit_has_trait("std::ops::Add");
24     cfg.emit_trait_cfg("std::ops::Add", "has_trait_add");
25     // always false
26     cfg.emit_has_trait("dummy::DummyTrait");
27     cfg.emit_trait_cfg("dummy::DummyTrait", "has_trait_dummy");
28 
29     // always true
30     cfg.emit_has_type("i32");
31     cfg.emit_type_cfg("i32", "has_type_i32");
32     // always false
33     cfg.emit_has_type("i7billion");
34     cfg.emit_type_cfg("i7billion", "has_type_i7billion");
35 
36     // always true
37     cfg.emit_expression_cfg("3 + 7", "has_working_addition");
38     // always false
39     cfg.emit_expression_cfg("3 ^^^^^ 12", "has_working_5xor");
40 
41     // always true
42     cfg.emit_constant_cfg("7", "has_const_7");
43     // false - Opening file should never be `const`
44     cfg.emit_constant_cfg("std::fs::File::open(\"foo.txt\")", "has_const_file_open");
45 }
46