未验证 提交 c540d01d 编写于 作者: M Mark Plesko 提交者: GitHub

Remove some manual test scaffolding (#89653)

上级 7d7b0fa3
......@@ -4,151 +4,124 @@
using System;
using Xunit;
delegate void TestDelegate();
public class ArrayBounds
{
internal static void f1a()
{
int [] a = new int[4];
for (int i=0; i < a.Length; --i)
{
a[i]=1;
}
}
internal static void f2a()
{
int [] a = new int[4];
for (int i=0; i < a.Length; --i)
{
int b = a[i];
}
}
internal static void f3a()
{
int [] a = new int[4];
for (int i=0; i < a.Length; --i)
{
Console.WriteLine(a[i]);
}
}
internal static void f4a()
{
int [] a = new int[4];
for (int i=0; i < a.Length; a[i]=i,--i)
{
// empty
}
}
// ++i
internal static void f1b()
{
int [] a = new int[4];
for (int i=0; i <= a.Length; ++i)
{
a[i]=1;
}
}
internal static void f2b()
{
int [] a = new int[4];
for (int i=0; i <= a.Length; ++i)
{
int b = a[i];
}
}
internal static void f3b()
{
int [] a = new int[4];
for (int i=0; i <= a.Length; ++i)
{
Console.WriteLine(a[i]);
}
}
internal static void f4b()
{
int [] a = new int[4];
for (int i=0; i <= a.Length; a[i]=i,++i)
{
// empty
}
}
// ++i, 0x7fff
internal static void f1c()
{
bool [] a = new bool[0x7fff];
for (short i=0x7ff0; i < a.Length+1; ++i)
{
a[i]=true;
}
}
internal static void f2c()
{
bool [] a = new bool[0x7fff];
for (short i=0x7ff0; i < a.Length+1; ++i)
{
bool b = a[i];
}
}
internal static void f3c()
{
bool [] a = new bool[0x7fff];
for (short i=0x7ffe; i < a.Length+1; ++i)
{
Console.WriteLine(a[i]);
}
}
internal static void f4c()
{
bool [] a = new bool[0x7fff];
for (short i=0x7ff0; i < a.Length+1; ++i)
{
a[i] = true;
}
}
static int RunTests(TestDelegate d)
{
try
{
Console.Write(d.Method.Name + ": ");
d();
}
catch (IndexOutOfRangeException)
{
Console.WriteLine("IndexOutOfRangeException caught as expected");
return 100;
}
catch (Exception e)
{
Console.WriteLine("FAILED");
Console.WriteLine(e);
return 1;
}
internal static void f1a()
{
int [] a = new int[4];
for (int i=0; i < a.Length; --i)
{
a[i]=1;
}
}
internal static void f2a()
{
int [] a = new int[4];
for (int i=0; i < a.Length; --i)
{
int b = a[i];
}
}
internal static void f3a()
{
int [] a = new int[4];
for (int i=0; i < a.Length; --i)
{
Console.WriteLine(a[i]);
}
}
internal static void f4a()
{
int [] a = new int[4];
for (int i=0; i < a.Length; a[i]=i,--i)
{
// empty
}
}
Console.WriteLine("PASSED");
return 100;
}
// ++i
internal static void f1b()
{
int [] a = new int[4];
for (int i=0; i <= a.Length; ++i)
{
a[i]=1;
}
}
internal static void f2b()
{
int [] a = new int[4];
for (int i=0; i <= a.Length; ++i)
{
int b = a[i];
}
}
internal static void f3b()
{
int [] a = new int[4];
for (int i=0; i <= a.Length; ++i)
{
Console.WriteLine(a[i]);
}
}
internal static void f4b()
{
int [] a = new int[4];
for (int i=0; i <= a.Length; a[i]=i,++i)
{
// empty
}
}
[Fact]
public static int TestEntryPoint()
{
if (RunTests(new TestDelegate(f1a))!=100) return 1;
if (RunTests(new TestDelegate(f2a))!=100) return 1;
if (RunTests(new TestDelegate(f3a))!=100) return 1;
if (RunTests(new TestDelegate(f4a))!=100) return 1;
if (RunTests(new TestDelegate(f1b))!=100) return 1;
if (RunTests(new TestDelegate(f2b))!=100) return 1;
if (RunTests(new TestDelegate(f3b))!=100) return 1;
if (RunTests(new TestDelegate(f4b))!=100) return 1;
if (RunTests(new TestDelegate(f1c))!=100) return 1;
if (RunTests(new TestDelegate(f2c))!=100) return 1;
if (RunTests(new TestDelegate(f3c))!=100) return 1;
if (RunTests(new TestDelegate(f4c))!=100) return 1;
// ++i, 0x7fff
internal static void f1c()
{
bool [] a = new bool[0x7fff];
for (short i=0x7ff0; i < a.Length+1; ++i)
{
a[i]=true;
}
}
internal static void f2c()
{
bool [] a = new bool[0x7fff];
for (short i=0x7ff0; i < a.Length+1; ++i)
{
bool b = a[i];
}
}
internal static void f3c()
{
bool [] a = new bool[0x7fff];
for (short i=0x7ffe; i < a.Length+1; ++i)
{
Console.WriteLine(a[i]);
}
}
internal static void f4c()
{
bool [] a = new bool[0x7fff];
for (short i=0x7ff0; i < a.Length+1; ++i)
{
a[i] = true;
}
}
Console.WriteLine();
Console.WriteLine("PASSED");
return 100;
}
[Fact]
public static void TestEntryPoint()
{
Assert.Throws<IndexOutOfRangeException>(f1a);
Assert.Throws<IndexOutOfRangeException>(f2a);
Assert.Throws<IndexOutOfRangeException>(f3a);
Assert.Throws<IndexOutOfRangeException>(f4a);
Assert.Throws<IndexOutOfRangeException>(f1b);
Assert.Throws<IndexOutOfRangeException>(f2b);
Assert.Throws<IndexOutOfRangeException>(f3b);
Assert.Throws<IndexOutOfRangeException>(f4b);
Assert.Throws<IndexOutOfRangeException>(f1c);
Assert.Throws<IndexOutOfRangeException>(f2c);
Assert.Throws<IndexOutOfRangeException>(f3c);
Assert.Throws<IndexOutOfRangeException>(f4c);
}
}
......@@ -13,6 +13,7 @@
public class Program
{
[MethodImpl(MethodImplOptions.NoInlining)]
[Fact]
public static int Bar()
{
int sum = 0;
......@@ -31,20 +32,4 @@ public static int Bar()
return 100;
}
}
[Fact]
public static int TestEntryPoint()
{
try
{
if (Bar() != 100)
return 0;
}
catch (Exception)
{
}
Console.WriteLine("Pass");
return 100;
}
}
......@@ -31,7 +31,7 @@ public static S<T> GetS()
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static int TestS()
public static void TestS()
{
// Use all available registers to push some locals on stack
// and force multi-reg->stack copies with small types
......@@ -58,56 +58,23 @@ public static int TestS()
TestS(s3);
TestS(s2);
TestS(s1);
return 100;
}
}
public class Runtime_46240
{
[Fact]
public static int TestEntryPoint()
public static void TestEntryPoint()
{
if (Tester<byte>.TestS() != 100)
{
return 101;
}
if (Tester<sbyte>.TestS() != 100)
{
return 101;
}
if (Tester<ushort>.TestS() != 100)
{
return 101;
}
if (Tester<short>.TestS() != 100)
{
return 101;
}
if (Tester<uint>.TestS() != 100)
{
return 101;
}
if (Tester<int>.TestS() != 100)
{
return 101;
}
if (Tester<ulong>.TestS() != 100)
{
return 101;
}
if (Tester<long>.TestS() != 100)
{
return 101;
}
if (Tester<float>.TestS() != 100)
{
return 101;
}
if (Tester<double>.TestS() != 100)
{
return 101;
}
return 100;
Tester<byte>.TestS();
Tester<sbyte>.TestS();
Tester<ushort>.TestS();
Tester<short>.TestS();
Tester<uint>.TestS();
Tester<int>.TestS();
Tester<ulong>.TestS();
Tester<long>.TestS();
Tester<float>.TestS();
Tester<double>.TestS();
}
}
......@@ -21,6 +21,7 @@ public class Program
public static uint s_2;
[MethodImpl(MethodImplOptions.NoInlining)]
[Fact]
public static int Test1()
{
int vr0 = default(int);
......@@ -42,6 +43,7 @@ public class C0
public static sbyte s_44;
[MethodImpl(MethodImplOptions.NoInlining)]
[Fact]
public static int Test2()
{
try
......@@ -58,12 +60,13 @@ public static int Test2()
public static uint s_4;
[MethodImpl(MethodImplOptions.NoInlining)]
[Fact]
public static int Test3()
{
return M17(0);
}
public static int M17(long arg0)
static int M17(long arg0)
{
short var0 = default(short);
if ((ulong)((-s_4) & arg0) >= 1)
......@@ -78,6 +81,7 @@ public static int M17(long arg0)
public static int[] s_12 = new int[] { 0 };
[MethodImpl(MethodImplOptions.NoInlining)]
[Fact]
public static int Test4()
{
s_12[0] = -2147483648;
......@@ -86,22 +90,4 @@ public static int Test4()
return vr9 ? 0 : 100;
}
}
[Fact]
public static int TestEntryPoint()
{
if (Program.Test1() != 100)
return 0;
if (Program.Test2() != 100)
return 0;
if (Program.Test3() != 100)
return 0;
if (Program.Test4() != 100)
return 0;
return 100;
}
}
......@@ -10,89 +10,78 @@
public class Test
{
// This is trying to verify that we properly zero-extend on all platforms.
public class Program
{
public static long s_15;
public static sbyte s_17;
public static ushort s_21 = 36659;
public static int Test()
{
s_15 = ~1;
return M40(0);
}
public class Program
{
public static long s_15;
public static sbyte s_17;
public static ushort s_21 = 36659;
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Consume(ushort x) { }
[Fact]
public static int Test()
{
s_15 = ~1;
return M40(0);
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static int M40(ushort arg0)
{
for (int var0 = 0; var0 < 2; var0++)
{
arg0 = 65535;
arg0 &= (ushort)(s_15++ >> s_17);
arg0 %= s_21;
}
[MethodImpl(MethodImplOptions.NoInlining)]
static void Consume(ushort x) { }
Consume(arg0);
[MethodImpl(MethodImplOptions.NoInlining)]
static int M40(ushort arg0)
{
for (int var0 = 0; var0 < 2; var0++)
{
arg0 = 65535;
arg0 &= (ushort)(s_15++ >> s_17);
arg0 %= s_21;
}
if (arg0 != 28876)
{
return 0;
}
return 100;
}
}
Consume(arg0);
public class Program2
{
public static long s_15;
public static sbyte s_17;
public static ushort s_21 = 36659;
public static int Test()
{
s_15 = ~1;
return M40();
}
if (arg0 != 28876)
{
return 0;
}
return 100;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Consume(ushort x) { }
public class Program2
{
public static long s_15;
public static sbyte s_17;
public static ushort s_21 = 36659;
[MethodImpl(MethodImplOptions.NoInlining)]
public static int M40()
{
S s = default;
for (int var0 = 0; var0 < 2; var0++)
{
s.U = 65535;
s.U &= (ushort)(s_15++ >> s_17);
s.U %= s_21;
}
[Fact]
public static int Test()
{
s_15 = ~1;
return M40();
}
Consume(s.U);
[MethodImpl(MethodImplOptions.NoInlining)]
static void Consume(ushort x) { }
if (s.U != 28876)
{
return 0;
}
return 100;
}
[MethodImpl(MethodImplOptions.NoInlining)]
static int M40()
{
S s = default;
for (int var0 = 0; var0 < 2; var0++)
{
s.U = 65535;
s.U &= (ushort)(s_15++ >> s_17);
s.U %= s_21;
}
public struct S { public ushort U; }
}
Consume(s.U);
[Fact]
public static int TestEntryPoint() {
if (Test.Program.Test() != 100)
{
return 0;
}
if (s.U != 28876)
{
return 0;
}
return 100;
}
if (Test.Program2.Test() != 100)
{
return 0;
}
return 100;
}
public struct S { public ushort U; }
}
}
......@@ -24,7 +24,8 @@ static float NextFloat(Random random)
return (float)(mantissa * exponent);
}
static int TestDouble()
[Fact]
public static int TestDouble()
{
Random random = new Random(Seed);
double[] arr1 = new double[] { NextFloat(random), NextFloat(random), NextFloat(random), NextFloat(random) };
......@@ -76,7 +77,8 @@ static byte[] GenerateByteArray(int size, Random random)
return arr;
}
static int TestBool()
[Fact]
public static int TestBool()
{
Random random = new Random(Seed);
byte[] arr1 = GenerateByteArray(64, random);
......@@ -108,20 +110,5 @@ static int TestBool()
}
return 100;
}
[Fact]
public static int TestEntryPoint()
{
if (TestDouble() != 100)
{
return 0;
}
if (TestBool() != 100)
{
return 0;
}
return 100;
}
}
}
......@@ -11,16 +11,6 @@ public class Test_143837
public static DerivedClass static_DerivedClass;
[Fact]
public static int TestEntryPoint()
{
if (Test1() != 100) return 1;
if (Test2() != 100) return 1;
Console.WriteLine("Pass");
return 100;
}
public static int Test1()
{
try
......@@ -54,6 +44,7 @@ public static int Test1()
return -1;
}
[Fact]
public static int Test2()
{
try
......
......@@ -20,7 +20,8 @@ namespace TestIntLimits
public class Program
{
[MethodImpl(MethodImplOptions.NoInlining)]
static int CheckMulNeg()
[Fact]
public static int CheckMulNeg()
{
bool fail = false;
if (MulNeg7(3) != -7 * 3)
......@@ -88,7 +89,6 @@ static int CheckMulNeg()
if (fail)
{
Console.WriteLine("CheckMulNeg failed");
return 101;
}
return 100;
......@@ -125,7 +125,8 @@ static int CheckedMulNeg0(int a)
}
[MethodImpl(MethodImplOptions.NoInlining)]
static int CheckNegMul()
[Fact]
public static int CheckNegMul()
{
bool fail = false;
if (NegMul7(3) != -7 * 3)
......@@ -163,7 +164,6 @@ static int CheckNegMul()
if (fail)
{
Console.WriteLine("CheckNegMul failed");
return 101;
}
return 100;
......@@ -190,7 +190,8 @@ static int CheckedNegMulIntMinValue(int a)
}
[MethodImpl(MethodImplOptions.NoInlining)]
static int CheckDivNeg()
[Fact]
public static int CheckDivNeg()
{
bool fail = false;
......@@ -220,7 +221,6 @@ static int CheckDivNeg()
if (fail)
{
Console.WriteLine("CheckDivNeg failed");
return 101;
}
return 100;
......@@ -264,7 +264,8 @@ static long LongDivNeg1000(long a)
static long LongDivNeg1(long a) => -a / 1;
[MethodImpl(MethodImplOptions.NoInlining)]
static int CheckNegDiv()
[Fact]
public static int CheckNegDiv()
{
bool fail = false;
......@@ -310,7 +311,6 @@ static int CheckNegDiv()
if (fail)
{
Console.WriteLine("CheckNegDiv failed");
return 101;
}
return 100;
......@@ -339,28 +339,5 @@ static int CheckNegDiv()
[MethodImpl(MethodImplOptions.NoInlining)]
static long LongNegDivMinus1(long a) => -(a / -1);
[Fact]
public static int TestEntryPoint()
{
if (CheckMulNeg() != 100)
{
return 101;
}
if (CheckNegMul() != 100)
{
return 101;
}
if (CheckDivNeg() != 100)
{
return 101;
}
if (CheckNegDiv() != 100)
{
return 101;
}
return 100;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册