[svn] r6267: nemerle/trunk/ncc/testsuite/positive:
extension-methods-lib.n extension-methods.n
malekith
svnadmin at nemerle.org
Sat May 13 16:46:26 CEST 2006
Log:
Test for extension methods on interfaces.
Author: malekith
Date: Sat May 13 16:46:25 2006
New Revision: 6267
Modified:
nemerle/trunk/ncc/testsuite/positive/extension-methods-lib.n
nemerle/trunk/ncc/testsuite/positive/extension-methods.n
Modified: nemerle/trunk/ncc/testsuite/positive/extension-methods-lib.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/extension-methods-lib.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/extension-methods-lib.n Sat May 13 16:46:25 2006
@@ -19,6 +19,17 @@
public static ToList2[T] (this a : array [T]) : list [T]
List.FromArray (a)
+
+public class Abc
+ public static Where [T] (this c : System.Collections.Generic.IEnumerable[T], fn : T -> bool) : list[T]
+ $[ e | e in c, fn (e) ]
+
+
+public class Bcd[T]
+ public static NoWhere (this c : System.Collections.Generic.IEnumerable[T], fn : T -> bool) : list[T]
+ $[ e | e in c, ! fn (e) ]
+
+
public class B
public static foo (this a : A, p : int) : void
Write ($"foo($(a.v),$p)\n")
@@ -55,6 +66,12 @@
B.Rev (a)
System.Console.WriteLine (List.FromArray (a))
+ def a = array [1,2,3];
+ System.Console.WriteLine (a.Where(_ > 1));
+ def a = array ["foo", "bar", "foox"];
+ System.Console.WriteLine (a.Where(_.StartsWith ("fo")));
+ System.Console.WriteLine (a.NoWhere(_.StartsWith ("fo")));
+
public class G[X, Y]
public Describe () : void
System.Console.WriteLine ($"$(typeof(X)) $(typeof(Y))")
Modified: nemerle/trunk/ncc/testsuite/positive/extension-methods.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/extension-methods.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/extension-methods.n Sat May 13 16:46:25 2006
@@ -77,6 +77,11 @@
N2.X.xMain ()
+def a = array [1,2,3];
+System.Console.WriteLine (a.Where(_ > 1));
+def a = array ["foo", "bar", "foox"];
+System.Console.WriteLine (a.Where(_.StartsWith ("fo")));
+System.Console.WriteLine (a.NoWhere(_.StartsWith ("fo")));
/*
BEGIN-OUTPUT
@@ -92,6 +97,9 @@
System.Double
[15, 14, 3]
[3, 14, 15]
+[2, 3]
+[foo, foox]
+[bar]
foo()
foo(42,1)
foo(42,2)
@@ -112,5 +120,8 @@
E.F(obj,string)
C.F(obj)
C.F(obj)
+[2, 3]
+[foo, foox]
+[bar]
END-OUTPUT
*/
More information about the svn
mailing list