chore(tvix/eval): Pass in VM to nix_eq

Pass in, but ignore, a mutable reference to the VM to the `nix_eq`
functions, in preparation for using that VM to force thunks during
comparison.

Change-Id: I565435d8dfb33768f930fdb5a6b0fb1365d7e161
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6651
Autosubmit: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Griffin Smith 2022-09-18 15:13:20 -04:00 committed by clbot
parent 915ff5ac2a
commit 0b76ed5615
5 changed files with 55 additions and 20 deletions

View file

@ -1,24 +1,38 @@
use super::*;
mod nix_eq {
use crate::observer::NoOpObserver;
use super::*;
use proptest::prelude::ProptestConfig;
use test_strategy::proptest;
#[proptest(ProptestConfig { cases: 5, ..Default::default() })]
fn reflexive(x: NixAttrs) {
assert!(x.nix_eq(&x).unwrap())
let mut observer = NoOpObserver {};
let mut vm = VM::new(&mut observer);
assert!(x.nix_eq(&x, &mut vm).unwrap())
}
#[proptest(ProptestConfig { cases: 5, ..Default::default() })]
fn symmetric(x: NixAttrs, y: NixAttrs) {
assert_eq!(x.nix_eq(&y).unwrap(), y.nix_eq(&x).unwrap())
let mut observer = NoOpObserver {};
let mut vm = VM::new(&mut observer);
assert_eq!(
x.nix_eq(&y, &mut vm).unwrap(),
y.nix_eq(&x, &mut vm).unwrap()
)
}
#[proptest(ProptestConfig { cases: 5, ..Default::default() })]
fn transitive(x: NixAttrs, y: NixAttrs, z: NixAttrs) {
if x.nix_eq(&y).unwrap() && y.nix_eq(&z).unwrap() {
assert!(x.nix_eq(&z).unwrap())
let mut observer = NoOpObserver {};
let mut vm = VM::new(&mut observer);
if x.nix_eq(&y, &mut vm).unwrap() && y.nix_eq(&z, &mut vm).unwrap() {
assert!(x.nix_eq(&z, &mut vm).unwrap())
}
}
}