Author: marek
Date: 2007-02-15 18:25:35 -0500 (Thu, 15 Feb 2007)
New Revision: 72972

Added:
   trunk/mcs/tests/gtest-exmethod-01.cs
   trunk/mcs/tests/gtest-exmethod-02-lib.cs
   trunk/mcs/tests/gtest-exmethod-02.cs
   trunk/mcs/tests/gtest-exmethod-03.cs
   trunk/mcs/tests/gtest-exmethod-04-lib.cs
   trunk/mcs/tests/gtest-exmethod-04.cs
   trunk/mcs/tests/gtest-exmethod-05.cs
   trunk/mcs/tests/gtest-exmethod-06.cs
Log:
Extension method tests.

Added: trunk/mcs/tests/gtest-exmethod-01.cs
===================================================================
--- trunk/mcs/tests/gtest-exmethod-01.cs        2007-02-15 23:22:03 UTC (rev 
72971)
+++ trunk/mcs/tests/gtest-exmethod-01.cs        2007-02-15 23:25:35 UTC (rev 
72972)
@@ -0,0 +1,36 @@
+// Compiler options: -langversion:linq
+
+using System;
+
+static class SimpleTest
+{
+       public static string Prefix (this string s, string prefix)
+       {
+               return prefix + s;
+       }
+}
+
+public class M
+{
+       public static int Main ()
+       {
+               SimpleTest.Prefix ("foo", "1");
+               string s = "foo".Prefix ("1");
+               
+               Type ex_attr = typeof 
(System.Runtime.CompilerServices.ExtensionAttribute);
+               if (!typeof (SimpleTest).IsDefined (ex_attr, false))
+                       return 1;
+               
+               if (!typeof (SimpleTest).Assembly.IsDefined (ex_attr, false))
+                       return 2;
+
+               if (!typeof (SimpleTest).GetMethod ("Prefix").IsDefined 
(ex_attr, false))
+                       return 3;
+
+               if (s != "1foo")
+                       return 9;
+               
+               Console.WriteLine (s);
+               return 0;
+       }
+}
\ No newline at end of file


Property changes on: trunk/mcs/tests/gtest-exmethod-01.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/mcs/tests/gtest-exmethod-02-lib.cs
===================================================================
--- trunk/mcs/tests/gtest-exmethod-02-lib.cs    2007-02-15 23:22:03 UTC (rev 
72971)
+++ trunk/mcs/tests/gtest-exmethod-02-lib.cs    2007-02-15 23:25:35 UTC (rev 
72972)
@@ -0,0 +1,11 @@
+// Compiler options: -t:library -langversion:linq
+
+using System;
+
+public static class Test
+{
+       public static string Test_1 (this string s)
+       {
+               return ":";
+       }
+}

Added: trunk/mcs/tests/gtest-exmethod-02.cs
===================================================================
--- trunk/mcs/tests/gtest-exmethod-02.cs        2007-02-15 23:22:03 UTC (rev 
72971)
+++ trunk/mcs/tests/gtest-exmethod-02.cs        2007-02-15 23:25:35 UTC (rev 
72972)
@@ -0,0 +1,22 @@
+// Compiler options: -r:gtest-exmethod-02-lib.dll -langversion:linq
+
+using System;
+
+public class M
+{
+       public static void Main ()
+       {
+               "foo".Test_1 ();
+       }
+}
+
+namespace N
+{
+       public class M
+       {
+               public static void Test2 ()
+               {
+                       "foo".Test_1 ();
+               }
+       }
+}
\ No newline at end of file


Property changes on: trunk/mcs/tests/gtest-exmethod-02.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/mcs/tests/gtest-exmethod-03.cs
===================================================================
--- trunk/mcs/tests/gtest-exmethod-03.cs        2007-02-15 23:22:03 UTC (rev 
72971)
+++ trunk/mcs/tests/gtest-exmethod-03.cs        2007-02-15 23:25:35 UTC (rev 
72972)
@@ -0,0 +1,89 @@
+// Compiler options: -langversion:linq
+
+using System;
+
+namespace A
+{
+       public static class A
+       {
+               public static int Foo (this int i)
+               {
+                       return 1;
+               }
+               
+               public static int Foo (this int i, string s)
+               {
+                       return 30;
+               }
+       }
+}
+
+namespace B
+{
+       public static class X
+       {
+               public static int Foo (this int i)
+               {
+                       return 2;
+               }
+               
+               public static int Foo (this int i, bool b)
+               {
+                       return 20;
+               }
+       }
+}
+
+namespace C
+{
+       using A;
+       using B;
+       using D;
+       
+       public static class F
+       {
+               public static bool Foo (this byte i)
+               {
+                       return false;
+               }
+       }
+       
+       namespace D
+       {
+               public static class F
+               {
+                       public static int Foo (this int i)
+                       {
+                               return 66;
+                       }
+                       
+                       public static void TestX ()
+                       {
+                               int i = 2.Foo (false);
+                       }
+               }
+       }
+       
+       public static class M
+       {
+               public static int Foo (this int i)
+               {
+                       return 4;
+               }
+
+               public static int Main ()
+               {
+                       if (3.Foo ("a") != 30)
+                               return 1;
+                       
+                       if (((byte)0).Foo ())
+                               return 2;
+                       
+                       if (4.Foo (false) != 20)
+                               return 3;
+                       
+                       Console.WriteLine ("OK");
+                       return 0;
+               }
+       }
+}
\ No newline at end of file


Property changes on: trunk/mcs/tests/gtest-exmethod-03.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/mcs/tests/gtest-exmethod-04-lib.cs
===================================================================
--- trunk/mcs/tests/gtest-exmethod-04-lib.cs    2007-02-15 23:22:03 UTC (rev 
72971)
+++ trunk/mcs/tests/gtest-exmethod-04-lib.cs    2007-02-15 23:25:35 UTC (rev 
72972)
@@ -0,0 +1,14 @@
+// Compiler options: -t:library -langversion:linq
+
+using System;
+
+namespace A
+{
+       public static class A
+       {
+               public static string Test_1 (this string s)
+               {
+                       return ":";
+               }
+       }
+}

Added: trunk/mcs/tests/gtest-exmethod-04.cs
===================================================================
--- trunk/mcs/tests/gtest-exmethod-04.cs        2007-02-15 23:22:03 UTC (rev 
72971)
+++ trunk/mcs/tests/gtest-exmethod-04.cs        2007-02-15 23:25:35 UTC (rev 
72972)
@@ -0,0 +1,25 @@
+// Compiler options: -r:gtest-exmethod-04-lib.dll -langversion:linq
+
+namespace A
+{
+       public static class Test
+       {
+               public static string Test_1 (this bool t)
+               {
+                       return ":";
+               }
+       }
+}
+
+namespace B
+{
+       using A;
+       
+       public class M
+       {
+               public static void Main ()
+               {
+                       "".Test_1();
+               }
+       }
+}
\ No newline at end of file


Property changes on: trunk/mcs/tests/gtest-exmethod-04.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/mcs/tests/gtest-exmethod-05.cs
===================================================================
--- trunk/mcs/tests/gtest-exmethod-05.cs        2007-02-15 23:22:03 UTC (rev 
72971)
+++ trunk/mcs/tests/gtest-exmethod-05.cs        2007-02-15 23:25:35 UTC (rev 
72972)
@@ -0,0 +1,37 @@
+// Compiler options: -langversion:linq
+
+namespace A
+{
+       public static class Test_A
+       {
+               public static string Test_1 (this string s)
+               {
+                       return ":";
+               }
+       }
+}
+
+namespace A
+{
+       public static partial class Test_B
+       {
+               public static string Test_2 (this string s)
+               {
+                       return ":";
+               }
+       }
+}
+
+namespace B
+{
+       using A;
+       
+       public class M
+       {
+               public static void Main ()
+               {
+                       "".Test_1();
+                       "".Test_2();
+               }
+       }
+}
\ No newline at end of file


Property changes on: trunk/mcs/tests/gtest-exmethod-05.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/mcs/tests/gtest-exmethod-06.cs
===================================================================
--- trunk/mcs/tests/gtest-exmethod-06.cs        2007-02-15 23:22:03 UTC (rev 
72971)
+++ trunk/mcs/tests/gtest-exmethod-06.cs        2007-02-15 23:25:35 UTC (rev 
72972)
@@ -0,0 +1,29 @@
+// Compiler options: -langversion:linq
+
+public static class Gen
+{
+       public static T Test_1<T> (this T t)
+       {
+               return default (T);
+       }
+       
+       public static string Test_1<T> (this string s)
+       {
+               return ":";
+       }
+}
+
+namespace B
+{
+       public class M
+       {
+               public static void Main ()
+               {
+                       "".Test_1();
+                       4.Test_1();
+                       new M().Test_1();
+                       
+                       //null.Test_1();
+               }
+       }
+}
\ No newline at end of file


Property changes on: trunk/mcs/tests/gtest-exmethod-06.cs
___________________________________________________________________
Name: svn:eol-style
   + native

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to