Updates for CODEOWNERS
[mono-project.git] / mono / tests / generic-valuetype-interface.2.cs
blob8a3202ee11b834915a1fdcfa2a908120c47cbf97
1 using System;
2 using System.Collections.Generic;
4 public struct GenStruct<T> {
5 public int inc (int i) {
6 return i + 1;
9 public T[] newArr () {
10 return new T [3];
14 public class Bla {
15 public bool work (IList<string> l) {
16 foreach (string s in l) {
17 if (s.Length != 1)
18 return false;
20 return true;
24 public interface GenInterface<T> {
25 T[] newArr ();
28 public struct GenIntStruct<T> : GenInterface<T> {
29 public T[] newArr () {
30 return new T [3];
34 public interface GenFactory<T> {
35 GenInterface<T> makeInterface ();
38 public class Gen<T> : GenFactory<T> {
39 public GenInterface<T> makeInterface () {
40 return new GenIntStruct<T> ();
44 public class NonGen : GenFactory<string> {
45 public GenInterface<string> makeInterface () {
46 return new GenIntStruct<string> ();
50 public class main {
51 public static bool testInterface (GenFactory<string> gf) {
52 GenInterface<string> gi = gf.makeInterface ();
53 if (gi.newArr ().GetType () != typeof (string []))
54 return false;
55 return true;
58 public static int Main () {
59 GenStruct<object> gso = new GenStruct<object> ();
60 GenStruct<string> gss = new GenStruct<string> ();
62 if (gso.inc (1) != 2)
63 return 1;
64 if (gss.inc (2) != 3)
65 return 1;
67 if (gso.newArr ().GetType () != typeof (object []))
68 return 1;
69 if (gss.newArr ().GetType () != typeof (string []))
70 return 1;
72 Gen<string> g = new Gen<string> ();
73 testInterface (g);
75 NonGen ng = new NonGen ();
76 testInterface (ng);
78 Bla bla = new Bla ();
79 string [] arr = { "a", "b", "c" };
81 if (!bla.work (arr))
82 return 1;
84 return 0;