[runtime] Fix "make distcheck"
[mono-project.git] / mono / tests / verifier / valid_generic_test.cs
blobc375a2b643d6e126dc3e3d3af8cbe0acebaf4ae1
1 using System;
3 public delegate void GenericDelegate<T>(T a);
4 public delegate void ObjectDelegate(object a);
6 public class Tst<T> {
7 T field;
8 static T staticField;
10 public Tst() {
11 TestLoadStore (field);
12 TestByRef (field);
13 TestCalls ();
14 TestTypeOps ();
15 TestDelegate ();
18 public void TestLoadStore (T arg) {
19 T local = arg;
20 T[] array = new T[10];
22 field = arg;
23 staticField = arg;
24 arg = local;
25 arg = field;
26 arg = staticField;
27 array[0] = arg;
28 field = array[1];
31 public void TestByRef (T arg) {
32 T local = arg;
33 T[] array = new T[10];
34 PassByRef (ref arg);
35 PassByRef (ref array[0]);
36 PassByRef (ref field);
37 PassByRef (ref local);
38 PassByRef (ref staticField);
41 public void TestCalls () {
42 this.field.ToString ();
43 this.field = Static ();
45 Virtual (field);
48 public void TestTypeOps () {
49 object o = typeof (T);
50 o = field;
51 o = default(T);
52 staticField = (T)o;
53 if (o is T) {
54 //T x = o as T; test with constraints
58 public void TestDelegate () {
59 GenericDelegate<T> gd = new GenericDelegate<T>(this.Virtual);
60 gd(field);
63 public void PassByRef (ref T t) {
64 t = default (T);
67 public virtual void Virtual (T a) {
70 public static T Static() {
71 return staticField;
75 public struct Foo {
76 public int dd;
79 public class Driver {
80 public static void Main () {
81 new Tst<int> ().Virtual (10);
82 new Tst<string> ().Virtual ("str");
83 new Tst<Foo> ().Virtual (new Foo ());