From: Mark Thom Date: Thu, 25 May 2017 20:46:48 +0000 (-0600) Subject: add tests X-Git-Tag: v0.8.110~723 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=cf470e48c2c9ca11c638b6cf97cd911e75d6b1bf;p=scryer-prolog.git add tests --- diff --git a/README.md b/README.md index 795baa17..75028800 100644 --- a/README.md +++ b/README.md @@ -17,19 +17,21 @@ Extend rusty-wam to include the following, among other features: * call/N as a built-in meta-predicate (_done_). * ISO Prolog compliant throw/catch. -* Support for built-in and user-defined operators of all fixities, +* Built-in and user-defined operators of all fixities, with custom associativity and precedence. * Bignum and floating point arithmetic. -* Standard built-in control operators (`;`, `->`, etc.). +* Built-in control operators (`;`, `->`, etc.). * Attributed variables using the SICStus Prolog interface and - semantics. Implementing coroutines like `dif/2`, `freeze/2` - is easy with attributed variables. + semantics. Adding coroutines like `dif/2`, `freeze/2`, etc. + is straightforward with attributed variables. * An occurs check. * Built-in predicates for list processing and top-level declarative control (`setup_call_control/3`, `call_with_inference_limit/3`, etc.) * Mode declarations. -* Extensions for clp(FD). +* Extensions for clp(FD). +* `if_` and related predicates, following the developments of the + paper "Indexing `dif/2`". ## Tutorial To enter a multi-clause predicate, the brackets ":{" and "}:" are used diff --git a/src/main.rs b/src/main.rs index 788faa92..5bfac5db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -593,6 +593,25 @@ mod tests { assert_eq!(submit(&mut wam, "?- f(r, X, X)."), true); assert_eq!(submit(&mut wam, "?- f(r, f(X), g(Y))."), true); assert_eq!(submit(&mut wam, "?- f(r, j(X), h(Y))."), false); + + submit(&mut wam, "p(one, one). p(one, two). p(two, two)."); + + assert_eq!(submit(&mut wam, "?- f(p(one), X, Y)."), true); + assert_eq!(submit(&mut wam, "?- f(p(one), X, X)."), true); + assert_eq!(submit(&mut wam, "?- f(p(one), one, Y)."), true); + assert_eq!(submit(&mut wam, "?- f(p(one), one, two)."), true); + assert_eq!(submit(&mut wam, "?- f(p(one), one, three)."), false); + + assert_eq!(submit(&mut wam, "?- f(p(two), one, two)."), false); + assert_eq!(submit(&mut wam, "?- f(p(two), two, one)."), false); + assert_eq!(submit(&mut wam, "?- f(p(two), two, two)."), true); + assert_eq!(submit(&mut wam, "?- f(p(two), two, three)."), false); + + assert_eq!(submit(&mut wam, "?- f(p(three), X, Y)."), false); + assert_eq!(submit(&mut wam, "?- f(p(three), X, X)."), false); + assert_eq!(submit(&mut wam, "?- f(p(three), one, Y)."), false); + assert_eq!(submit(&mut wam, "?- f(p(three), one, two)."), false); + assert_eq!(submit(&mut wam, "?- f(p(three), one, three)."), false); } }