[tuner] handle the case with multiple "preserve" attributes
[mono-project.git] / mcs / tests / gtest-collectioninit-01.cs
bloba39aa33b1fb2e81455d6937482814db87d037bd0
2 // Tests collection initialization
4 using System;
5 using System.Collections;
6 using System.Collections.Generic;
8 public class Test
10 class Wrap
12 ArrayList numbers = new ArrayList ();
13 public int Id;
14 public Wrap Next;
16 public Wrap ()
18 Next = new Wrap (100);
21 public Wrap (int i)
23 Next = this;
26 public ArrayList Numbers {
27 get {
28 return numbers;
33 static void TestList (List<int> list, int expectedCount)
35 if (list.Count != expectedCount)
36 throw new ApplicationException (expectedCount.ToString ());
38 foreach (int i in list)
39 Console.WriteLine (i);
42 public static int Main ()
44 ArrayList collection = new ArrayList { "Foo", null, 1 };
45 if (collection.Count != 3)
46 return 1;
48 if ((string)collection [0] != "Foo")
49 return 2;
51 if ((int)collection [2] != 1)
52 return 3;
54 List<string> generic_collection = new List<string> { "Hello", "World" };
55 foreach (string s in generic_collection)
56 if (s.Length != 5)
57 return 4;
59 List<Wrap> a = null;
60 a = new List<Wrap> () {
61 new Wrap (0) {
62 Id = 0,
63 Numbers = { 5, 10 },
64 Next = { Id = 55 }
66 new Wrap {
67 Id = 1,
68 Numbers = { collection, }
70 new Wrap {
71 Id = 2,
72 Numbers = { },
74 null
77 if (a.Count != 4)
78 return 5;
80 if ((int)a [0].Numbers [1] != 10)
81 return 6;
83 new List<int> { 1, 2, 3, 4 };
84 TestList (new List<int> { 1, 2, 3, 4 }, 4);
86 new List<int> { };
88 Console.WriteLine ("OK");
89 return 0;