public void ReturnParenthesizedNullLitteral() { var code = @" public Type f() { return (null); } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void AssignmentInBinaryOperator() { var code = @" void f(int a, int b) { a = (b = 2) + 1; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void MethodGroup() { var code = @" public static Func<string, bool> CreateFilter() { return string.IsNullOrEmpty; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void IgnoreParenthesesInAssignment() { var code = @" void f(int a, int b) { a = (b = 2); } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void SimpleLambdaExpression() { var code = @" public System.Linq.Expressions.Expression<Func<int, int>> F() { return x => 2*x; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void ParenthesizedLambdaExpression() { var code = @" Action f() { return () => Y(); } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void UnnamedFunctionParameter() { var code = @" int Func(int, int, int i) { return 2*i; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void ParamsKeyword() { var code = @" public void f(params int[] args) { } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void ChainingAssignments() { var code = @" void f(int i) { int j = i = 0; i = j = 10; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void UnknownMethodOnMultipleLines() { var code = @" void f(int i, int j) { g(i, j); } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void ArrayAssignment() { var code = @" void f() { int[] array = new int[5]; array[0] = 2; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void AnonymousObjectCreation() { var code = @" public int f() { var v = new { a = 108, m = ""Hello"" }; return v.a; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void Goto() { var code = @" void f() { goto Label; Label: return; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void AsyncFunction() { var code = @" class A { async System.Threading.Tasks.Task<int> FuncAsync() { return 3; } } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void CommentsWithNewLine() { var code = @" void f() { new A() { i = 3 }; // Noncompliant // ^^^^^^^^^ new A() { i = 4 }; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void ForWithoutCondition() { var code = @" void f(int i) { for (;;) { i = i + 1; } } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void Enum() { var code = @" using System; public enum Color { Red, Green, Blue }; private enum Color { Red, Green, Blue }; class A { private Color WorkWithEnum(int i, Color col) { if (col == Color.Blue && i == (int)col) { Color c = Color.Blue; return c; } else { return Color.Red; } } private Color WorkWithUnaccessibleEnum(int i, Color col) { if (col == Color.Blue && i == (int)col) { Color c = Color.Blue; return c; } else { return Color.Red; } } private ConsoleColor WorkWithExternalEnum(int i, ConsoleColor col) { if (col == ConsoleColor.Blue && i == (int)col) { Color c = ConsoleColor.Blue; return c; } else { return ConsoleColor.Red; } } } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void MixingUintAndNeg() { var code = @" void f() { int j = -10u; } void g() { int someInt = -2147483648; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void UnsafeClass() { var code = @" unsafe class C { int f() { int j = 1; return j+1; } } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void Namespace() { var code = @" namespace Tests { public static void f() { Tests.g(); } } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void NonASCIIEncodings() { var code = @" public void 你好() { } public void Łódź() { } public void AsciiThen你好ThenAsciiAgain() { } public int Łódźअनुلمرadım(int 你好) { return 2 * 你好; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void UnknownConstant() { var code = @" class A { private const object NullConst = null; void f() { NullConst.ToString(); } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void ParenthesizedExpressions() { var code = @" public void f(int i, int j) { var k = ((i) + j); if (((k) == 0)) { (i = k); } } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void InfiniteLoop() { var code = @" int InfiniteLoop(int i) { while (true) { if (++i == 42) { return i; } } // No return here } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void AssignmentInComparison() { var code = @" int f(int a, int b) { if ((a = 3) < (b = 2)) { return 0; } return 1; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void NestedFunction() { var code = @" void f() { var s = g(); int g() { return 0; } } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void UnaryNeg() { var code = @" public bool neg() { int i = -12; int j = -i; if (i + j == 0) { return true; } return false; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void BooleanConstant() { var code = @" public class A { internal const bool myBool = true; void f() { var b = myBool; } } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void UnaryPlus() { var code = @" public bool plus() { int i = +12; int j = +i; if (i - j == 0) { return true; } return false; } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }
public void UseOfConstantClassField() { var code = @" public class A { const int a = 0; public int getA() { return a; } } "; MlirTestUtilities.ValidateCodeGeneration(code, TestContext.TestName); }