From: Nicolas Luck Date: Mon, 29 Jan 2024 15:49:03 +0000 (+0100) Subject: Add more test cases to differentiate usage of discontiguous X-Git-Tag: v0.9.4~3^2~25 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=9aacfff35dea836d88f9e1b32fe34c051f6d94a7;p=scryer-prolog.git Add more test cases to differentiate usage of discontiguous --- diff --git a/src/machine/lib_machine.rs b/src/machine/lib_machine.rs index 6756a953..cee7e6eb 100644 --- a/src/machine/lib_machine.rs +++ b/src/machine/lib_machine.rs @@ -549,7 +549,62 @@ mod tests { ); let query = - String::from(r#"subject_class("Todo", C), property_resolve(C, "isLiked")."#); + String::from(r#"property_resolve(C, "isLiked"), subject_class("Todo", C)."#); + let output = machine.run_query(query); + assert_eq!( + output, + Ok(QueryResolution::False) + ); + + let query = + String::from(r#"subject_class("Todo", C), property_resolve(C, "isLiked")."#); + let output = machine.run_query(query); + assert_eq!( + output, + Ok(QueryResolution::False) + ); + } + + #[test] + fn dont_return_partial_matches_without_discountiguous() { + let mut machine = Machine::new_lib(); + + machine.consult_module_string( + "facts", + String::from( + r#" + a("true for a"). + b("true for b"). + "#, + ), + ); + + let query = + String::from(r#"a("true for a")."#); + let output = machine.run_query(query); + assert_eq!( + output, + Ok(QueryResolution::True) + ); + + let query = + String::from(r#"a("true for a"), b("true for b")."#); + let output = machine.run_query(query); + assert_eq!( + output, + Ok(QueryResolution::True) + ); + + let query = + String::from(r#"a("true for b"), b("true for b")."#); + let output = machine.run_query(query); + assert_eq!( + output, + Ok(QueryResolution::False) + ); + + let query = + String::from(r#"a("true for a"), b("true for a")."#); let output = machine.run_query(query); assert_eq!( output,