예제 #1
0
        public void VarPrimitiveAcceptsVariable()
        {
            StructureObject so = new StructureObject("var", "X");
            PrologMachine   pm = new PrologMachine();

            Assert.IsTrue(pm.Resolve(so));
        }
예제 #2
0
        public void VarPrimitiveRejectsInteger()
        {
            StructureObject so = new StructureObject("var", 1);
            PrologMachine   pm = new PrologMachine();

            Assert.IsFalse(pm.Resolve(so));
        }
예제 #3
0
        public void VarPrimitiveRejectsStructure()
        {
            StructureObject so = new StructureObject("var", new StructureObject("foo", "bar"));
            PrologMachine   pm = new PrologMachine();

            Assert.IsFalse(pm.Resolve(so));
        }
예제 #4
0
        public void IntegerPrimitiveRejectsAtom()
        {
            StructureObject so = new StructureObject("integer", "a");
            PrologMachine   pm = new PrologMachine();

            Assert.IsFalse(pm.Resolve(so));
        }
예제 #5
0
        public void IntegerPrimitiveAcceptsInteger()
        {
            StructureObject so = new StructureObject("integer", 1);
            PrologMachine   pm = new PrologMachine();

            Assert.IsTrue(pm.Resolve(so));
        }
예제 #6
0
        public void EqualPrimitiveDontUnifyDifferentAtoms()
        {
            StructureObject so = new StructureObject("=", "a", "b");
            PrologMachine   pm = new PrologMachine();

            Assert.IsFalse(pm.Resolve(so));
        }
예제 #7
0
        public void AtomicPrimitiveAcceptsAtom()
        {
            StructureObject so = new StructureObject("atomic", "a");
            PrologMachine   pm = new PrologMachine();

            Assert.IsTrue(pm.Resolve(so));
        }
예제 #8
0
        public void EqualPrimitiveUnifyVariables()
        {
            StructureObject so = new StructureObject("=", "Y", "X");
            PrologMachine   pm = new PrologMachine();

            Assert.IsTrue(pm.Resolve(so));
        }
예제 #9
0
        public void NonVarPrimitiveRejectsVariable()
        {
            StructureObject so = new StructureObject("nonvar", "X");
            PrologMachine   pm = new PrologMachine();

            Assert.IsFalse(pm.Resolve(so));
        }
예제 #10
0
        public void NonVarPrimitiveAcceptsStructure()
        {
            StructureObject so = new StructureObject("nonvar", new StructureObject("foo", "bar"));
            PrologMachine   pm = new PrologMachine();

            Assert.IsTrue(pm.Resolve(so));
        }
예제 #11
0
        public void EqualPrimitiveUnifyInternalAtomVariable()
        {
            StructureObject so = new StructureObject("=", new StructureObject("f", "a"), new StructureObject("f", "X"));
            PrologMachine   pm = new PrologMachine();

            Assert.IsTrue(pm.Resolve(so));
            Assert.AreEqual("a", pm.GetVariable(0).Dereference().ToString());
        }
예제 #12
0
        public void EqualPrimitiveUnifyAtomWithVariable()
        {
            StructureObject so = new StructureObject("=", "a", "X");
            PrologMachine   pm = new PrologMachine();

            Assert.IsTrue(pm.Resolve(so));
            Assert.AreEqual(so.Parameters[0], pm.GetVariable(0).Dereference());
        }