public void DontMatchDifferentAtoms() { MatchBody match = new MatchBody(new Atom("a"), new ConstantExpression(1)); var context = match.MakeContext(new Atom("b"), null); Assert.IsNull(context); }
public void ReceiveMessageWithNoMatch() { Process process = new Process(); process.Tell(new Atom("foo")); Process.Current = process; MatchBody match = new MatchBody(new Atom("ping"), new ConstantExpression("pong")); ReceiveExpression expr = new ReceiveExpression(new MatchBody[] { match }); Assert.IsFalse(expr.HasVariable()); Assert.IsNull(expr.Evaluate(null)); }
public void MatchVariableInteger() { MatchBody match = new MatchBody(new Variable("X"), new VariableExpression(new Variable("X"))); var context = match.MakeContext(123, null); Assert.IsNotNull(context); var result = match.Evaluate(context); Assert.IsNotNull(result); Assert.AreEqual(123, result); }
public void MatchAtoms() { MatchBody match = new MatchBody(new Atom("a"), new ConstantExpression(1)); var context = match.MakeContext(new Atom("a"), null); Assert.IsNotNull(context); var result = match.Evaluate(context); Assert.IsNotNull(result); Assert.AreEqual(1, result); }
public void ReceiveMessage() { Process process = new Process(); process.Tell(new Atom("ping")); Process.Current = process; MatchBody match = new MatchBody(new Atom("ping"), new ConstantExpression("pong")); ReceiveExpression expr = new ReceiveExpression(new MatchBody[] { match }); Assert.IsFalse(expr.HasVariable()); var result = expr.Evaluate(null); Assert.IsNotNull(result); Assert.AreEqual("pong", result); }