Skip to content

Commit

Permalink
Add an option to skip the pointer check
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Sep 16, 2015
1 parent 0cf730b commit b1d0e03
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct TestGenerator {
defines: Vec<(String, Option<String>)>,
cfg: Vec<(String, Option<String>)>,
skip_fn: Box<Fn(&str) -> bool>,
skip_fn_ptrcheck: Box<Fn(&str) -> bool>,
skip_const: Box<Fn(&str) -> bool>,
skip_signededness: Box<Fn(&str) -> bool>,
skip_type: Box<Fn(&str) -> bool>,
Expand Down Expand Up @@ -65,6 +66,7 @@ impl TestGenerator {
defines: Vec::new(),
cfg: Vec::new(),
skip_fn: Box::new(|_| false),
skip_fn_ptrcheck: Box::new(|_| false),
skip_const: Box::new(|_| false),
skip_signededness: Box::new(|_| false),
skip_type: Box::new(|_| false),
Expand Down Expand Up @@ -133,6 +135,13 @@ impl TestGenerator {
self
}

pub fn skip_fn_ptrcheck<F>(&mut self, f: F) -> &mut TestGenerator
where F: Fn(&str) -> bool + 'static
{
self.skip_fn_ptrcheck = Box::new(f);
self
}

pub fn skip_const<F>(&mut self, f: F) -> &mut TestGenerator
where F: Fn(&str) -> bool + 'static
{
Expand Down Expand Up @@ -570,12 +579,14 @@ impl<'a> Generator<'a> {
fn __test_fn_{name}() -> size_t;
}}
unsafe {{
same({name} as usize,
__test_fn_{name}() as usize,
"{name} function pointer");
if !{skip} {{
same({name} as usize,
__test_fn_{name}() as usize,
"{name} function pointer");
}}
}}
}}
"#, name = name));
"#, name = name, skip = (self.opts.skip_fn_ptrcheck)(name)));
self.tests.push(format!("fn_{}", name));
}

Expand Down

0 comments on commit b1d0e03

Please sign in to comment.