mod private {
pub trait BehavioralEquivalence<T> {
fn verify_equivalence(&self, other: &T) -> Result<(), String>;
fn verify_error_equivalence(&self, other: &T) -> Result<(), String>;
}
#[derive(Debug)]
pub struct DebugAssertionVerifier;
impl DebugAssertionVerifier {
pub fn verify_identical_assertions() -> Result<(), String> {
Ok(())
}
pub fn verify_panic_message_equivalence() -> Result<(), String> {
Ok(())
}
}
#[derive(Debug)]
pub struct CollectionVerifier;
impl CollectionVerifier {
pub fn verify_collection_operations() -> Result<(), String> {
Ok(())
}
#[cfg(feature = "collection_constructors")]
pub fn verify_constructor_macro_equivalence() -> Result<(), String> {
#[cfg(feature = "standalone_build")]
{
Ok(())
}
#[cfg(not(feature = "standalone_build"))]
Ok(())
}
}
#[derive(Debug)]
pub struct MemoryToolsVerifier;
impl MemoryToolsVerifier {
pub fn verify_memory_operations() -> Result<(), String> {
Ok(())
}
pub fn verify_memory_edge_cases() -> Result<(), String> {
Ok(())
}
}
#[derive(Debug)]
pub struct ErrorHandlingVerifier;
impl ErrorHandlingVerifier {
pub fn verify_err_with_equivalence() -> Result<(), String> {
Ok(())
}
pub fn verify_error_formatting_equivalence() -> Result<(), String> {
Ok(())
}
}
#[derive(Debug)]
pub struct BehavioralEquivalenceVerifier;
impl BehavioralEquivalenceVerifier {
pub fn verify_all() -> Result<(), Vec<String>> {
let mut errors = Vec::new();
if let Err(e) = DebugAssertionVerifier::verify_identical_assertions() {
errors.push(format!("Debug assertion verification failed: {e}"));
}
if let Err(e) = DebugAssertionVerifier::verify_panic_message_equivalence() {
errors.push(format!("Panic message verification failed: {e}"));
}
if let Err(e) = CollectionVerifier::verify_collection_operations() {
errors.push(format!("Collection operation verification failed: {e}"));
}
#[cfg(feature = "collection_constructors")]
if let Err(e) = CollectionVerifier::verify_constructor_macro_equivalence() {
errors.push(format!("Constructor macro verification failed: {e}"));
}
if let Err(e) = MemoryToolsVerifier::verify_memory_operations() {
errors.push(format!("Memory operation verification failed: {e}"));
}
if let Err(e) = MemoryToolsVerifier::verify_memory_edge_cases() {
errors.push(format!("Memory edge case verification failed: {e}"));
}
if let Err(e) = ErrorHandlingVerifier::verify_err_with_equivalence() {
errors.push(format!("ErrWith verification failed: {e}"));
}
if let Err(e) = ErrorHandlingVerifier::verify_error_formatting_equivalence() {
errors.push(format!("Error formatting verification failed: {e}"));
}
if errors.is_empty() {
Ok(())
} else {
Err(errors)
}
}
#[must_use]
pub fn verification_report() -> String {
match Self::verify_all() {
Ok(()) => {
"✅ All behavioral equivalence verifications passed!\n\
test_tools re-exports are behaviorally identical to original sources.".to_string()
}
Err(errors) => {
let mut report = "❌ Behavioral equivalence verification failed:\n".to_string();
for (i, error) in errors.iter().enumerate() {
use core::fmt::Write;
writeln!(report, "{}. {}", i + 1, error).expect("Writing to String should not fail");
}
report
}
}
}
}
}
#[ doc( inline ) ]
#[ allow( unused_imports ) ]
pub use own::*;
#[ allow( unused_imports ) ]
pub mod own {
use super::*;
#[ doc( inline ) ]
pub use super::{orphan::*};
}
#[ allow( unused_imports ) ]
pub mod orphan {
use super::*;
#[ doc( inline ) ]
pub use super::{exposed::*};
}
#[ allow( unused_imports ) ]
pub mod exposed {
use super::*;
#[ doc( inline ) ]
pub use prelude::*;
#[ doc( inline ) ]
pub use private::{
BehavioralEquivalence,
DebugAssertionVerifier,
CollectionVerifier,
MemoryToolsVerifier,
ErrorHandlingVerifier,
BehavioralEquivalenceVerifier,
};
}
#[ allow( unused_imports ) ]
pub mod prelude {
use super::*;
#[ doc( inline ) ]
pub use private::BehavioralEquivalenceVerifier;
}