public void Equals() { IList <IExpression> keyexprs1 = new IExpression[] { new ConstantExpression(new Symbol("one")), new ConstantExpression(new Symbol("three")) }; IList <IExpression> valueexprs1 = new IExpression[] { new ConstantExpression("one"), new ConstantExpression("three") }; IList <IExpression> keyexprs2 = new IExpression[] { new ConstantExpression(new Symbol("one")), new ConstantExpression(new Symbol("two")) }; IList <IExpression> valueexprs2 = new IExpression[] { new ConstantExpression("one"), new ConstantExpression("two") }; HashExpression expr1 = new HashExpression(keyexprs1, valueexprs1); HashExpression expr2 = new HashExpression(keyexprs1, valueexprs2); HashExpression expr3 = new HashExpression(keyexprs2, valueexprs1); HashExpression expr4 = new HashExpression(keyexprs2, valueexprs2); HashExpression expr5 = new HashExpression(keyexprs1, valueexprs1); Assert.IsFalse(expr1.Equals(null)); Assert.IsFalse(expr1.Equals("foo")); Assert.IsFalse(expr1.Equals(123)); Assert.IsTrue(expr1.Equals(expr1)); Assert.IsTrue(expr1.Equals(expr5)); Assert.IsTrue(expr5.Equals(expr1)); Assert.AreEqual(expr1.GetHashCode(), expr5.GetHashCode()); Assert.IsFalse(expr1.Equals(expr2)); Assert.IsFalse(expr2.Equals(expr1)); Assert.IsFalse(expr1.Equals(expr3)); Assert.IsFalse(expr3.Equals(expr1)); Assert.IsFalse(expr1.Equals(expr4)); Assert.IsFalse(expr4.Equals(expr1)); }
private IExpression ParseHashExpression() { var hash = new HashExpression { Token = CurToken }; hash.Data = ParseHashPairs(); return(hash); }
public void ParseEmptyHash() { Parser parser = new Parser("{ }"); var expected = new HashExpression(new IExpression[0], new IExpression[0]); var result = parser.ParseExpression(); Assert.IsNotNull(result); Assert.AreEqual(expected, result); Assert.IsNull(parser.ParseCommand()); }
public void ParseSimpleHash() { Parser parser = new Parser("{ :one=>1, :two => 2 }"); var expected = new HashExpression(new IExpression[] { new ConstantExpression(new Symbol("one")), new ConstantExpression(new Symbol("two")) }, new IExpression[] { new ConstantExpression(1), new ConstantExpression(2) }); var result = parser.ParseExpression(); Assert.IsNotNull(result); Assert.AreEqual(expected, result); Assert.IsNull(parser.ParseCommand()); }
public void EvaluateWithSymbolKeys() { IList <IExpression> keyexprs = new IExpression[] { new ConstantExpression(new Symbol("one")), new ConstantExpression(new Symbol("three")) }; IList <IExpression> valueexprs = new IExpression[] { new ConstantExpression("one"), new ConstantExpression("three") }; HashExpression expr = new HashExpression(keyexprs, valueexprs); var result = expr.Evaluate(null); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IDictionary)); var dict = (IDictionary)result; Assert.AreEqual("one", dict[new Symbol("one")]); Assert.AreEqual("three", dict[new Symbol("three")]); }
public override void Accept(HashExpression hash) { hash.VisitChildren(this); }
public override void Accept(HashExpression hash) { hash.VisitChildren(this); methodBuilder.EmitInstruction(hash.Location, Opcode.BuildHash, hash.Children.Count / 2); }
public override void Accept(HashExpression hash) { hash.Visit(functionCompiler); }
public virtual void Accept(HashExpression hash) { }
public override void Accept(HashExpression hash) { hash.Visit(parentVisitor); }