package golog

import "github.com/mndrix/golog/read"

import "testing"

func TestFacts (t *testing.T) {
    rt := read.Term_
    db := NewDatabase().
            Asserta(rt(`father(michael).`)).
            Asserta(rt(`father(marc).`))
    t.Logf("%s\n", db.String())

    // these should be provably true
    if !IsTrue(db, rt(`father(michael).`)) {
        t.Errorf("Couldn't prove father(michael)")
    }
    if !IsTrue(db, rt(`father(marc).`)) {
        t.Errorf("Couldn't prove father(marc)")
    }

    // these should not be provable
    if IsTrue(db, rt(`father(sue).`)) {
        t.Errorf("Proved father(sue)")
    }
    if IsTrue(db, rt(`father(michael,marc).`)) {
        t.Errorf("Proved father(michael, marc)")
    }
    if IsTrue(db, rt(`mother(michael).`)) {
        t.Errorf("Proved mother(michael)")
    }
}

package golog

import . "github.com/mndrix/golog/term"

import "testing"

func TestFacts (t *testing.T) {
    db := NewDatabase().
            Asserta(NewTerm("father", NewTerm("michael"))).
            Asserta(NewTerm("father", NewTerm("marc")))
    t.Logf("%s\n", db.String())

    // these should be provably true
    if !IsTrue(db, NewTerm("father", NewTerm("michael"))) {
        t.Errorf("Couldn't prove father(michael)")
    }
    if !IsTrue(db, NewTerm("father", NewTerm("marc"))) {
        t.Errorf("Couldn't prove father(marc)")
    }

    // these should not be provable
    if IsTrue(db, NewTerm("father", NewTerm("sue"))) {
        t.Errorf("Proved father(sue)")
    }
    if IsTrue(db, NewTerm("father", NewTerm("michael"), NewTerm("marc"))) {
        t.Errorf("Proved father(michael, marc)")
    }
    if IsTrue(db, NewTerm("mother", NewTerm("michael"))) {
        t.Errorf("Proved mother(michael)")
    }
}

--- 
+++ 
@@ -1,31 +1,32 @@
 package golog
 
-import . "github.com/mndrix/golog/term"
+import "github.com/mndrix/golog/read"
 
 import "testing"
 
 func TestFacts (t *testing.T) {
+    rt := read.Term_
     db := NewDatabase().
-            Asserta(NewTerm("father", NewTerm("michael"))).
-            Asserta(NewTerm("father", NewTerm("marc")))
+            Asserta(rt(`father(michael).`)).
+            Asserta(rt(`father(marc).`))
     t.Logf("%s\n", db.String())
 
     // these should be provably true
-    if !IsTrue(db, NewTerm("father", NewTerm("michael"))) {
+    if !IsTrue(db, rt(`father(michael).`)) {
         t.Errorf("Couldn't prove father(michael)")
     }
-    if !IsTrue(db, NewTerm("father", NewTerm("marc"))) {
+    if !IsTrue(db, rt(`father(marc).`)) {
         t.Errorf("Couldn't prove father(marc)")
     }
 
     // these should not be provable
-    if IsTrue(db, NewTerm("father", NewTerm("sue"))) {
+    if IsTrue(db, rt(`father(sue).`)) {
         t.Errorf("Proved father(sue)")
     }
-    if IsTrue(db, NewTerm("father", NewTerm("michael"), NewTerm("marc"))) {
+    if IsTrue(db, rt(`father(michael,marc).`)) {
         t.Errorf("Proved father(michael, marc)")
     }
-    if IsTrue(db, NewTerm("mother", NewTerm("michael"))) {
+    if IsTrue(db, rt(`mother(michael).`)) {
         t.Errorf("Proved mother(michael)")
     }
 }
Simplify prove tests with read.Term_
