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
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ description = "Declarative quantifiers for filtering, validation, and testing in
keywords = ["logic", "validation", "math", "quantifiers"]
categories = ["algorithms", "data-structures", "mathematics", "development-tools::testing"]
repository = "https://github.com/nervousnullptr/quantor"
version = "0.10.0"
version = "0.10.1"
edition = "2021"
readme = "readme.md"
license = "MIT OR Apache-2.0"
include = ["src/**/*", "README.md", "LICENSE*", "Cargo.toml"]

[package.metadata.docs.rs]
all-features = true
Expand Down
16 changes: 8 additions & 8 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,15 @@ impl QuantorError {
#[must_use]
pub fn kind(&self) -> QuantorKind {
match self {
QuantorError::PredicateFailed { .. } => QuantorKind::Forall,
QuantorError::PredicateFailed { kind, .. } => *kind,
QuantorError::EmptyInput { kind } => *kind,
QuantorError::NoMatch { .. } => QuantorKind::Exists,
QuantorError::UnexpectedMatch { .. } => QuantorKind::None,
QuantorError::NotAllEqual { .. } => QuantorKind::AllEqual,
QuantorError::PairwiseFailed { .. } => QuantorKind::Pairwise,
QuantorError::ForAllExistsFailed { .. } => QuantorKind::ForAllExists,
QuantorError::ExistsForAllFailed { .. } => QuantorKind::ExistsForAll,
QuantorError::ExactlyNFailed { .. } => QuantorKind::ExactlyN,
QuantorError::NoMatch { kind, .. } => *kind,
QuantorError::UnexpectedMatch { kind, .. } => *kind,
QuantorError::NotAllEqual { kind, .. } => *kind,
QuantorError::PairwiseFailed { kind, .. } => *kind,
QuantorError::ForAllExistsFailed { kind, .. } => *kind,
QuantorError::ExistsForAllFailed { kind, .. } => *kind,
QuantorError::ExactlyNFailed { kind, .. } => *kind,
QuantorError::Custom(_) => QuantorKind::Custom,
}
}
Expand Down
31 changes: 13 additions & 18 deletions src/macros/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,7 @@ macro_rules! debug_exactly_n {
{
match $crate::quantifiers::basic::exactly_n($xs, $count, $pred) {
Ok(()) => {},
Err(e) => {
if let Some(found) = e.match_count() {
println!(
"[debug_exactly_n] expected exactly {}, but found {} matching elements.",
$count, found
);
} else {
println!(
"[debug_exactly_n] quantifier failed, but count information was not available."
);
}
}
Err(e) => {println!("[debug_exactly_n] {}", e)},
}
}
};
Expand Down Expand Up @@ -168,9 +157,12 @@ macro_rules! debug_none {
macro_rules! debug_assert_duplicates {
($xs:expr) => {
#[cfg(debug_assertions)]
match $crate::quantifiers::selection::assert_duplicates($xs) {
Ok(()) => {},
Err(e) => panic!("debug_assert_duplicates! failed: {}", e),
{
let candidates = $crate::quantifiers::selection::select_duplicates($xs);

if candidates.is_empty() {
panic!("debug_assert_duplicates! failed: {:#?}", candidates)
}
}
};
}
Expand Down Expand Up @@ -205,9 +197,12 @@ macro_rules! debug_duplicates {
macro_rules! debug_assert_unique {
($xs:expr) => {
#[cfg(debug_assertions)]
match $crate::quantifiers::selection::assert_unique($xs) {
Ok(()) => {},
Err(e) => panic!("debug_assert_unique! failed: {}", e),
{
let candidates = $crate::quantifiers::selection::select_duplicates($xs);

if !candidates.is_empty() {
panic!("debug_assert_unique! failed: {:#?}", candidates)
}
}
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/macros/quantify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// - `exactly_one x in &a => predicate`
/// - `exactly_n n x in &a => predicate`
/// - `all_equal x in &a => predicate`
/// - `pairwise x in &a => predicate`
/// - `pairwise x,y in &a => predicate`
/// - `forallexists x in &a, y in &b => predicate`
/// - `existsforall x in &a, y in &b => predicate`
///
Expand Down Expand Up @@ -60,8 +60,8 @@ macro_rules! quantify {
$crate::quantifiers::basic::all_equal($xs)
};

(pairwise $x:ident in $xs:expr => $cond:expr) => {
$crate::quantifiers::basic::pairwise($xs, |$x, x_next| $cond)
(pairwise $x:ident,$y:ident in $xs:expr => $cond:expr) => {
$crate::quantifiers::structured::pairwise($xs, |$x, $y| $cond)
};

// Nested
Expand Down