Updated with review feedback.
[mono.git] / mcs / tests / test-543.cs
1 // Compiler options: -r:test-543-lib.dll
2
3 using System;
4
5 class BetterMethod
6 {
7     public int this[params bool[] args] { get { return 2; } }
8     public string this[bool a, object b] { get { throw new NotImplementedException (); } }
9 }
10
11 class MainClass
12 {
13     public int this [int expectedLength, params string[] items]
14     {
15         get { return 4; }
16         set {
17             if (expectedLength != items.Length)
18                 throw new ArgumentException (expectedLength + " != " + items.Length);
19         }
20     }
21
22     public object this [int expectedLength, params object[] items]
23     {
24         get { return null; }
25         set {
26             if (expectedLength != items.Length)
27                 throw new ArgumentException (expectedLength + " != " + items.Length);
28         }
29     }
30     
31     public bool this [int expectedLength, bool isNull, params object[] items]
32     {
33         get { return false; }
34         set {
35             if (expectedLength != items.Length)
36                 throw new ArgumentException (expectedLength + " != " + items.Length);
37         }
38     }
39
40     public static void Main(string[] args)
41     {
42         MainClass t = new MainClass();
43         t [2, "foo", "doo"] = 2;
44         t [3, new object[3]] = null;
45         t [2, new int[] { 1 }, new string[] { "c", "b", "a" }] = null;
46         t [0, true] = t [0, true];
47         t [1, false, "foo"] = t [0, false, "foo", "doo"];
48         
49         ExternClass e = new ExternClass ();
50         e ["a", "b", "b"] = false;
51         
52         BetterMethod bm = new BetterMethod ();
53         Console.WriteLine (bm[true, false]);
54     }
55 }