mini_kanren/
testing.rs

1use crate::core::goal::Goal;
2use crate::core::value::Value;
3use crate::goals::StatSubs;
4
5/// Assert that a goal fails
6pub fn fails(goal: impl Goal<StatSubs>) {
7    let result = run!(1, q, goal);
8    if !result.is_empty() {
9        panic!("Expected goal to fail, but it succeeded with {:?}", result);
10    }
11}
12
13/// Assert that a goal succeeds at least once
14pub fn succeeds(goal: impl Goal<StatSubs>) {
15    let result = run!(1, q, goal);
16    if result.is_empty() {
17        panic!("Goal did not succeed.")
18    }
19}
20
21pub fn has_unique_solution(mut solutions: impl Iterator<Item = Value>, expected: Value) {
22    assert_eq!(solutions.next(), Some(expected));
23    assert_eq!(solutions.next(), None);
24}