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:
authorMartin Baulig <martin@novell.com>2006-06-16 01:58:26 +0400
committerMartin Baulig <martin@novell.com>2006-06-16 01:58:26 +0400
commite7a29a20c4383e58ebcc08d6ec06e05e35bd039a (patch)
treeee5ea504ba7d54e961e072f6ea851fce8bb6ce7f /mcs/tests/gtest-269.cs
parent0bc47ad15089d7aa927f086725ca5daea9210271 (diff)
2006-06-15 Martin Baulig <martin@ximian.com>
* statement.cs (SwitchLabel.ResolveAndReduce): Added `bool allow_nullable' argument; always allow a `null' label if true. (Switch.SwitchGoverningType): Take an `Expression expr' argument. (Switch.TableSwitchEmit, Switch.SimpleSwitchEmit): Check whether we have a `null' label and mark the new `null_target' label; default to the `default' label. (Switch.Resolve): Add support for nullable types. Fixes #78630. svn path=/trunk/mcs/; revision=61777
Diffstat (limited to 'mcs/tests/gtest-269.cs')
-rwxr-xr-xmcs/tests/gtest-269.cs134
1 files changed, 134 insertions, 0 deletions
diff --git a/mcs/tests/gtest-269.cs b/mcs/tests/gtest-269.cs
new file mode 100755
index 00000000000..b8da9a5b893
--- /dev/null
+++ b/mcs/tests/gtest-269.cs
@@ -0,0 +1,134 @@
+using System;
+
+[Flags]
+enum IrishBeer {
+ Stout = 0x1000,
+ Ale = 0x2000,
+ Lager = 0x3000,
+
+ Guinness = 1 | Stout,
+ Smithwicks = 2 | Ale
+}
+
+struct IrishPub
+{
+ public readonly IrishBeer Beer;
+
+ public IrishPub (IrishBeer beer)
+ {
+ this.Beer = beer;
+ }
+
+ public static implicit operator long (IrishPub? pub)
+ {
+ return pub.HasValue ? (long) pub.Value.Beer : 0;
+ }
+
+ public static implicit operator IrishPub? (long value)
+ {
+ return new IrishPub ((IrishBeer) value);
+ }
+}
+
+class X
+{
+ static int Beer (IrishPub? pub)
+ {
+ switch (pub) {
+ case 0x1001:
+ return 1;
+
+ case 0x2002:
+ return 2;
+
+ default:
+ return 3;
+ }
+ }
+
+ static long PubToLong (IrishPub pub)
+ {
+ return pub;
+ }
+
+ static int Test (int? a)
+ {
+ switch (a) {
+ case 0:
+ return 0;
+
+ case 3:
+ return 1;
+
+ default:
+ return 2;
+ }
+ }
+
+ static int TestWithNull (int? a)
+ {
+ switch (a) {
+ case 0:
+ return 0;
+
+ case 3:
+ return 1;
+
+ case null:
+ return 2;
+
+ default:
+ return 3;
+ }
+ }
+
+ static long? Foo (bool flag)
+ {
+ if (flag)
+ return 4;
+ else
+ return null;
+ }
+
+ static int Test (bool flag)
+ {
+ switch (Foo (flag)) {
+ case 0:
+ return 0;
+
+ case 4:
+ return 1;
+
+ default:
+ return 2;
+ }
+ }
+
+ static int Main ()
+ {
+ IrishPub pub = new IrishPub (IrishBeer.Guinness);
+ if (PubToLong (pub) != 0x1001)
+ return 1;
+
+ if (Beer (null) != 3)
+ return 2;
+ if (Beer (new IrishPub (IrishBeer.Guinness)) != 1)
+ return 3;
+
+ if (Test (null) != 2)
+ return 4;
+ if (Test (3) != 1)
+ return 5;
+ if (Test (true) != 1)
+ return 6;
+ if (Test (false) != 2)
+ return 7;
+
+ if (TestWithNull (null) != 2)
+ return 8;
+ if (TestWithNull (3) != 1)
+ return 9;
+
+ return 0;
+ }
+}