use crate::test_utils; use super::*; use ark_relations::r1cs::{ConstraintSystem, SynthesisError}; pub(crate) fn test_unary_op( a: bool, mode: AllocationMode, test: impl FnOnce(Boolean) -> Result<(), SynthesisError>, ) -> Result<(), SynthesisError> { let cs = ConstraintSystem::::new_ref(); let a = Boolean::::new_variable(cs.clone(), || Ok(a), mode)?; test(a) } pub(crate) fn test_binary_op( a: bool, b: bool, mode_a: AllocationMode, mode_b: AllocationMode, test: impl FnOnce(Boolean, Boolean) -> Result<(), SynthesisError>, ) -> Result<(), SynthesisError> { let cs = ConstraintSystem::::new_ref(); let a = Boolean::::new_variable(cs.clone(), || Ok(a), mode_a)?; let b = Boolean::::new_variable(cs.clone(), || Ok(b), mode_b)?; test(a, b) } pub(crate) fn run_binary_exhaustive( test: impl Fn(Boolean, Boolean) -> Result<(), SynthesisError> + Copy, ) -> Result<(), SynthesisError> { for (mode_a, a) in test_utils::combination([false, true].into_iter()) { for (mode_b, b) in test_utils::combination([false, true].into_iter()) { test_binary_op(a, b, mode_a, mode_b, test)?; } } Ok(()) } pub(crate) fn run_unary_exhaustive( test: impl Fn(Boolean) -> Result<(), SynthesisError> + Copy, ) -> Result<(), SynthesisError> { for (mode, a) in test_utils::combination([false, true].into_iter()) { test_unary_op(a, mode, test)?; } Ok(()) }