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