Skip to content

Commit ae624f3

Browse files
committed
Add test coverage for structs containing refs
1 parent 97862b1 commit ae624f3

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/tests/JIT/interpreter/Interpreter.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ public MyStruct2(int val)
6565
}
6666
}
6767

68+
public struct StructWithRefs
69+
{
70+
public MyObj o1, o2;
71+
72+
public StructWithRefs(int val1, int val2)
73+
{
74+
o1 = new MyObj(val1);
75+
o2 = new MyObj(val2);
76+
}
77+
}
78+
6879
public class InterpreterTest
6980
{
7081
static int Main(string[] args)
@@ -93,6 +104,8 @@ public static void RunInterpreterTests()
93104
Environment.FailFast(null);
94105
if (!TestFields())
95106
Environment.FailFast(null);
107+
if (!TestStructRefFields())
108+
Environment.FailFast(null);
96109
// FIXME: Calling TestSpecialFields causes the following System.GC.Collect to fail.
97110
/*
98111
if (!TestSpecialFields())
@@ -214,6 +227,24 @@ public static bool TestFields()
214227
return true;
215228
}
216229

230+
public static bool TestStructRefFields()
231+
{
232+
StructWithRefs s = new StructWithRefs(3, 42);
233+
if (s.o1.str.a != 3)
234+
return false;
235+
if (s.o2.str.a != 42)
236+
return false;
237+
238+
System.GC.Collect();
239+
240+
if (s.o1.str.a != 3)
241+
return false;
242+
if (s.o2.str.a != 42)
243+
return false;
244+
245+
return true;
246+
}
247+
217248
[ThreadStatic]
218249
public static MyObj threadStaticObj;
219250
[ThreadStatic]

0 commit comments

Comments
 (0)