File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
src/tests/JIT/interpreter Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 44using System ;
55using System . Runtime . CompilerServices ;
66
7+ public interface ITest
8+ {
9+ public int VirtualMethod ( ) ;
10+ }
11+
12+ public class BaseClass : ITest
13+ {
14+ public int NonVirtualMethod ( )
15+ {
16+ return 0xbaba ;
17+ }
18+
19+ public virtual int VirtualMethod ( )
20+ {
21+ return 0xbebe ;
22+ }
23+ }
24+
25+ public class DerivedClass : BaseClass
26+ {
27+ public override int VirtualMethod ( )
28+ {
29+ return 0xdede ;
30+ }
31+
32+ }
33+
734public struct MyStruct
835{
936 public int a ;
@@ -71,6 +98,8 @@ public static void RunInterpreterTests()
7198// Environment.FailFast(null);
7299 if ( ! TestFloat ( ) )
73100 Environment . FailFast ( null ) ;
101+ if ( ! TestVirtual ( ) )
102+ Environment . FailFast ( null ) ;
74103 }
75104
76105 public static int Mul4 ( int a , int b , int c , int d )
@@ -209,4 +238,26 @@ public static bool TestFloat()
209238
210239 return true ;
211240 }
241+
242+ public static bool TestVirtual ( )
243+ {
244+ BaseClass bc = new DerivedClass ( ) ;
245+ ITest itest = bc ;
246+
247+ if ( bc . NonVirtualMethod ( ) != 0xbaba )
248+ return false ;
249+ if ( bc . VirtualMethod ( ) != 0xdede )
250+ return false ;
251+ if ( itest . VirtualMethod ( ) != 0xdede )
252+ return false ;
253+ bc = new BaseClass ( ) ;
254+ itest = bc ;
255+ if ( bc . NonVirtualMethod ( ) != 0xbaba )
256+ return false ;
257+ if ( bc . VirtualMethod ( ) != 0xbebe )
258+ return false ;
259+ if ( itest . VirtualMethod ( ) != 0xbebe )
260+ return false ;
261+ return true ;
262+ }
212263}
You can’t perform that action at this time.
0 commit comments