Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalStrehovsky committed Jul 25, 2024
1 parent a7abd87 commit a502e06
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 28 deletions.
43 changes: 42 additions & 1 deletion src/tests/nativeaot/SmokeTests/Reflection/Reflection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ private static int Main()
TestAbstractGenericLdtoken.Run();
TestTypeHandlesVisibleFromIDynamicInterfaceCastable.Run();
TestCompilerGeneratedCode.Run();
Test105034Regression.Run();


//
// Mostly functionality tests
Expand Down Expand Up @@ -713,6 +715,45 @@ public static void Run()
}
}

class Test105034Regression
{
interface IFactory
{
object Make();
}

interface IOption<T> where T : new() { }

class OptionFactory<T> : IFactory where T : class, new()
{
public object Make() => new T();
}

class Gen<T> { }

struct Atom { }

static Type Register<T>() => typeof(T).GetGenericArguments()[0];
static IFactory Activate(Type t) => (IFactory)Activator.CreateInstance(typeof(OptionFactory<>).MakeGenericType(t));

public static void Run()
{
Console.WriteLine(nameof(Test105034Regression));

Wrap<Atom>();

static void Wrap<T>()
{

Type t = Register();
static Type Register() => Register<IOption<Gen<T>>>();

var f = Activate(t);
f.Make();
}
}
}

class TestCreateDelegate
{
internal class Greeter
Expand Down Expand Up @@ -2485,7 +2526,7 @@ class TestMdArrayLoad2
{
class Atom { }

public static object MakeMdArray<T>() => new T[1,1,1];
public static object MakeMdArray<T>() => new T[1, 1, 1];

public static void Run()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,40 +268,13 @@ public static void Run()
if (!o.ToString().Contains(nameof(Marker1)))
throw new Exception();
}

// ...but not nullable...
{
Array arr = new Nullable<NeverAllocated2>[1];
arr.GetValue(0);
ThrowIfPresent(typeof(TestArrayElementTypeOperations), nameof(Marker2));
}


// ...or reference type element types
{
Array arr = new NeverAllocated3[1];
arr.GetValue(0);
ThrowIfPresent(typeof(TestArrayElementTypeOperations), nameof(Marker3));
}
}

class Marker1 { }
struct NeverAllocated1
{
public override string ToString() => typeof(Marker1).ToString();
}

class Marker2 { }
struct NeverAllocated2
{
public override string ToString() => typeof(Marker2).ToString();
}

class Marker3 { }
class NeverAllocated3
{
public override string ToString() => typeof(Marker3).ToString();
}
}

class TestStaticVirtualMethodOptimizations
Expand Down

0 comments on commit a502e06

Please sign in to comment.