add ExcludeFromCodeCoverageAttribute
[mcs.git] / tests / gtest-397.cs
bloba3478f6cb3e6a09b75c3eb472e2151837241b3af
1 using System;
3 struct Foo
5 public int Value;
7 public Foo (int value)
9 this.Value = value;
12 public static Foo operator - (Foo? f)
14 if (f.HasValue)
15 return new Foo (-f.Value.Value);
17 return new Foo (42);
21 struct Bar
23 public int Value;
25 public Bar (int value)
27 this.Value = value;
30 public static Bar? operator - (Bar? b)
32 if (b.HasValue)
33 return new Bar (-b.Value.Value);
35 return b;
39 class Test
42 static Foo NegateFoo (Foo f)
44 return -f;
47 static Foo NegateFooNullable (Foo? f)
49 return -f;
52 static Bar? NegateBarNullable (Bar? b)
54 return -b;
57 static Bar? NegateBar (Bar b)
59 return -b;
62 static int Main ()
64 if (NegateFooNullable (null).Value != 42)
65 return 1;
67 if (NegateFoo (new Foo (2)).Value != -2)
68 return 2;
70 if (NegateBarNullable (null) != null)
71 return 3;
73 if (NegateBar (new Bar (2)).Value.Value != -2)
74 return 4;
76 Console.WriteLine ("OK");
77 return 0;