Exemplo n.º 1
0
        public void FT_ToString_3()
        {
            Tstr t = new Tstr("42");

            t.AddState(Date(2004, 2, 21), "43");
            Assert.AreEqual(null, t.ToString);
        }
Exemplo n.º 2
0
        public void Unknown_Concat_1()
        {
            Tstr ts2 = new Tstr(Hstate.Unstated);
            Tstr ts3 = " x" + ts2;

            Assert.AreEqual(eternallyUnstated, ts3.Out);
        }
Exemplo n.º 3
0
        public void Concat_2()
        {
            Tstr ts1 = new Tstr("hello,");
            Tstr ts2 = new Tstr("world");
            Tstr ts3 = ts1 + " " + ts2;

            Assert.AreEqual("hello, world", ts3.Out);
        }
Exemplo n.º 4
0
        public void TstrSwitch1_lazy()
        {
            Tstr result = Switch <Tstr>(() => false, () => "41",
                                        () => true, () => "42",
                                        () => new Tstr("43"));

            Assert.AreEqual("42", result.Out);
        }
Exemplo n.º 5
0
        public void FT_AsOf_6()
        {
            Tstr t = new Tstr("ham");

            t.AddState(Time.DawnOf.AddYears(5), "sam");
            Tstr res = t.AsOf(Time.DawnOf.AddYears(12));

            Assert.AreEqual("sam", res.Out);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Asserts a given fact (of the proper Tvar type)
        /// </summary>
        private static void AssertFact(Factoid f)
        {
            // Instantiate relevant Things
            Thing t1 = f.Arg1.ToString() != "" ? Facts.AddThing(f.Arg1.ToString()) : null;
            Thing t2 = f.Arg2.ToString() != "" ? Facts.AddThing(f.Arg2.ToString()) : null;
            Thing t3 = f.Arg3.ToString() != "" ? Facts.AddThing(f.Arg3.ToString()) : null;

            // Sometimes I have my doubts about static typing...
            if (f.FactType == "Tbool")
            {
                Tbool val = new Tbool();
                foreach (TemporalValue v in f.Timeline)
                {
                    val.AddState(v.Date, new Hval(v.Value));
                }
                Facts.Assert(t1, f.Relationship, t2, t3, val);
            }
            else if (f.FactType == "Tnum")
            {
                Tnum val = new Tnum();
                foreach (TemporalValue v in f.Timeline)
                {
                    val.AddState(v.Date, new Hval(v.Value));
                }
                Facts.Assert(t1, f.Relationship, t2, t3, val);
            }
            else if (f.FactType == "Tstr")
            {
                Tstr val = new Tstr();
                foreach (TemporalValue v in f.Timeline)
                {
                    val.AddState(v.Date, new Hval(v.Value));
                }
                Facts.Assert(t1, f.Relationship, t2, t3, val);
            }
            else if (f.FactType == "Tdate")
            {
                Tdate val = new Tdate();
                foreach (TemporalValue v in f.Timeline)
                {
                    val.AddState(v.Date, new Hval(v.Value));
                }
                Facts.Assert(t1, f.Relationship, t2, t3, val);
            }
            else if (f.FactType == "Tset")
            {
                Tset val = new Tset();
                foreach (TemporalValue v in f.Timeline)
                {
                    val.AddState(v.Date, new Hval(v.Value));
                }
                Facts.Assert(t1, f.Relationship, t2, t3, val);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a Tstr from a string representing a time-varying value.
        /// </summary>
        /// <remarks>
        /// Sample input: {2012-01-01: "Hello"; Time.DawnOf: "world"}
        /// </remarks>
        private static Tstr TstrFromTemporalString(string val)
        {
            if (val.StartsWith("{"))
            {
                Tstr result = new Tstr();
                foreach (string s in TimeValuePairs(val))
                {
                    string[] parts    = s.Split(new char[] { ':' });
                    DateTime datePart = Convert.ToDateTime(parts[0].Trim().Replace("Dawn", "1800-01-01"));
                    result.AddState(datePart, parts[1].Trim());
                }
                return(result);
            }

            return(new Tstr(val));
        }
 public void StringComparison14()
 {
     Tbool t = new Tstr("Hello, world!") != "Hello, world";
     Assert.AreEqual(true , t.Out);
 }
        public void StringComparison11()
        {
            Tbool t = new Tstr("Hello, world!") != new Tstr("Hello, world!");

            Assert.AreEqual(false, t.Out);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates a Tstr from a string representing a time-varying value.
        /// </summary>
        /// <remarks>
        /// Sample input: {2012-01-01: "Hello"; Time.DawnOf: "world"}
        /// </remarks>
        private static Tstr TstrFromTemporalString(string val)
        {
            if (val.StartsWith("{"))
            {
                Tstr result = new Tstr();
                foreach (string s in TimeValuePairs(val))
                {
                    string[] parts = s.Split(new char[] {':'});
                    DateTime datePart = Convert.ToDateTime(parts[0].Trim().Replace("Dawn","1800-01-01"));
                    result.AddState(datePart, parts[1].Trim());
                }
                return result;
            }

            return new Tstr(val);
        }
Exemplo n.º 11
0
        public void Concat_3()
        {
            Tstr ts1 = new Tstr("hello,") + " world";

            Assert.AreEqual("hello, world", ts1.Out);
        }
Exemplo n.º 12
0
        public void StringComparison14()
        {
            Tbool t = new Tstr("Hello, world!") != "Hello, world";

            Assert.AreEqual(true, t.Out);
        }
 public void FT_ToString_2()
 {
     Tstr t = new Tstr(Hstate.Stub);
     Assert.AreEqual(null, t.ToString);
 }
Exemplo n.º 14
0
 public void Unknown_Concat_1()
 {
     Tstr ts2 = new Tstr(Hstate.Unstated);
     Tstr ts3 = " x" + ts2;
     Assert.AreEqual(eternallyUnstated, ts3.Out);
 }
Exemplo n.º 15
0
        public void StringComparison5()
        {
            Tbool t = new Tstr(Hstate.Unstated) == "Hello, world";

            Assert.AreEqual("Unstated", t.Out);
        }
 public void FT_AsOf_7()
 {
     Tstr t = new Tstr("ham");
     t.AddState(Time.DawnOf.AddYears(5), "sam");
     Tstr res = t.AsOf(Time.DawnOf.AddYears(2));
     Assert.AreEqual("ham", res.Out);
 }
Exemplo n.º 17
0
        public void FT_ToString_2()
        {
            Tstr t = new Tstr(Hstate.Stub);

            Assert.AreEqual(null, t.ToString);
        }
Exemplo n.º 18
0
        public void FT_ToString_1()
        {
            Tstr t = new Tstr("42");

            Assert.AreEqual("42", t.ToString);
        }
 public void FT_ToString_3()
 {
     Tstr t = new Tstr("42");
     t.AddState(Date(2004,2,21), "43");
     Assert.AreEqual(null, t.ToString);
 }
 public void StringComparison4()
 {
     Tbool t = new Tstr("Hello, world!") == "Hello, world";
     Assert.AreEqual(false , t.Out);
 }
 public void StringComparison5()
 {
     Tbool t = new Tstr(Hstate.Unstated) == "Hello, world";
     Assert.AreEqual("Unstated", t.Out);
 }
 public void FT_ToString_1()
 {
     Tstr t = new Tstr("42");
     Assert.AreEqual("42", t.ToString);
 }