From 637ab79eb7006849264515ff6265eb4ef9d99c05 Mon Sep 17 00:00:00 2001 From: Arthur Paulino Date: Wed, 1 Nov 2023 15:09:44 -0300 Subject: [PATCH] add a test for a non self-evaluating expression --- src/lem/multiframe.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/lem/multiframe.rs b/src/lem/multiframe.rs index 1c280e611b..473861eea3 100644 --- a/src/lem/multiframe.rs +++ b/src/lem/multiframe.rs @@ -895,6 +895,7 @@ where #[cfg(test)] mod tests { + use bellpepper_core::test_cs::TestConstraintSystem; use pasta_curves::Fq; use crate::{ @@ -1014,4 +1015,33 @@ mod tests { assert_eq!(x.hash().get_value(), y.hash().get_value()); } } + + #[test] + fn non_self_evaluating() { + let store = Store::default(); + + // not self-evaluating + let expr = store.read_with_default_state("(+ 1 2)").unwrap(); + + let lang = Arc::new(Lang::>::new()); + let (mut frames, _) = evaluate::>(None, expr, &store, 1).unwrap(); + assert_eq!(frames.len(), 1); + + let mut frame = frames.pop().unwrap(); + // faking a trivial evaluation frame + frame.output = vec![expr, store.intern_nil(), store.cont_terminal()]; + + let mut cs = TestConstraintSystem::::new(); + + let folding_config = Arc::new(FoldingConfig::new_ivc(lang.clone(), 1)); + + store.hydrate_z_cache(); + MultiFrame::from_frames(1, &[frame], &store, &folding_config) + .pop() + .unwrap() + .synthesize(&mut cs) + .unwrap(); + + assert!(!cs.is_satisfied()); + } }