1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use canrun::assert_2;
use canrun::goal::Goal;
use canrun::value::IntoVal;
use canrun::DomainType;
use std::fmt::Debug;
pub fn gte<'a, A, AV, B, BV, D>(a: AV, b: BV) -> Goal<'a, D>
where
A: PartialOrd<B> + Debug + 'a,
B: Debug + 'a,
AV: IntoVal<A>,
BV: IntoVal<B>,
D: DomainType<'a, A> + DomainType<'a, B>,
{
assert_2(a, b, |a, b| a >= b)
}
#[cfg(test)]
mod tests {
use super::gte;
use canrun::domains::example::I32;
use canrun::{unify, util, var, Goal};
#[test]
fn succeeds() {
let (x, y, z) = (var(), var(), var());
let goals: Vec<Goal<I32>> =
vec![unify(x, 2), unify(y, 1), unify(z, 1), gte(x, y), gte(y, z)];
util::assert_permutations_resolve_to(goals, (x, y, z), vec![(2, 1, 1)]);
}
#[test]
fn fails() {
let (x, y) = (var(), var());
let goals: Vec<Goal<I32>> = vec![unify(x, 1), unify(y, 2), gte(x, y)];
util::assert_permutations_resolve_to(goals, (x, y), vec![]);
}
}