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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2014-08-04 19:32:15 +0400
committerMarek Safar <marek.safar@gmail.com>2014-08-04 19:33:43 +0400
commit3bd87b33c522187af6aa8e31bbd82043905d357e (patch)
tree5d7f523c98c5341a5e39c9f1308ff1f93a9c54ee /mcs/tests/test-null-operator-05.cs
parent04ae3b8a2e96bd9d78b214a92ec6d8385dc5d3ea (diff)
[mcs] null propagating operator on index expressions
Diffstat (limited to 'mcs/tests/test-null-operator-05.cs')
-rw-r--r--mcs/tests/test-null-operator-05.cs58
1 files changed, 58 insertions, 0 deletions
diff --git a/mcs/tests/test-null-operator-05.cs b/mcs/tests/test-null-operator-05.cs
new file mode 100644
index 00000000000..5fa5c6ff9b4
--- /dev/null
+++ b/mcs/tests/test-null-operator-05.cs
@@ -0,0 +1,58 @@
+using System;
+
+class CI
+{
+ public string this [string i] { set { } get { return ""; } }
+ public int? this [int i] { set { } get { return 1; } }
+}
+
+class C
+{
+ static int TestArrayAccess ()
+ {
+ byte[] arr = null;
+ var v = arr? [0];
+ if (v != null)
+ return 1;
+
+ long?[] ar2 = null;
+ var v2 = ar2? [-1];
+ if (v2 != null)
+ return 2;
+
+// TODO: Disabled for now?
+// arr? [0] += 2;
+ return 0;
+ }
+
+ static int TestIndexerAccess ()
+ {
+ CI ci = null;
+ var v = ci? ["x"];
+ if (v != null)
+ return 1;
+
+ var v2 = ci? [0];
+ if (v2 != null)
+ return 2;
+
+// TODO: Disabled for now?
+// ci? [0] += 3;
+ return 0;
+ }
+
+ static int Main ()
+ {
+ int res;
+ res = TestArrayAccess ();
+ if (res != 0)
+ return 10 + res;
+
+ res = TestIndexerAccess ();
+ if (res != 0)
+ return 20 + res;
+
+ Console.WriteLine ("ok");
+ return 0;
+ }
+} \ No newline at end of file