public void While_WhenCreatingWhileLoopWithBinaryExpression_ShouldGenerateCode() { var binaryExpression = new ConditionalBinaryExpression(new ConstantReference(1), new ConstantReference(2), ConditionalStatements.LessThan); Assert.AreEqual("while(1<2){}", _control.While(binaryExpression, BodyGenerator.Create()).ToString()); }
public void GetBinaryExpression_WhenHavingTwoReferencesAndEqual_ShouldGenerateCode() { var binaryExpression = new ConditionalBinaryExpression( new ConstantReference(1), new ConstantReference(2), ConditionalStatements.Equal); Assert.AreEqual("1==2", binaryExpression.GetBinaryExpression().ToString()); }
public void GetBinaryExpression_WhenHavingTwoConditionalBinaryExpressions_ShouldGenerateCode() { var leftBinaryExpression = new ConditionalBinaryExpression( new ConstantReference(1), new ConstantReference(2), ConditionalStatements.Equal); var rightBinaryExpression = new ConditionalBinaryExpression( new ConstantReference(1), new ConstantReference(2), ConditionalStatements.LessThan); var binaryExpression = new OrBinaryExpression( leftBinaryExpression, rightBinaryExpression); Assert.AreEqual("1==2||1<2", binaryExpression.GetBinaryExpression().ToString()); }
public void If_WhenCreatingAnComplexBinaryExpression_ShouldGenerateCorrectIfStatement() { var leftBinaryExpression = new ConditionalBinaryExpression( new ConstantReference(1), new ConstantReference(2), ConditionalStatements.Equal); var rightBinaryExpression = new ConditionalBinaryExpression( new ConstantReference(1), new ConstantReference(2), ConditionalStatements.LessThan); var orBinaryExpression = new OrBinaryExpression( leftBinaryExpression, rightBinaryExpression); var binaryExpression = new OrBinaryExpression( leftBinaryExpression, orBinaryExpression); Assert.AreEqual("if(1==2||1==2||1<2){}", conditional.If(binaryExpression, BodyGenerator.Create()).ToString()); }