Match() public method

public Match ( Tuple tuple, Context context ) : bool
tuple Tuple
context Context
return bool
Esempio n. 1
0
 public void MatchSimpleTuple()
 {
     Tuple tuple = new Tuple(new object[] { 1, 2, 3 });
     Tuple tuple2 = new Tuple(new object[] { 1, 2, 3 });
     Context context = new Context();
     Assert.IsTrue(tuple.Match(tuple2, context));
 }
Esempio n. 2
0
        public void MatchTuplesWithAVariable()
        {
            Tuple tuple = new Tuple(new object[] { 1, new Variable("X"), 3 });
            Tuple tuple2 = new Tuple(new object[] { 1, 2, 3 });
            Context context = new Context();
            Assert.IsTrue(tuple.Match(tuple2, context));
            Assert.AreEqual(2, context.GetValue("X"));

            Assert.IsTrue(tuple2.Match(tuple, context));

            Assert.AreEqual(2, context.GetValue("X"));
        }
Esempio n. 3
0
 public void NoMatchTuplesWithDifferentArities()
 {
     Tuple tuple = new Tuple(new object[] { 1, 2, 3 });
     Tuple tuple2 = new Tuple(new object[] { 1, 2, 3, 4 });
     Context context = new Context();
     Assert.IsFalse(tuple.Match(tuple2, context));
     Assert.IsFalse(tuple2.Match(tuple, context));
 }
Esempio n. 4
0
 public void MatchTuplesWithNullElement()
 {
     Tuple tuple = new Tuple(new object[] { 1, null, 3 });
     Tuple tuple2 = new Tuple(new object[] { 1, null, 3 });
     Context context = new Context();
     Assert.IsTrue(tuple.Match(tuple2, context));
 }
Esempio n. 5
0
 public void MatchNull()
 {
     Tuple tuple = new Tuple(new object[] { 1, 2, 3 });
     Context context = new Context();
     Assert.IsFalse(tuple.Match(null, context));
 }