Skip to content

Commit

Permalink
Fix the probe_raw test on no_std
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Mar 28, 2024
1 parent e0a2240 commit e01e120
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,17 @@ fn probe_constant() {
#[test]
fn probe_raw() {
let ac = AutoCfg::for_test().unwrap();
let prefix = if ac.no_std { "#![no_std]\n" } else { "" };
let f = |s| format!("{}{}", prefix, s);

// This attribute **must** be used at the crate level.
assert!(ac.probe_raw("#![no_builtins]").is_ok());
assert!(ac.probe_raw(&f("#![no_builtins]")).is_ok());

assert!(ac.probe_raw("#![deny(dead_code)] fn x() {}").is_err());
assert!(ac.probe_raw("#![allow(dead_code)] fn x() {}").is_ok());
assert!(ac.probe_raw("#![deny(dead_code)] pub fn x() {}").is_ok());
assert!(ac.probe_raw(&f("#![deny(dead_code)] fn x() {}")).is_err());
assert!(ac.probe_raw(&f("#![allow(dead_code)] fn x() {}")).is_ok());
assert!(ac
.probe_raw(&f("#![deny(dead_code)] pub fn x() {}"))
.is_ok());
}

#[test]
Expand Down

0 comments on commit e01e120

Please sign in to comment.