Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gtest-021.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c57b3df11245a1e55a96445a38c96b0ef8cf5a84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Testing the default value expressions (14.5.13)

using System;

class Foo<T>
{
	T[] t;

	public Foo (int n)
	{
		t = new T [n];
		for (int i = 0; i < n; i++)
			t [i] = default (T);
	}

	public void Test ()
	{
		X.Print (t [0]);
	}
}

class Bar<T>
{
	public void Test ()
	{
		X.Print (default (X));
		X.Print (default (T));
		X.Print (default (S));
	}
}

struct S
{
	public readonly string Hello;

	S (string hello)
	{
		this.Hello = hello;
	}

	public override string ToString ()
	{
		return String.Format ("S({0})", Hello);
	}

}

class X
{
	public static void Print (object obj)
	{
		if (obj == null)
			Console.WriteLine ("NULL");
		else
			Console.WriteLine ("OBJECT: {0} {1}", obj, obj.GetType ());
	}

	static void Main ()
	{
		Foo<string> a = new Foo<string> (4);
		a.Test ();

		Bar<int> b = new Bar<int> ();
		b.Test ();
		Bar<X> c = new Bar<X> ();
		c.Test ();
	}
}