]> Repositorios git - scryer-prolog.git/commitdiff
Add more test cases to differentiate usage of discontiguous
authorNicolas Luck <[email protected]>
Mon, 29 Jan 2024 15:49:03 +0000 (16:49 +0100)
committerNicolas Luck <[email protected]>
Mon, 29 Jan 2024 15:49:03 +0000 (16:49 +0100)
src/machine/lib_machine.rs

index 6756a953b611b70b785f434e4f02f9e31176549a..cee7e6eb7bea6bedd42a87b1eb7cdfda231c83c2 100644 (file)
@@ -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,