Esempio n. 1
0
        public void Test10()
        {
            Tset s1 = new Tset(P1, P2);
            Tset s2 = new Tset(P1, P2, P3);

            Assert.AreEqual(false, s2.IsSubsetOf(s1).Out);
        }
Esempio n. 2
0
        public void Test7()
        {
            Tset s1 = new Tset(P1, P2);
            Tset s2 = new Tset(P1);

            Assert.AreEqual(true, s2.IsSubsetOf(s1).Out);
        }
Esempio n. 3
0
 public void Complement4()
 {
     Tset s1 = new Tset(P1,P2,P3);
     Tset s2 = new Tset(P2,P3);
     Tset res = s1 - s2;
     Assert.AreEqual("P1", res.Out);
 }
Esempio n. 4
0
        public void Count3()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Assert.AreEqual(0, s1.Count.Out);
        }
        public void AllKnownPeople2()
        {
            Facts.Clear();
            Tset result = Facts.AllKnownPeople();

            Assert.AreEqual("", result.Out);
        }
        public void Filter3()
        {
            Facts.Clear();

            Thing P1 = new Thing("P1");
            Thing P3 = new Thing("P3");
            Thing P4 = new Thing("P4");

            Tbool tb1 = new Tbool(false);

            tb1.AddState(new DateTime(2005, 12, 20), true);

            Tbool tb2 = new Tbool(false);

            tb2.AddState(new DateTime(2008, 3, 8), true);

            Facts.Assert(P1, "IsParentOf", P3, tb1);
            Facts.Assert(P1, "IsParentOf", P4, tb2);
            Facts.Assert(P1, "IsParentOf", P1, false);  // An absurd thing to have to assert

            Tset people = new Tset(P1, P3, P4);
            Tset result = people.Filter(_ => IsParentOf(P1, _));

            Assert.AreEqual("{Dawn: ; 12/20/2005: P3; 3/8/2008: P3, P4}", result.Out);
        }
        public void Filter1()
        {
            NewTest();
            Tset theAssets = TheThings().Filter(_ => Owns(M, _));

            Assert.AreEqual("{Dawn: A, B; 1/1/2005: A, B, C; 1/1/2008: A, C}", theAssets.Out);
        }
Esempio n. 8
0
        public void Test1_2()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Assert.AreEqual("", s1.Out);
        }
Esempio n. 9
0
        public void IsEmpty2()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Assert.AreEqual(true, s1.IsEmpty.Out);
        }
Esempio n. 10
0
        public void Test22()
        {
            Tset s1 = new Tset();

            s1.SetEternally();
            Assert.AreEqual(false, s1.Contains(P3).Out);
        }
Esempio n. 11
0
        public void Test_AsOf_2()
        {
            Tset s1 = new Tset();

            s1.AddState(Time.DawnOf, P1, P2);
            s1.AddState(Time.DawnOf.AddYears(3), P2);
            Assert.AreEqual("P1, P2", s1.AsOf(Time.DawnOf.AddYears(2)).Out);        // Lean not working
        }
Esempio n. 12
0
        public void Test75()
        {
            Tset  s1  = new Tset(P1, P2, P3);
            Tset  s2  = new Tset(P1, P2, P3);
            Tbool res = s1 != s2;

            Assert.AreEqual(false, res.Out);
        }
Esempio n. 13
0
        public void Test0_1()
        {
            Tset s1 = new Tset();

            s1.AddState(Time.DawnOf, P1);
            s1.AddState(Time.DawnOf.AddYears(1), P1);
            Assert.AreEqual("P1", s1.Lean.Out);
        }
Esempio n. 14
0
        public void Complement6()
        {
            Tset s1  = new Tset(Hstate.Unstated);
            Tset s2  = new Tset(P2, P3);
            Tset res = s2 - s1;

            Assert.AreEqual("Unstated", res.Out);
        }
Esempio n. 15
0
        public void Complement4()
        {
            Tset s1  = new Tset(P1, P2, P3);
            Tset s2  = new Tset(P2, P3);
            Tset res = s1 - s2;

            Assert.AreEqual("P1", res.Out);
        }
Esempio n. 16
0
        public void Intersection5()
        {
            Tset s1  = new Tset(Hstate.Stub);
            Tset s2  = new Tset(P2, P3);
            Tset res = s1 & s2;

            Assert.AreEqual("Stub", res.Out);
        }
Esempio n. 17
0
        public void Intersection4()
        {
            Tset s1  = new Tset(P1, P2, P3);
            Tset s2  = new Tset(P2, P3);
            Tset res = s1 & s2;

            Assert.AreEqual("P2, P3", res.Out);
        }
Esempio n. 18
0
        public void Union4()
        {
            Tset s1  = new Tset(Hstate.Stub);
            Tset s2  = new Tset(P2, P3);
            Tset res = s1 | s2;

            Assert.AreEqual("Stub", res.Out);
        }
Esempio n. 19
0
        public void Union2()
        {
            Tset s1  = new Tset(P1);
            Tset s2  = new Tset(P2, P3);
            Tset res = s1 | s2;

            Assert.AreEqual("P1, P2, P3", res.Out);
        }
Esempio n. 20
0
        public void Test65()
        {
            Tset  s1  = new Tset(P1, P2, P3);
            Tset  s2  = new Tset(P1, P2, P3);
            Tbool res = s1 == s2;

            Assert.AreEqual(true, res.Out);
        }
        public void OrderBy1()
        {
            NewTest();
            Tset theAssets     = TheThings().Filter(_ => Owns(M, _));
            Tset orderedAssets = theAssets.OrderBy(x => AssetValue((Thing)x) * -1);

            Assert.AreEqual("{Dawn: B, A; 1/1/2005: C, B, A; 1/1/2008: C, A}", orderedAssets.Out);
        }
Esempio n. 22
0
        public void Test11()
        {
            Tset s1 = new Tset(P1, P2);
            Tset s2 = new Tset();

            s2.SetEternally();
            Assert.AreEqual(true, s2.IsSubsetOf(s1).Out);
        }
        public void Exists_1()
        {
            NewTest();
            Tset  theAssets         = TheThings().Filter(_ => Owns(M, _));
            Tbool areAnyCheapAssets = theAssets.Exists(x => AssetValueLessThan4(x));

            Assert.AreEqual(true, areAnyCheapAssets.Out);
        }
        public void Exists_3_Unknown()
        {
            NewTest();
            Tset  theAssets         = TheThings().Filter(_ => Owns(M, _));
            Tbool areAnyCheapAssets = theAssets.Exists(x => AssetValueIndeterminacy(x));

            Assert.AreEqual("Unstated", areAnyCheapAssets.Out);
        }
        public void Exists_2_Unknown()
        {
            NewTest();
            Tset  theAssets         = new Tset(Hstate.Unstated);
            Tbool areAnyCheapAssets = theAssets.Exists(x => AssetValueLessThan4(x));

            Assert.AreEqual("Unstated", areAnyCheapAssets.Out);
        }
        public void Set_Sum_Unknown_1()
        {
            NewTest();
            Tset theAssets   = new Tset(Hstate.Unstated);
            Tnum sumOfAssets = theAssets.Sum(x => AssetValue((Thing)x));

            Assert.AreEqual("Unstated", sumOfAssets.Out);
        }
        public void Set_Sum_Unknown_2()
        {
            NewTest();
            Tset theAssets   = TheThings().Filter(_ => Owns(M, _));
            Tnum sumOfAssets = theAssets.Sum(x => NullFcn(x));

            Assert.AreEqual("Stub", sumOfAssets.Out);
        }
        public void ForAll1()
        {
            NewTest();
            Tset  theAssets         = TheThings().Filter(_ => Owns(M, _));
            Tbool allAssetsAreCheap = theAssets.ForAll(x => AssetValueLessThan4((Thing)x));

            Assert.AreEqual("{Dawn: true; 1/14/2011: false}", allAssetsAreCheap.Out);
        }
Esempio n. 29
0
        public void Unknown_Subset_1()
        {
            Thing P1 = new Thing("P1");
            Thing P2 = new Thing("P2");
            Tset  s1 = new Tset(P1, P2);

            Assert.AreEqual(eternallyUnstated, theSet.IsSubsetOf(s1).Out);
        }
        public void Set_Sum2()
        {
            NewTest();
            Tset theAssets   = TheThings().Filter(_ => Owns(M, _));
            Tnum sumOfAssets = theAssets.Sum(x => AssetValue((Thing)x));

            Assert.AreEqual("{Dawn: 3; 1/1/2005: 6; 1/1/2008: 4; 1/14/2011: 5}", sumOfAssets.Out);
        }
        public void Filter6()
        {
            NewTest();
            Tset theAssets   = TheThings().Filter(_ => Owns(M, _));
            Tset cheapAssets = theAssets.Filter(x => AssetValueLessThan4((Thing)x));

            Assert.AreEqual("{Dawn: A, B; 1/1/2005: A, B, C; 1/1/2008: A, C; 1/14/2011: A}", cheapAssets.Out);
        }
Esempio n. 32
0
 public void Complement3()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Tset s2 = new Tset(P2,P3);
     Tset res = s1 - s2;
     Assert.AreEqual("", res.Out);
 }
Esempio n. 33
0
 public void Unknown_Subset_1()
 {
     Thing P1 = new Thing("P1");
     Thing P2 = new Thing("P2");
     Tset s1 = new Tset(P1,P2);
     Assert.AreEqual(eternallyUnstated, theSet.IsSubsetOf(s1).Out);
 }
Esempio n. 34
0
 public void Unknown_SetEquality_2()
 {
     Thing P1 = new Thing("P1");
     Thing P2 = new Thing("P2");
     Tset s1 = new Tset(P1,P2);
     Tbool res = s1 != theSet;
     Assert.AreEqual(eternallyUnstated, res.Out);
 }
 public void ObjectAsOf2()
 {
     Thing P1 = new Thing("P1");
     Tset tsv = new Tset(Hstate.Stub);
     tsv.AddState(Date(2000,01,01),P1);
     tsv.AddState(Date(2001,01,01),Hstate.Uncertain);
     Assert.AreEqual(Hstate.Uncertain, tsv.ObjectAsOf(Date(2002,02,01)).Val);
 }
 private static Tbool SomeoneWorksAt(Thing c, Tset theSet)
 {
     return theSet.Exists( _ => Econ.IsEmployedBy(_,c));
 }
Esempio n. 37
0
 public void Test9()
 {
     Tset s1 = new Tset(P1,P2,P3);
     Tset s2 = new Tset(P1,P2);
     Assert.AreEqual(true, s2.IsSubsetOf(s1).Out);
 }
Esempio n. 38
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);
 }
Esempio n. 39
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);
 }
        public void Filter4()
        {
            Facts.Clear();

            Thing P1 = new Thing("P1");
            Thing P3 = new Thing("P3");
            Thing P4 = new Thing("P4");

            Facts.Assert(P1, "IsParentOf", P3, true);
            Facts.Assert(P1, "IsParentOf", P4, true);
            Facts.Assert(P4, "IsParentOf", P3, false);
            Facts.Assert(P3, "IsParentOf", P3, false);

            Tset people = new Tset(P1,P3,P4);
            Tset result = people.Filter( _ => IsParentOf(_,P3));
            Assert.AreEqual("P1", result.Out);
        }
        public void Filter3()
        {
            Facts.Clear();

            Thing P1 = new Thing("P1");
            Thing P3 = new Thing("P3");
            Thing P4 = new Thing("P4");

            Tbool tb1 = new Tbool(false);
            tb1.AddState(new DateTime(2005,12,20),true);

            Tbool tb2 = new Tbool(false);
            tb2.AddState(new DateTime(2008,3,8),true);

            Facts.Assert(P1, "IsParentOf", P3, tb1);
            Facts.Assert(P1, "IsParentOf", P4, tb2);
            Facts.Assert(P1, "IsParentOf", P1, false);  // An absurd thing to have to assert

            Tset people = new Tset(P1,P3,P4);
            Tset result = people.Filter( _ => IsParentOf(P1,_));

            Assert.AreEqual("{Dawn: ; 12/20/2005: P3; 3/8/2008: P3, P4}", result.Out);
        }
        public void Filter2()
        {
            Facts.Clear();

            Thing P1 = new Thing("P1");
            Thing P3 = new Thing("P3");
            Thing P4 = new Thing("P4");

            Facts.Assert(P1, "IsParentOf", P3, true);
            Facts.Assert(P1, "IsParentOf", P4, true);
            Facts.Assert(P1, "IsParentOf", P1, false);  // An absurd thing to have to assert

            Tset people = new Tset(P1,P3,P4);
            Tset result = people.Filter( _ => IsParentOf(P1,_));

            Assert.AreEqual("P3, P4", result.Out);
        }
 public void Exists_2_Unknown()
 {
     NewTest();
     Tset theAssets = new Tset(Hstate.Unstated);
     Tbool areAnyCheapAssets = theAssets.Exists(x => AssetValueLessThan4(x));
     Assert.AreEqual("Unstated", areAnyCheapAssets.Out);
 }
 public void CountUnknown1()
 {
     Thing P1 = new Thing("P1");
     Tset tsv = new Tset(Hstate.Stub);
     tsv.AddState(Date(2000,01,01),P1);
     tsv.AddState(Date(2001,01,01),Hstate.Uncertain);
     Assert.AreEqual("{Dawn: Stub; 1/1/2000: 1; 1/1/2001: Uncertain}", tsv.Count.Out);
 }
Esempio n. 45
0
 public void Test65()
 {
     Tset s1 = new Tset(P1,P2,P3);
     Tset s2 = new Tset(P1,P2,P3);
     Tbool res = s1 == s2;
     Assert.AreEqual(true, res.Out);
 }
Esempio n. 46
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";
                    }
                }
            }
        }
 public void Filter5a()
 {
     Facts.Clear();
     Thing P1 = new Thing("P1");
     Tset people = new Tset(P1);
     Tset result = people.Filter( _ => IsParentOf(_,P1));
     Assert.AreEqual("Unstated", result.Out); // Compare with the test Filter5b below
 }
Esempio n. 48
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);
 }
Esempio n. 49
0
 public void Test22()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Assert.AreEqual(false, s1.Contains(P3).Out);
 }
Esempio n. 50
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);
 }
Esempio n. 51
0
 public void Test1_2()
 {
     Tset s1 = new Tset();
     s1.SetEternally();
     Assert.AreEqual("", s1.Out);
 }
Esempio n. 52
0
 public void Union4()
 {
     Tset s1 = new Tset(Hstate.Stub);
     Tset s2 = new Tset(P2,P3);
     Tset res = s1 | s2;
     Assert.AreEqual("Stub", res.Out);
 }
Esempio n. 53
0
 public void Test_AsOf_2()
 {
     Tset s1 = new Tset();
     s1.AddState(Time.DawnOf, P1, P2);
     s1.AddState(Time.DawnOf.AddYears(3), P2);
     Assert.AreEqual("P1, P2", s1.AsOf(Time.DawnOf.AddYears(2)).Out);        // Lean not working
 }
Esempio n. 54
0
 public void Union2()
 {
     Tset s1 = new Tset(P1);
     Tset s2 = new Tset(P2,P3);
     Tset res = s1 | s2;
     Assert.AreEqual("P1, P2, P3", res.Out);
 }
 public void Filter5b()
 {
     Facts.Clear();
     Thing P1 = new Thing("P1");
     Tset people = new Tset(P1);
     Facts.Assert(P1, "IsParentOf", P1, false);
     Tset result = people.Filter( _ => IsParentOf(_,P1));
     Assert.AreEqual("", result.Out);
 }
Esempio n. 56
0
        public void TestOutput1()
        {
            string val = "ham; beans";
            string[] items = val.Split(new char[] {';'});
            List<Thing> list = new List<Thing>();

            foreach (string i in items)
            {
                list.Add(new Thing(i.Trim()));
            }

            Tset result = new Tset(list);
            Assert.AreEqual("ham, beans", result.Out);
        }
 public void Set_Sum_Unknown_1()
 {
     NewTest();
     Tset theAssets = new Tset(Hstate.Unstated);
     Tnum sumOfAssets = theAssets.Sum(x => AssetValue((Thing)x));
     Assert.AreEqual("Unstated", sumOfAssets.Out);
 }
 private static Tbool AllAreMale(Tset theSet)
 {
     return theSet.ForAll( _ => Facts.QueryTvar<Tstr>("Gender", _) == "Male");
 }
Esempio n. 59
0
 public void Complement6()
 {
     Tset s1 = new Tset(Hstate.Unstated);
     Tset s2 = new Tset(P2,P3);
     Tset res = s2 - s1;
     Assert.AreEqual("Unstated", res.Out);
 }
Esempio n. 60
0
 public void Test75()
 {
     Tset s1 = new Tset(P1,P2,P3);
     Tset s2 = new Tset(P1,P2,P3);
     Tbool res = s1 != s2;
     Assert.AreEqual(false, res.Out);
 }