Пример #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);
 }