]> Repositorios git - scryer-prolog.git/commitdiff
add more tests
authorMark Thom <[email protected]>
Fri, 23 Feb 2018 01:33:00 +0000 (18:33 -0700)
committerMark Thom <[email protected]>
Fri, 23 Feb 2018 01:33:00 +0000 (18:33 -0700)
src/prolog/machine/machine_state.rs
src/tests.rs

index 94daa4ac59c32bfa1edfb9c134f724ccd03bb258..b9663d6c9f2af6bca6c4735ec72b6bc7e5bc9b37 100644 (file)
@@ -370,7 +370,7 @@ impl CallWithInferenceLimitCallPolicy {
         *policy = Box::new(new_policy);
     }
 
-    fn increment(&mut self) -> CallResult {
+    fn increment(&mut self) -> CallResult {        
         if let Some(&(ref limit, bp)) = self.limits.last() {
             if self.count == **limit {
                 return Err(functor!(self.atom_tbl,
index ed5767583709c47bca4fb0b67eac8552c84228cb..e7868ae9ae0cb69cf4a61f0fe9f2765cfde65a50 100644 (file)
@@ -1326,7 +1326,7 @@ fn test_queries_on_builtins()
     assert_prolog_failure!(&mut wam, "?- string(atom).");
     assert_prolog_failure!(&mut wam, "?- string([1,2,3]).");
     assert_prolog_failure!(&mut wam, "?- string([1,2,X]).");
-    
+
     assert_prolog_success!(&mut wam, "?- X = nonvar, nonvar(X).");
     assert_prolog_failure!(&mut wam, "?- nonvar(X).");
     assert_prolog_success!(&mut wam, "?- nonvar(f(X)).");
@@ -1441,15 +1441,14 @@ fn test_queries_on_setup_call_cleanup()
     assert_prolog_success!(&mut wam, "?- catch(setup_call_cleanup(true,throw(goal),throw(cl)), Pat, true).",
                            [["Pat = goal"]]);
     assert_prolog_success!(&mut wam, "?- catch(( setup_call_cleanup(true,(G=1;G=2),throw(cl)), throw(cont)), Pat, true).",
-                           [["Pat = cont", "G = _1"]]);    
+                           [["Pat = cont", "G = _1"]]);
 }
 
 #[test]
 fn test_queries_on_call_with_inference_limit()
-{   
+{
     let mut wam = Machine::new();
 
-    // inference_limit_exceeded thrown on 0 limit.
     assert_prolog_success!(&mut wam, "?- call_with_inference_limit(throw(error), 0, R).",
                            [["R = inference_limit_exceeded"]]);
     assert_prolog_success!(&mut wam, "?- catch(call_with_inference_limit(throw(error), 1, R),
@@ -1457,7 +1456,7 @@ fn test_queries_on_call_with_inference_limit()
                                                true).");
 
     assert_prolog_failure!(&mut wam, "?- call_with_inference_limit(g(X), 5, R).");
-    
+
     submit(&mut wam, "g(1). g(2). g(3). g(4). g(5).");
 
     assert_prolog_success!(&mut wam, "?- call_with_inference_limit(g(X), 5, R).",
@@ -1466,6 +1465,12 @@ fn test_queries_on_call_with_inference_limit()
                             ["R = true", "X = 3"],
                             ["R = true", "X = 4"],
                             ["R = !", "X = 5"]]);
+    assert_prolog_success!(&mut wam, "?- call_with_inference_limit(g(X), 5, R), call(true).",
+                           [["R = true", "X = 1"],
+                            ["R = true", "X = 2"],
+                            ["R = true", "X = 3"],
+                            ["R = true", "X = 4"],
+                            ["R = !", "X = 5"]]);
     assert_prolog_success!(&mut wam, "?- call_with_inference_limit(g(X), 2, R).",
                            [["R = true", "X = 1"],
                             ["R = true", "X = 2"],
@@ -1496,7 +1501,7 @@ fn test_queries_on_call_with_inference_limit()
                            [["R = inference_limit_exceeded", "X = _1"]]);
 
     submit(&mut wam, "e(X) :- call_with_inference_limit(f(X), 10, _).");
-    
+
     assert_prolog_success!(&mut wam, "?- call_with_inference_limit(e(X), 7, R).",
                            [["R = true", "X = 1"],
                             ["R = true", "X = 2"],
@@ -1520,11 +1525,11 @@ fn test_queries_on_call_with_inference_limit()
                            [["R = inference_limit_exceeded", "X = _1"]]);
 
     submit(&mut wam, "f(X, R) :- call_with_inference_limit(g(X), 5, R).");
-    
+
     assert_prolog_success!(&mut wam, "?- call_with_inference_limit(f(X, R), 3, S).",
                            [["S = true", "X = 1", "R = true"],
                             ["S = true", "X = 2", "R = true"],
-                            ["S = inference_limit_exceeded", "X = _1", "R = _2"]]);    
+                            ["S = inference_limit_exceeded", "X = _1", "R = _2"]]);
     assert_prolog_success!(&mut wam, "?- call_with_inference_limit(f(X, R), 7, R).",
                            [["R = true", "X = 1"],
                             ["R = true", "X = 2"],