Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
VSadov committed May 29, 2023
1 parent 7fd8be5 commit 174de5a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/tests/nativeaot/SmokeTests/DynamicGenerics/B282745.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,29 +86,33 @@ struct SomeGenStruct<T>
public T o;
public int i;
public long l;
public long l1;
}

public class GenericType<T>
{
public static void test()
{
int[] lengths = {1,2,3};
int[] lengths = {42,2,3};

This comment has been minimized.

Copy link
@MichalStrehovsky

MichalStrehovsky May 29, 2023

Member

Can you copy-paste the existing test instead? I cannot reason whether we're losing test coverage to what bug 282745 was about and it's hard to dig for these in the internal databases.

This comment has been minimized.

Copy link
@VSadov

VSadov May 29, 2023

Author Member

From looking at the test I think the test was for similar issues, but it would not work for the actual issue at hand, since 1 + 5 = 6, and 6 ptrs is exactly 2 array elements in the test, we would just skip to the next ptr, which would be null anyways.
Perhaps the test was for 32bit.

It does make sense to add another test.

SomeGenStruct<T>[,,] array = (SomeGenStruct<T>[,,])Array.CreateInstance(typeof(SomeGenStruct<T>), lengths);

array[0,0,0].o = default(T);
array[0,0,0].i = GetIntPtrOnHeapAsInt();
array[0,0,0].l = GetIntPtrOnHeapAsInt();
for (int i = 0; i < 42; i++)
{
array[i,0,0].o = default(T);
array[i,0,0].i = GetIntPtrOnHeapAsInt();
array[i,0,0].l = GetIntPtrOnHeapAsInt();

array[0,1,2].o = default(T);
array[0,1,2].i = GetIntPtrOnHeapAsInt();
array[0,1,2].l = GetIntPtrOnHeapAsLong();
array[i,1,2].o = default(T);
array[i,1,2].i = GetIntPtrOnHeapAsInt();
array[i,1,2].l = GetIntPtrOnHeapAsLong();

array[0,1,1].o = default(T);
array[0,1,1].i = GetIntPtrOnHeapAsInt();
array[0,1,1].l = GetIntPtrOnHeapAsLong();
array[i,1,1].o = default(T);
array[i,1,1].i = GetIntPtrOnHeapAsInt();
array[i,1,1].l = GetIntPtrOnHeapAsLong();
}

GC.Collect();

GC.KeepAlive(array);

RuntimeTypeHandle arrayTypeHandle = array.GetType().TypeHandle;
Expand Down

0 comments on commit 174de5a

Please sign in to comment.