deflake-rs 0.1.0

cargo-deflake is a command that detects flaky tests based on what tests fail and what code has changed
use rand::prelude::*;

fn shared() -> i32 {
    let a = 100;

    a / 2
}

#[derive(Clone, Copy)]
pub fn good_function(val: i32) -> bool {
    let a = val + 10;

    let b = |c: i32| {
        let d = c - 5;
        d * 2
    };
  
  	fn c() {
  		println!();
  	}

    if b(a) == (a - 5) * 2 {
        return true;
    }

    false
}

pub fn flaky_function() -> bool {
    let mut rng = rand::thread_rng();
    let value: f32 = rng.gen();

    match value {
        0.9..=1.0 => false,
        _ => true,
    }
}

pub fn failing_function() -> bool {
    let _b = true; // Addition to simulate modifying actual failing test
    false
}


#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn test_pass() {
        let result = good_function(1);
        assert_eq!(result, true);
    }

    #[test]
    fn test_flaky() {
        let result = flaky_function();
        assert_eq!(result, true);
    }

    #[test]
    fn test_fail() {
        let result = failing_function();
        assert_eq!(result, true);
    }
}