Match() public method

public Match ( List list, Context context ) : bool
list List
context Context
return bool
Esempio n. 1
0
        public void NoMatchWithDifferentTails()
        {
            List list = new List(1, 0);
            List list2 = new List(1, 2);
            Context context = new Context();

            Assert.IsFalse(list.Match(list2, context));
            Assert.IsFalse(list2.Match(list, context));
        }
Esempio n. 2
0
        public void NoMatchNullList()
        {
            List list = new List(1, 2);
            Context context = new Context();

            Assert.IsFalse(list.Match(null, context));
        }
Esempio n. 3
0
        public void NoMatchTwoListsWithDifferentLength()
        {
            List list = new List(1, 2);
            List list2 = new List(1, new List(2, 3));
            Context context = new Context();

            Assert.IsFalse(list.Match(list2, context));
            Assert.IsFalse(list2.Match(list, context));
        }
Esempio n. 4
0
        public void MatchWithAVariable()
        {
            List list = new List(1, new Variable("X"));
            List list2 = new List(1, new List(2, 3));
            Context context = new Context();

            Assert.IsTrue(list.Match(list2, context));

            Assert.AreEqual(list2.Tail, context.GetValue("X"));

            Assert.IsTrue(list2.Match(list, context));

            Assert.AreEqual(list2.Tail, context.GetValue("X"));
        }
Esempio n. 5
0
        public void MatchTwoListsWithThreeElements()
        {
            List list = new List(1, new List(2, 3));
            List list2 = new List(1, new List(2, 3));
            Context context = new Context();

            Assert.IsTrue(list.Match(list2, context));
            Assert.IsTrue(list2.Match(list, context));
        }
Esempio n. 6
0
        public void MatchTwoLists()
        {
            List list = new List(1, 2);
            List list2 = new List(1, 2);
            Context context = new Context();

            Assert.IsTrue(list.Match(list2, context));
            Assert.IsTrue(list2.Match(list, context));
        }
Esempio n. 7
0
        public void MatchSameList()
        {
            List list = new List(1, 2);
            Context context = new Context();

            Assert.IsTrue(list.Match(list, context));
        }
Esempio n. 8
0
        public void MatchHeadAndTailWithVariables()
        {
            List list = new List(new Variable("H"), new Variable("T"));
            List list2 = new List(1, new List(2, 3));
            Context context = new Context();

            Assert.IsTrue(list.Match(list2, context));

            Assert.AreEqual(list2.Head, context.GetValue("H"));
            Assert.AreEqual(list2.Tail, context.GetValue("T"));

            Assert.IsTrue(list2.Match(list, context));

            Assert.AreEqual(list2.Head, context.GetValue("H"));
            Assert.AreEqual(list2.Tail, context.GetValue("T"));
        }