[][src]Function canrun::util::assert_permutations_resolve_to

pub fn assert_permutations_resolve_to<'a, D, Q>(
    goals: Vec<Goal<'a, D>>,
    query: Q,
    expected: Vec<Q::Reified>
) where
    D: Domain<'a> + Debug + 'a,
    Q: ReifyIn<'a, D> + Clone + 'a,
    Q::Reified: PartialEq + Clone + Debug

Test helper for ensuring that goals work no matter the order they are applied.

When building lower level goals, it can be easy to make mistakes where something appears to work fine but breaks when you reorder the goals. This is especially a problem with projection goals.

This function takes a Vec<Goal<_>>, a Query and a Vec containing the expected values. It will try every permutation of the goals (wrapped in an all goal) and panic if any of the results vary.

Example

use canrun::{Goal, var, unify, assert_1, util};
use canrun::example::I32;

let x = var();
let goals: Vec<Goal<I32>> = vec![
    unify(2, x),
    assert_1(x, |x| *x > 1),
];

util::assert_permutations_resolve_to(goals, x, vec![2]);