]> Repositorios git - scryer-prolog.git/commitdiff
Test show problem with nonexistent predicate
authorNicolas Luck <[email protected]>
Thu, 1 Feb 2024 13:14:50 +0000 (14:14 +0100)
committerNicolas Luck <[email protected]>
Thu, 1 Feb 2024 13:14:50 +0000 (14:14 +0100)
src/machine/lib_machine.rs

index ab16a7a4f5de56be391993c920b86d5522950a1d..346e0ebccef413cc3f952ddb05daa8eed24d938e 100644 (file)
@@ -584,4 +584,28 @@ mod tests {
         let output = machine.run_query(query);
         assert_eq!(output, Ok(QueryResolution::False));
     }
+
+    #[test]
+    fn non_existent_predicate_should_not_cause_panic_when_other_predicates_are_defined() {
+        let mut machine = Machine::new_lib();
+
+        machine.consult_module_string(
+            "facts",
+            String::from(
+                r#"
+                triple("a", "p1", "b").
+                triple("a", "p2", "b").
+        "#,
+            ),
+        );
+
+        let query = String::from("non_existent_predicate(\"a\",\"p1\",\"b\").");
+
+        let result = machine.run_query(query);
+
+        assert_eq!(
+            result,
+            Err(String::from("error existence_error procedure / non_existent_predicate 3 / non_existent_predicate 3"))
+        );    
+    }
 }