Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[workspace]
members = ["crates/*"]
resolver = "2"
resolver = "3"

[workspace.package]
repository = "https://github.com/assert-rs/predicates-rs"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.74" # MSRV
edition = "2024"
rust-version = "1.85" # MSRV
include = [
"build.rs",
"src/**/*",
Expand Down
162 changes: 97 additions & 65 deletions src/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use std::fmt;
use std::marker::PhantomData;

use crate::reflection;
use crate::Predicate;
use crate::reflection;

/// Predicate that combines two `Predicate`s, returning the AND of the results.
///
Expand Down Expand Up @@ -123,66 +123,82 @@ mod test_and {

#[test]
fn find_case_true() {
assert!(predicate::always()
.and(predicate::always())
.find_case(true, &5)
.is_some());
assert!(
predicate::always()
.and(predicate::always())
.find_case(true, &5)
.is_some()
);
}

#[test]
fn find_case_true_left_fail() {
assert!(predicate::never()
.and(predicate::always())
.find_case(true, &5)
.is_none());
assert!(
predicate::never()
.and(predicate::always())
.find_case(true, &5)
.is_none()
);
}

#[test]
fn find_case_true_right_fail() {
assert!(predicate::always()
.and(predicate::never())
.find_case(true, &5)
.is_none());
assert!(
predicate::always()
.and(predicate::never())
.find_case(true, &5)
.is_none()
);
}

#[test]
fn find_case_true_fails() {
assert!(predicate::never()
.and(predicate::never())
.find_case(true, &5)
.is_none());
assert!(
predicate::never()
.and(predicate::never())
.find_case(true, &5)
.is_none()
);
}

#[test]
fn find_case_false() {
assert!(predicate::never()
.and(predicate::never())
.find_case(false, &5)
.is_some());
assert!(
predicate::never()
.and(predicate::never())
.find_case(false, &5)
.is_some()
);
}

#[test]
fn find_case_false_fails() {
assert!(predicate::always()
.and(predicate::always())
.find_case(false, &5)
.is_none());
assert!(
predicate::always()
.and(predicate::always())
.find_case(false, &5)
.is_none()
);
}

#[test]
fn find_case_false_left_fail() {
assert!(predicate::never()
.and(predicate::always())
.find_case(false, &5)
.is_some());
assert!(
predicate::never()
.and(predicate::always())
.find_case(false, &5)
.is_some()
);
}

#[test]
fn find_case_false_right_fail() {
assert!(predicate::always()
.and(predicate::never())
.find_case(false, &5)
.is_some());
assert!(
predicate::always()
.and(predicate::never())
.find_case(false, &5)
.is_some()
);
}
}

Expand Down Expand Up @@ -295,66 +311,82 @@ mod test_or {

#[test]
fn find_case_true() {
assert!(predicate::always()
.or(predicate::always())
.find_case(true, &5)
.is_some());
assert!(
predicate::always()
.or(predicate::always())
.find_case(true, &5)
.is_some()
);
}

#[test]
fn find_case_true_left_fail() {
assert!(predicate::never()
.or(predicate::always())
.find_case(true, &5)
.is_some());
assert!(
predicate::never()
.or(predicate::always())
.find_case(true, &5)
.is_some()
);
}

#[test]
fn find_case_true_right_fail() {
assert!(predicate::always()
.or(predicate::never())
.find_case(true, &5)
.is_some());
assert!(
predicate::always()
.or(predicate::never())
.find_case(true, &5)
.is_some()
);
}

#[test]
fn find_case_true_fails() {
assert!(predicate::never()
.or(predicate::never())
.find_case(true, &5)
.is_none());
assert!(
predicate::never()
.or(predicate::never())
.find_case(true, &5)
.is_none()
);
}

#[test]
fn find_case_false() {
assert!(predicate::never()
.or(predicate::never())
.find_case(false, &5)
.is_some());
assert!(
predicate::never()
.or(predicate::never())
.find_case(false, &5)
.is_some()
);
}

#[test]
fn find_case_false_fails() {
assert!(predicate::always()
.or(predicate::always())
.find_case(false, &5)
.is_none());
assert!(
predicate::always()
.or(predicate::always())
.find_case(false, &5)
.is_none()
);
}

#[test]
fn find_case_false_left_fail() {
assert!(predicate::never()
.or(predicate::always())
.find_case(false, &5)
.is_none());
assert!(
predicate::never()
.or(predicate::always())
.find_case(false, &5)
.is_none()
);
}

#[test]
fn find_case_false_right_fail() {
assert!(predicate::always()
.or(predicate::never())
.find_case(false, &5)
.is_none());
assert!(
predicate::always()
.or(predicate::never())
.find_case(false, &5)
.is_none()
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

use std::fmt;

use crate::reflection;
use crate::Predicate;
use crate::reflection;

/// `Predicate` that wraps another `Predicate` as a trait object, allowing
/// sized storage of predicate types.
Expand Down
2 changes: 1 addition & 1 deletion src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

use std::fmt;

use crate::Predicate;
use crate::reflection;
use crate::utils;
use crate::Predicate;

/// Predicate that always returns a constant (boolean) result.
///
Expand Down
2 changes: 1 addition & 1 deletion src/float/close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use std::fmt;
use float_cmp::ApproxEq;
use float_cmp::Ulps;

use crate::reflection;
use crate::Predicate;
use crate::reflection;

/// Predicate that ensures two numbers are "close" enough, understanding that rounding errors
/// occur.
Expand Down
2 changes: 1 addition & 1 deletion src/float/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
#[cfg(feature = "float-cmp")]
mod close;
#[cfg(feature = "float-cmp")]
pub use self::close::{is_close, IsClosePredicate};
pub use self::close::{IsClosePredicate, is_close};
2 changes: 1 addition & 1 deletion src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
use std::fmt;
use std::marker::PhantomData;

use crate::Predicate;
use crate::reflection;
use crate::utils;
use crate::Predicate;

/// Predicate that wraps a function over a reference that returns a `bool`.
/// This type is returned by the `predicate::function` function.
Expand Down
2 changes: 1 addition & 1 deletion src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use std::fmt;
use std::hash::Hash;
use std::iter::FromIterator;

use crate::Predicate;
use crate::reflection;
use crate::utils;
use crate::Predicate;

/// Predicate that returns `true` if `variable` is a member of the pre-defined
/// set, otherwise returns `false`.
Expand Down
2 changes: 1 addition & 1 deletion src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use std::fmt;
use std::marker::PhantomData;

use crate::reflection;
use crate::Predicate;
use crate::reflection;

/// Augment an existing predicate with a name.
///
Expand Down
2 changes: 1 addition & 1 deletion src/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

use std::fmt;

use crate::Predicate;
use crate::reflection;
use crate::utils;
use crate::Predicate;

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum EqOps {
Expand Down
2 changes: 1 addition & 1 deletion src/path/existence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use std::fmt;
use std::path;

use crate::Predicate;
use crate::reflection;
use crate::utils;
use crate::Predicate;

/// Predicate that checks if a file is present
///
Expand Down
2 changes: 1 addition & 1 deletion src/path/fc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use std::fs;
use std::io::{self, Read};
use std::path;

use crate::reflection;
use crate::Predicate;
use crate::reflection;

fn read_file(path: &path::Path) -> io::Result<Vec<u8>> {
let mut buffer = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion src/path/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use std::fs;
use std::io::{self, Read};
use std::path;

use crate::Predicate;
use crate::reflection;
use crate::utils;
use crate::Predicate;

fn read_file(path: &path::Path) -> io::Result<Vec<u8>> {
let mut buffer = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion src/path/ft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use std::fs;
use std::io;
use std::path;

use crate::reflection;
use crate::Predicate;
use crate::reflection;

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum FileType {
Expand Down
6 changes: 3 additions & 3 deletions src/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
//! This module contains predicates specific to the file system.

mod existence;
pub use self::existence::{exists, missing, ExistencePredicate};
pub use self::existence::{ExistencePredicate, exists, missing};
mod ft;
pub use self::ft::{is_dir, is_file, is_symlink, FileTypePredicate};
pub use self::ft::{FileTypePredicate, is_dir, is_file, is_symlink};
mod fc;
pub use self::fc::{FileContentPredicate, PredicateFileContentExt};
mod fs;
pub use self::fs::{eq_file, BinaryFilePredicate, StrFilePredicate};
pub use self::fs::{BinaryFilePredicate, StrFilePredicate, eq_file};
Loading