public void LoopHeaderBlockExpression() { var sst = new LoopHeaderBlockExpression { Body = { new ContinueStatement(), new BreakStatement() } }; AssertPrint( sst, "", "{", " continue;", " break;", "}"); }
public void VisitorWithReturnIsImplemented() { var sut = new LoopHeaderBlockExpression(); sut.Accept(23).VerifyWithReturn(v => v.Visit(sut, 23)); }
public void ComplexInlineIfElse() { CompleteInClass(@" public void A(object o1, object o2, object o3) { var compare = (o2.GetHashCode() > o3.GetHashCode()) ? o1.ToString().Equals(o2.ToString()) : o1.ToString().Equals(o3.ToString()); $ } "); var mA = NewMethodDeclaration( Fix.Void, "A", string.Format("[{0}] o1", Fix.Object), string.Format("[{0}] o2", Fix.Object), string.Format("[{0}] o3", Fix.Object)); mA.Body.Add(SSTUtil.Declare("compare", Fix.Bool)); var ifBlock = new LoopHeaderBlockExpression(); // {Value = new[] {"$0", "$1"}}; ifBlock.Body.Add(SSTUtil.Declare("$0", Fix.Int)); ifBlock.Body.Add( SSTUtil.AssignmentToLocal("$0", SSTUtil.InvocationExpression("o2", Fix.GetHashCode(Fix.Object)))); ifBlock.Body.Add(SSTUtil.Declare("$1", Fix.Int)); ifBlock.Body.Add( SSTUtil.AssignmentToLocal("$1", SSTUtil.InvocationExpression("o3", Fix.GetHashCode(Fix.Object)))); var thenBlock = new LoopHeaderBlockExpression(); //) {Value = new[] {"$4"}}; thenBlock.Body.Add(SSTUtil.Declare("$2", Fix.String)); thenBlock.Body.Add( SSTUtil.AssignmentToLocal("$2", SSTUtil.InvocationExpression("o1", Fix.ToString(Fix.Object)))); thenBlock.Body.Add(SSTUtil.Declare("$3", Fix.String)); thenBlock.Body.Add( SSTUtil.AssignmentToLocal("$3", SSTUtil.InvocationExpression("o2", Fix.ToString(Fix.Object)))); thenBlock.Body.Add(SSTUtil.Declare("$4", Fix.Bool)); thenBlock.Body.Add( SSTUtil.AssignmentToLocal( "$4", SSTUtil.InvocationExpression( "$2", Fix.Equals(Fix.String, Fix.String, "value"), new[] { RefExpr("$3") }))); var elseBlock = new LoopHeaderBlockExpression(); //) {Value = new[] {"$7"}}; elseBlock.Body.Add(SSTUtil.Declare("$5", Fix.String)); //elseBlock.Body.Add(SSTUtil.AssignmentToLocal("$5", InvocationExpression("o1", Fix.ToString(Fix.Object)))); elseBlock.Body.Add(SSTUtil.Declare("$6", Fix.String)); //elseBlock.Body.Add(SSTUtil.AssignmentToLocal("$6", InvocationExpression("o3", Fix.ToString(Fix.Object)))); elseBlock.Body.Add(SSTUtil.Declare("$7", Fix.Bool)); elseBlock.Body.Add( SSTUtil.AssignmentToLocal( "$7", SSTUtil.InvocationExpression( "$5", Fix.Equals(Fix.String, Fix.String, "value"), new[] { RefExpr("$6") }))); // mA.Body.Add( // new Assignment( // "compare", // new IfElseExpression {Condition = ifBlock, ThenExpression = thenBlock, ElseExpression = elseBlock})); AssertAllMethods(mA); }