public void ReplaceJumpToGoToIfNecessary() { var cu = new CompilationUnit().AddStatements(new Statement[] { new JumpStatement(false.ToLiteral(), 10) { StartOffset = 0, EndOffset = 5 }, new ExpressionStatement( new MethodInvocation("Print").AddArgument("Var1 is lower or equals to 0".ToLiteral())) { StartOffset = 5, EndOffset = 10 }, new ExpressionStatement( new MethodInvocation("Print").AddArgument("End".ToLiteral())) { StartOffset = 10, EndOffset = 15 } }); var expectedCu = new CompilationUnit().AddStatements(new Statement[] { new JumpStatement(false.ToLiteral(), 10) { StartOffset = 0, EndOffset = 5 }, new ExpressionStatement( new MethodInvocation("Print").AddArgument("Var1 is lower or equals to 0".ToLiteral())) { StartOffset = 5, EndOffset = 10 }, new ExpressionStatement( new MethodInvocation("Print").AddArgument("End".ToLiteral())) { StartOffset = 10, EndOffset = 15 } }); var actualCu = new ReplaceJumpToGoTo().Replace(cu); AstHelper.AstEquals(expectedCu, actualCu); }
public void ReplaceJumpToGoToIfNecessary() { var cu = new CompilationUnit().AddStatements(new Statement[] { new JumpStatement(false.ToLiteral(), 10){ StartOffset = 0, EndOffset = 5 }, new ExpressionStatement( new MethodInvocation("Print").AddArgument("Var1 is lower or equals to 0".ToLiteral())) { StartOffset = 5, EndOffset = 10 }, new ExpressionStatement( new MethodInvocation("Print").AddArgument("End".ToLiteral())) { StartOffset = 10, EndOffset = 15 } }); var expectedCu = new CompilationUnit().AddStatements(new Statement[] { new JumpStatement(false.ToLiteral(), 10){ StartOffset = 0, EndOffset = 5 }, new ExpressionStatement( new MethodInvocation("Print").AddArgument("Var1 is lower or equals to 0".ToLiteral())) { StartOffset = 5, EndOffset = 10 }, new ExpressionStatement( new MethodInvocation("Print").AddArgument("End".ToLiteral())) { StartOffset = 10, EndOffset = 15 } }); var actualCu = new ReplaceJumpToGoTo().Replace(cu); AstHelper.AstEquals(expectedCu, actualCu); }