예제 #1
0
        public void Test22()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Assert.AreEqual(false, s1.Contains(P3).Out);
        }
예제 #2
0
        public void Count3()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Assert.AreEqual(0, s1.Count.Out);
        }
예제 #3
0
        public void IsEmpty2()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Assert.AreEqual(true, s1.IsEmpty.Out);
        }
예제 #4
0
        public void Test1_2()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Assert.AreEqual("", s1.Out);
        }
예제 #5
0
        public void Test11()
        {
            Tset s1 = new Tset(P1, P2);
            Tset s2 = new Tset();

            s2.SetEternally();
            Assert.AreEqual(true, s2.IsSubsetOf(s1).Out);
        }
예제 #6
0
        public void Count2()
        {
            // This is how you assert an eternally empty set
            Tset s1 = new Tset();

            s1.SetEternally();
            Assert.AreEqual(0, s1.Count.Out);
        }
예제 #7
0
 public void Complement3()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Tset s2 = new Tset(P2,P3);
     Tset res = s1 - s2;
     Assert.AreEqual("", res.Out);
 }
예제 #8
0
        public void Union3()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Tset s2  = new Tset(P2, P3);
            Tset res = s1 | s2;

            Assert.AreEqual("P2, P3", res.Out);
        }
예제 #9
0
        public void Test74()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Tset  s2  = new Tset(P2, P3);
            Tbool res = s2 != s1;

            Assert.AreEqual(true, res.Out);
        }
예제 #10
0
        public void Test62()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Tset  s2  = new Tset(P2, P3);
            Tbool res = s1 == s2;

            Assert.AreEqual(false, res.Out);
        }
예제 #11
0
        public void Complement5()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Tset s2  = new Tset(P2, P3);
            Tset res = s2 - s1;

            Assert.AreEqual("P2, P3", res.Out);
        }
예제 #12
0
        public void Complement3()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Tset s2  = new Tset(P2, P3);
            Tset res = s1 - s2;

            Assert.AreEqual("", res.Out);
        }
예제 #13
0
        public void Intersection3()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Tset s2  = new Tset(P2, P3);
            Tset res = s1 & s2;

            Assert.AreEqual("", res.Out);
        }
예제 #14
0
 public void Union3()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Tset s2 = new Tset(P2,P3);
     Tset res = s1 | s2;
     Assert.AreEqual("P2, P3", res.Out);
 }
예제 #15
0
 public void Test74()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Tset s2 = new Tset(P2,P3);
     Tbool res = s2 != s1;
     Assert.AreEqual(true, res.Out);
 }
예제 #16
0
 public void Test62()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Tset s2 = new Tset(P2,P3);
     Tbool res = s1 == s2;
     Assert.AreEqual(false, res.Out);
 }
예제 #17
0
 public void Test22()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Assert.AreEqual(false, s1.Contains(P3).Out);
 }
예제 #18
0
 public void Test1_2()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Assert.AreEqual("", s1.Out);
 }
예제 #19
0
 public void Test12()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Tset s2 = new Tset(P1,P2);
     Assert.AreEqual(false, s2.IsSubsetOf(s1).Out);
 }
예제 #20
0
 public void IsEmpty2()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Assert.AreEqual(true, s1.IsEmpty.Out);
 }
예제 #21
0
 public void Intersection3()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Tset s2 = new Tset(P2,P3);
     Tset res = s1 & s2;
     Assert.AreEqual("", res.Out);
 }
예제 #22
0
        /// <summary>
        /// Asserts a fact.
        /// </summary>
        public static void AssertAnswer(Engine.Response response, string val)
        {
            // Get the data pertaining to the current question
            Thing  subj  = (Thing)response.NextFact.Arg1;
            Thing  obj   = (Thing)response.NextFact.Arg2;
            string rel   = response.NextFact.Relationship;
            string qType = Templates.GetQ(rel).questionType;

            // Create the fact/relationship text for the .akk unit test
            if (qType != "Tset")
            {
                AkkTest.testStr += AkkTest.assertedRelationship;
            }

            // Assert the fact (converted to the proper type of Tvar)
            if (qType == "Tbool")
            {
                // Asserts the fact (handling uncertainty)
                // Also, creates part of the .akk unit test string
                if (val == "?")
                {
                    Facts.Assert(subj, rel, obj, new Tbool(Hstate.Uncertain));
                    AkkTest.testStr += "Tbool(?)\r\n";
                }
                else
                {
                    Facts.Assert(subj, rel, obj, TboolFromTemporalString(val));
                    AkkTest.testStr += val + "\r\n";
                }
            }
            else if (qType == "Tstr")
            {
                if (val == "?")
                {
                    Facts.Assert(subj, rel, obj, new Tstr(Hstate.Uncertain));
                    AkkTest.testStr += "Tstr(?)\r\n";
                }
                else
                {
                    Facts.Assert(subj, rel, obj, TstrFromTemporalString(val));
                    AkkTest.testStr += "\"" + val + "\"\r\n";
                }
            }
            else if (qType == "Tnum")
            {
                if (val == "?")
                {
                    Facts.Assert(subj, rel, obj, new Tnum(Hstate.Uncertain));
                    AkkTest.testStr += "Tnum(?)\r\n";
                }
                else
                {
                    Facts.Assert(subj, rel, obj, TnumFromTemporalString(val));
                    AkkTest.testStr += val + "\r\n";
                }
            }
            else if (qType == "Tdate")
            {
                if (val == "?")
                {
                    Facts.Assert(subj, rel, obj, new Tdate(Hstate.Uncertain));
                    AkkTest.testStr += "Tdate(?)\r\n";
                }
                else
                {
                    Facts.Assert(subj, rel, obj, TdateFromTemporalString(val));
                    AkkTest.testStr += val + "\r\n";
                }
            }
            else if (qType == "Tset")
            {
                if (val == "?")
                {
                    Facts.Assert(subj, rel, obj, new Tset(Hstate.Uncertain));
                    AkkTest.testStr += "Tset(?)\r\n";
                }
                else
                {
                    // Assert an empty set
                    if (val == "[]")
                    {
                        Tset result = new Tset();
                        result.SetEternally();
                        Facts.Assert(subj, rel, obj, result);
                    }
                    else
                    {
                        // Create a list of Things
                        string[]     items     = val.Split(new char[] { ';' });
                        List <Thing> list      = new List <Thing>();
                        string       thingList = ""; // for .akk unit tests
                        foreach (string i in items)
                        {
                            string name = i.Trim();
                            list.Add(Facts.AddThing(name));
                            thingList += name + ",";
                        }

                        // Assert the Tset
                        Facts.Assert(subj, rel, obj, new Tset(list));

                        // Build the .akk unit test string
                        AkkTest.testStr += "- Things " + thingList.TrimEnd(',') + "\r\n";
                        AkkTest.testStr += AkkTest.assertedRelationship;
                        AkkTest.testStr += "[[" + val.Replace(";", ",") + "]]\r\n";
                    }
                }
            }
        }
예제 #23
0
 public void Complement5()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Tset s2 = new Tset(P2,P3);
     Tset res = s2 - s1;
     Assert.AreEqual("P2, P3", res.Out);
 }
예제 #24
0
 public void Count2()
 {
     // This is how you assert an eternally empty set
     Tset s1 = new Tset();
     s1.SetEternally();
     Assert.AreEqual(0, s1.Count.Out);
 }
예제 #25
0
        /// <summary>
        /// Asserts a fact.
        /// </summary>
        public static void AssertAnswer(Engine.Response response, string val)
        {
            // Get the data pertaining to the current question
            Thing subj = (Thing)response.NextFact.Arg1;
            Thing obj = (Thing)response.NextFact.Arg2;
            string rel = response.NextFact.Relationship;
            string qType = Templates.GetQ(rel).questionType;

            // Create the fact/relationship text for the .akk unit test
            if (qType != "Tset")  AkkTest.testStr += AkkTest.assertedRelationship;

            // Assert the fact (converted to the proper type of Tvar)
            if (qType == "Tbool")
            {
                // Asserts the fact (handling uncertainty)
                // Also, creates part of the .akk unit test string
                if (val == "?")
                {
                    Facts.Assert(subj, rel, obj, new Tbool(Hstate.Uncertain));
                    AkkTest.testStr += "Tbool(?)\r\n";
                }
                else
                {
                    Facts.Assert(subj, rel, obj, TboolFromTemporalString(val));
                    AkkTest.testStr += val + "\r\n";
                }
            }
            else if (qType == "Tstr")
            {
                if (val == "?")
                {
                    Facts.Assert(subj, rel, obj, new Tstr(Hstate.Uncertain));
                    AkkTest.testStr += "Tstr(?)\r\n";
                }
                else
                {
                    Facts.Assert(subj, rel, obj, TstrFromTemporalString(val));
                    AkkTest.testStr += "\"" + val + "\"\r\n";
                }
            }
            else if (qType == "Tnum")
            {
                if (val == "?")
                {
                    Facts.Assert(subj, rel, obj, new Tnum(Hstate.Uncertain));
                    AkkTest.testStr += "Tnum(?)\r\n";
                }
                else
                {
                    Facts.Assert(subj, rel, obj, TnumFromTemporalString(val));
                    AkkTest.testStr += val + "\r\n";
                }
            }
            else if (qType == "Tdate")
            {
                if (val == "?")
                {
                    Facts.Assert(subj, rel, obj, new Tdate(Hstate.Uncertain));
                    AkkTest.testStr += "Tdate(?)\r\n";
                }
                else
                {
                    Facts.Assert(subj, rel, obj, TdateFromTemporalString(val));
                    AkkTest.testStr += val + "\r\n";
                }
            }
            else if (qType == "Tset")
            {
                if (val == "?")
                {
                    Facts.Assert(subj, rel, obj, new Tset(Hstate.Uncertain));
                    AkkTest.testStr += "Tset(?)\r\n";
                }
                else
                {
                    // Assert an empty set
                    if (val == "[]")
                    {
                        Tset result = new Tset();
                        result.SetEternally();
                        Facts.Assert(subj, rel, obj, result);
                    }
                    else
                    {
                        // Create a list of Things
                        string[] items = val.Split(new char[] {';'});
                        List<Thing> list = new List<Thing>();
                        string thingList = "";      // for .akk unit tests
                        foreach (string i in items)
                        {
                            string name = i.Trim();
                            list.Add(Facts.AddThing(name));
                            thingList += name + ",";
                        }

                        // Assert the Tset
                        Facts.Assert(subj, rel, obj, new Tset(list));

                        // Build the .akk unit test string
                        AkkTest.testStr += "- Things " + thingList.TrimEnd(',') + "\r\n";
                        AkkTest.testStr += AkkTest.assertedRelationship;
                        AkkTest.testStr += "[[" + val.Replace(";",",") + "]]\r\n";
                    }
                }
            }
        }
예제 #26
0
 public void Count3()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Assert.AreEqual(0, s1.Count.Out);
 }