PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/mcs/tests/test-anon-123.cs

https://bitbucket.org/danipen/mono
C# | 111 lines | 90 code | 20 blank | 1 comment | 1 complexity | d0453e16bfc4e03d8959ae5ada6e976b MD5 | raw file
Possible License(s): Unlicense, Apache-2.0, LGPL-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0
  1. // Cloning tests
  2. using System;
  3. using System.Collections.Generic;
  4. class MemberAccessData
  5. {
  6. public volatile uint VolatileValue;
  7. public string [] StringValues;
  8. public List<string> ListValues;
  9. int? mt;
  10. public int? MyTypeProperty {
  11. set {
  12. mt = value;
  13. }
  14. get {
  15. return mt;
  16. }
  17. }
  18. }
  19. enum E
  20. {
  21. E1,
  22. E2,
  23. E3
  24. }
  25. public class B
  26. {
  27. protected virtual void BaseM ()
  28. {
  29. }
  30. }
  31. public class C : B
  32. {
  33. delegate void D ();
  34. static void Test (D d)
  35. {
  36. }
  37. static void Test (Action<E> func)
  38. {
  39. func (E.E1);
  40. }
  41. void InstanceTests ()
  42. {
  43. Test (() => base.BaseM ());
  44. }
  45. public static void Main ()
  46. {
  47. Exception diffException;
  48. Test (() => {
  49. diffException = null;
  50. try {
  51. } catch (Exception ex) {
  52. diffException = ex;
  53. } finally {
  54. }
  55. try {
  56. } catch {
  57. }
  58. });
  59. int[] i_a = new int [] { 1,2,3 };
  60. Test (() => {
  61. foreach (int t in i_a) {
  62. }
  63. });
  64. Test (() => {
  65. Console.WriteLine (typeof (void));
  66. });
  67. Test (() => {
  68. Console.WriteLine (typeof (Func<,>));
  69. });
  70. Test (() => {
  71. object o = new List<object> { "Hello", "", null, "World", 5 };
  72. });
  73. Test (() => {
  74. var v = new MemberAccessData {
  75. VolatileValue = 2, StringValues = new string [] { "sv" }, MyTypeProperty = null
  76. };
  77. });
  78. Test (x => {
  79. switch (x) {
  80. case E.E1:
  81. goto case E.E2;
  82. case E.E2:
  83. break;
  84. default:
  85. break;
  86. }
  87. });
  88. var c = new C ();
  89. c.InstanceTests ();
  90. }
  91. }