Skip to content

Commit 1bac9a0

Browse files
committed
Add test coverage for structs containing refs
1 parent a82432f commit 1bac9a0

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/tests/JIT/interpreter/Interpreter.cs

+31
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ public MyStruct2(int val)
3838
}
3939
}
4040

41+
public struct StructWithRefs
42+
{
43+
public MyObj o1, o2;
44+
45+
public StructWithRefs(int val1, int val2)
46+
{
47+
o1 = new MyObj(val1);
48+
o2 = new MyObj(val2);
49+
}
50+
}
51+
4152
public class InterpreterTest
4253
{
4354
static int Main(string[] args)
@@ -66,6 +77,8 @@ public static void RunInterpreterTests()
6677
Environment.FailFast(null);
6778
if (!TestFields())
6879
Environment.FailFast(null);
80+
if (!TestStructRefFields())
81+
Environment.FailFast(null);
6982
// FIXME: Calling TestSpecialFields causes the following System.GC.Collect to fail.
7083
/*
7184
if (!TestSpecialFields())
@@ -185,6 +198,24 @@ public static bool TestFields()
185198
return true;
186199
}
187200

201+
public static bool TestStructRefFields()
202+
{
203+
StructWithRefs s = new StructWithRefs(3, 42);
204+
if (s.o1.str.a != 3)
205+
return false;
206+
if (s.o2.str.a != 42)
207+
return false;
208+
209+
System.GC.Collect();
210+
211+
if (s.o1.str.a != 3)
212+
return false;
213+
if (s.o2.str.a != 42)
214+
return false;
215+
216+
return true;
217+
}
218+
188219
[ThreadStatic]
189220
public static MyObj threadStaticObj;
190221
[ThreadStatic]

0 commit comments

Comments
 (0)