[svn] r6408: nemerle/trunk/ncc: hierarchy/DelegateClassGen.n
testsuite/frommcs/gtest-046.n testsuite/fromm...
nazgul
svnadmin at nemerle.org
Tue Jun 20 18:30:55 CEST 2006
Log:
Some tests from mcs. Fix params compilation in delegate definition
Author: nazgul
Date: Tue Jun 20 18:30:28 2006
New Revision: 6408
Added:
nemerle/trunk/ncc/testsuite/frommcs/gtest-046.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-098-lib.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-172-lib.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-229.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-231.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-237.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-243.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-245.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-248.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-250.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-259.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-263.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-264.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-265-lib.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-266.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/gtest-xml-1.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-287.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-424.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-486.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-487.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-488.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-490.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-491.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-493.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-494.n
nemerle/trunk/ncc/testsuite/frommcs/test-498.n
nemerle/trunk/ncc/testsuite/frommcs/test-499.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-500.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-501.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-503.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-504.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-506.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-508.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-509.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-511.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-512.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-517.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-anon-33.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-anon-34.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-anon-35.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-anon-36.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-anon-37.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-iter-12.n (contents, props changed)
nemerle/trunk/ncc/testsuite/frommcs/test-partial-13.n (contents, props changed)
Modified:
nemerle/trunk/ncc/hierarchy/DelegateClassGen.n
nemerle/trunk/ncc/testsuite/frommcs/test-anon-11.n
Modified: nemerle/trunk/ncc/hierarchy/DelegateClassGen.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/DelegateClassGen.n (original)
+++ nemerle/trunk/ncc/hierarchy/DelegateClassGen.n Tue Jun 20 18:30:28 2006
@@ -50,9 +50,7 @@
attrs.mods |= NemerleAttributes.Sealed;
// create the BeginInvoke parameters
- def begin_invoke_parms =
- List.Append (header.parms, [<[ parameter: _ : System.AsyncCallback ]>,
- <[ parameter: _ : object ]>]);
+ def begin_invoke_parms = create_begin_invoke_parms (header.parms);
// build the delegate's return type and method body for the type inference engine
def ret_type = header.ret_type;
@@ -87,5 +85,17 @@
td
})
}
+
+ create_begin_invoke_parms (existing : list [Fun_parm]) : list [Fun_parm]
+ {
+ | [] => [<[ parameter: _ : System.AsyncCallback ]>, <[ parameter: _ : object ]>]
+ | x :: xs =>
+ def hasnt_params (x) { !(x is <[ System.ParamArrayAttribute ]>) }
+ if (!List.ForAll (x.modifiers.custom_attrs, hasnt_params))
+ Fun_parm (x.loc, x.name, x.ty, Modifiers (x.modifiers.mods, x.modifiers.custom_attrs.Filter (hasnt_params)))
+ :: create_begin_invoke_parms(xs);
+ else
+ x :: create_begin_invoke_parms(xs);
+ }
}
}
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-046.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-046.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,37 @@
+// Generic delegates.
+
+using System;
+
+delegate Test[T] (mutable t : T) : void;
+
+class Foo[T]
+{
+ public event MyEvent : Test[T];
+
+ public Hello (mutable t : T) : void
+ {
+ when (MyEvent != null)
+ MyEvent (t);
+ }
+}
+
+class X
+{
+ static do_hello (mutable hello : string) : void
+ {
+ Console.WriteLine ("Hello: {0}", hello);
+ }
+
+ static Main () : void
+ {
+ mutable foo = Foo ();
+ foo.MyEvent += Test (do_hello);
+ foo.Hello ("Boston");
+ }
+}
+
+/*
+BEGIN-OUTPUT
+Hello: Boston
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-098-lib.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-098-lib.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,20 @@
+// Compiler options: -t:library
+
+public interface IFoo
+{
+ Test[T] () : void;
+
+ Test[U,V] () : void;
+}
+
+public interface IBar[T]
+{
+ Test () : void;
+}
+
+public interface IBar[U,V]
+{
+ Test () : void;
+}
+
+
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-172-lib.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-172-lib.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,8 @@
+// Compiler options: -t:library
+public class A [T] {
+ public class Nil : A [T] {
+ public static mutable _N_constant_object : Nil = Nil ();
+ }
+}
+
+
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-229.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-229.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,41 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+public class B : IComparable[B] {
+ public CompareTo (_b : B) : int
+ {
+ 0;
+ }
+}
+
+public class Tester
+{
+ static Main () : int
+ {
+ mutable b = B ();
+
+ // This should be false
+ if (b is IComparable[object])
+
+ // This should be false
+ {
+ 1;
+
+ // This should be false
+ }
+
+ // This should be false
+ else
+ {
+ {
+ 0;
+ }
+ }
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-231.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-231.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,19 @@
+//
+// From bug 77032
+//
+class X {
+ static mutable stored_offset : int;
+ static mutable stored_len : int;
+ static mutable opt_len : int;
+
+ static Main () : void
+ {
+ when (stored_offset >= 0 && (stored_len+4) < (opt_len >> 3)) {}
+
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-237.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-237.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,56 @@
+using System;
+
+class Foo[T]
+{
+ public Test (_foo : T) : int
+ {
+ 1;
+ }
+
+ public Test (_foo : int) : int
+ {
+ 2;
+ }
+}
+
+class X
+{
+ static Main () : int
+ {
+ mutable foo = Foo ();
+ mutable bar = Foo ();
+ if (foo.Test (4L) != 1)
+ {
+ 1;
+ }
+ else
+ {
+ {
+ if (foo.Test (3) != 2)
+ {
+ 2;
+ }
+ else
+ {
+ {
+ if (bar.Test (3) != 2)
+ {
+ 3;
+ }
+ else
+ {
+ {
+ 0;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-243.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-243.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,100 @@
+// Bugs #77466 and #77460.
+using System;
+using System.Reflection;
+using System.Collections.Generic;
+
+public class Foo[T]
+{
+ public Test (_t : T) : void
+ { }
+}
+
+public class Tests
+{
+ public static foo[T] () : void
+ {
+ }
+
+ public static Test () : int
+ {
+ mutable mi = typeof (Tests).GetMethod ("foo");
+ if (!mi.IsGenericMethod)
+ {
+ 1;
+ }
+ else
+ {
+ {
+ if (!mi.IsGenericMethodDefinition)
+ {
+ 2;
+ }
+ else
+ {
+ {
+ mutable mi2 = mi.MakeGenericMethod ( array[ typeof (int) ]);
+ if (!mi2.IsGenericMethod)
+ {
+ 3;
+ }
+ else
+ {
+ {
+ if (mi2.IsGenericMethodDefinition)
+ {
+ 4;
+ }
+ else
+ {
+ {
+
+ mutable mi3 = typeof (Foo[int]).GetMethod ("Test");
+ if (mi3.IsGenericMethod)
+ {
+ 5;
+ }
+ else
+ {
+ {
+ if (mi3.IsGenericMethodDefinition)
+ {
+ 6;
+ }
+ else
+ {
+ {
+
+ 0;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+#if DEBUG
+
+#endif
+
+
+ public static Main () : int
+ {
+ mutable result = Test ();
+ if (result == 0)
+ Console.WriteLine ("OK");
+ else
+ Console.WriteLine ("ERROR: {0}", result); result;
+ }
+}
+
+/*
+BEGIN-OUTPUT
+OK
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-245.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-245.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,28 @@
+using System;
+
+class DerivedGenericClass[T] : BaseClass
+{
+ public override Foo () : void {}
+
+ public Baz () : void
+ {
+ Foo ();
+ }
+}
+
+abstract class BaseClass
+{
+ public abstract Foo () : void;
+}
+
+class X
+{
+ static Main () : void
+ {
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-248.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-248.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,20 @@
+using System;
+
+public class Foo[T]
+{ }
+
+class X
+{
+ static Test (mutable o : object) : bool
+ {
+ if ( o is Foo[int]) true else false;
+ }
+
+ static Main () : void
+ { }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-250.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-250.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,30 @@
+using System;
+using SCG = System.Collections.Generic;
+
+public delegate Fun[R,S] (mutable r : R) : S;
+
+public interface IIndexedSorted[T]
+{
+ Map[V] (mutable mapper : Fun[T,V]) : IIndexedSorted[V];
+}
+
+public class GuardedIndexedSorted[T] : IIndexedSorted[T]
+{
+ mutable indexedsorted : IIndexedSorted[T];
+
+ public Map[V] (mutable m : Fun[T,V]) : IIndexedSorted[V]
+ {
+ indexedsorted.Map (m);
+ }
+}
+
+class X
+{
+ static Main () : void
+ { }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-259.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-259.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,33 @@
+using System;
+
+public class Class1[T]
+ where T : MyType
+{
+ public MethodOfClass1 (mutable a : T, _b : MyType) : void
+ {
+ a.MethodOfMyBaseType ();
+ }
+}
+
+public class MyType : MyBaseType
+{
+ public override MethodOfMyBaseType () : void
+ {
+ }
+}
+
+public abstract class MyBaseType
+{
+ public abstract MethodOfMyBaseType () : void;
+}
+
+class X
+{
+ static Main () : void
+ { }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-263.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-263.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+
+class Foo[S]
+{
+ public Test (mutable t : S) : ICloneable
+ {
+ ( t :> ICloneable);
+ }
+}
+
+public static class ConvertHelper
+{
+ public static Test[S,T] (mutable s : S) : IEnumerator[T]
+ {
+ yield ( s :> T);
+ }
+
+ static Main () : void
+ { }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-264.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-264.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,27 @@
+public class BaseList[SubType]
+{
+ // without this field instantiation everything works fine.
+ mutable obj : object = object ();
+}
+
+public class XXX : BaseList[object]
+{
+}
+
+public class Crash
+{
+ public static Main() : void
+ {
+ // After creating an array, instantiation got broken.
+ mutable _arr = array(0);
+ // this array creation is OK
+ // BaseList<object> [] arr = new BaseList<object> [0];
+
+ _ = BaseList (); // even this causes SISSEGV
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-265-lib.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-265-lib.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,15 @@
+// Compiler options: -t:library
+
+public class A : X
+{
+ public override Whoa[T] (_arg : object) : void
+ {
+ }
+}
+
+public abstract class X
+{
+ // virtual is also buggy
+ public abstract Whoa[T] (_arg : object) : void;
+}
+
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-266.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-266.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,19 @@
+class Test[T]
+{
+ mutable priv : int;
+ private sealed class Inner[U]
+ {
+ mutable test : Test[U];
+ Foo () : void
+ {
+ test.priv = 0;
+ }
+ }
+}
+
+class Test { static Main () : void { } }
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/gtest-xml-1.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/gtest-xml-1.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,24 @@
+// Compiler options: -doc:gxml-1.xml
+using System;
+
+///<summary>This file throws an error when compiled with XML documentation</summary>
+public class GenericClass [gT]
+{
+ mutable m_data : gT;
+
+ ///<summary>This line caused bug #77183</summary>
+ public this (mutable Data : gT)
+ {
+ m_data = Data;
+ }
+}
+
+class Foo
+{
+ public static Main () : void {}
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-287.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-287.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,58 @@
+using System;
+using System.Reflection;
+
+static class StaticClass
+{
+ static Foo : int = 1;
+
+ delegate D () : object;
+ enum E {}
+
+ public static Name () : string
+ {
+ "OK";
+ }
+}
+
+public class MainClass
+{
+ public static Main () : int
+ {
+ mutable type_ = typeof (StaticClass);
+ if (!type_.IsAbstract || !type_.IsSealed)
+ { {
+ Console.WriteLine ("Is not abstract sealed");
+ 1;
+ }
+ }
+ else
+ {
+ {
+
+ if (type_.GetConstructors ().Length > 0)
+
+ { {
+ Console.WriteLine ("Has constructor");
+ 2;
+ }
+
+ }
+
+ else
+ {
+ {
+
+ Console.WriteLine (StaticClass.Name ());
+ 0;
+ }
+ }
+ }
+ }
+ }
+}
+
+/*
+BEGIN-OUTPUT
+OK
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-424.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-424.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,38 @@
+//
+// Sample for bug 75674
+//
+using System;
+using System.Collections;
+
+class XX {
+ static Metodo (mutable e : Exception) : void
+ {
+ if (e is NotImplementedException){
+ Console.WriteLine ("OK");
+ } else {
+ Console.WriteLine ("Fail");
+ }
+ }
+
+ static X () : IEnumerable
+ {
+ try {
+ throw NotImplementedException ();
+ } catch { | e is Exception => {
+ Metodo (e);
+ } }
+ yield 0;
+ }
+
+ static Main () : void
+ {
+ foreach ( _a :> int in X ()){
+ }
+ }
+}
+
+/*
+BEGIN-OUTPUT
+OK
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-486.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-486.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,21 @@
+using System;
+
+public class Test
+{
+ public static Main () : void
+ {
+ mutable aPath = array["a","b"];
+ mutable c = '.';
+ when (c.ToString () != ".")
+ throw Exception ("c.ToString () is not \".\"");
+ mutable erg = "";
+ erg += String.Join (c.ToString (), aPath);
+ when (erg != "a.b")
+ throw Exception ("erg is " + erg);
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-487.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-487.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,29 @@
+using System;
+struct X {
+ mutable i : int;
+ static mutable pass : bool = false;
+
+ this (_dummy : object)
+ {
+ mutable x = X ();
+ x.i = 1;
+ mutable n = 0;
+
+ when ((({ this = x; this })).i == 1)
+ n ++;
+
+ when (this.i == 1)
+ n ++;
+
+ pass = (n == 2);
+ }
+ static Main () : int
+ {
+ _ = X (null);
+ if ( pass) 0 else 1;
+ }
+}
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-488.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-488.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,30 @@
+using System.Collections;
+
+class P {
+ public mutable x : int;
+}
+
+struct Q {
+ public mutable p : P;
+ public this (mutable p : P) { this.p = p; }
+}
+
+class Test {
+ static foo () : IEnumerable { null; }
+
+ static Main () : void
+ {
+ mutable f = foo ();
+ when (f != null)
+ foreach ( p :> P in f)
+ p.x = 0;
+ when (f != null)
+ foreach ( q :> Q in f)
+ q.p.x = 0;
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-490.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-490.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,11 @@
+class T {
+ static mutable a : array [int] = array[1,2];
+ static mutable
+ b : array [int] = array[3, 4];
+ static Main () : void {}
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-491.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-491.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,17 @@
+
+[AttrB]
+public class M {
+ public static Main() : void
+ {
+ }
+}
+
+[AttrB]
+public class AttrA : System.Attribute {}
+
+public class AttrB : AttrA {}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-493.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-493.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,16 @@
+class A {
+ protected f : int { get { 1; } }
+}
+
+class B : A {
+ bar () : int { C().f; }
+ }
+
+class C : B {
+ static Main () : void {}
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-494.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-494.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,15 @@
+using System.Text;
+
+namespace Agresso.Foundation {
+ public class Function
+ {
+ static Main () : void {}
+ }
+
+ public delegate Translate(mutable callback : Function,mutable result :
+ ref StringBuilder) : void;
+ }
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-498.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-498.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,29 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+struct C
+{
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ public extern this(mutable value : float);
+
+ static Main () : int
+ {
+ mutable iflags = typeof (C).GetConstructors()[0].GetMethodImplementationFlags ();
+ if ((iflags %& MethodImplAttributes.InternalCall) == 0)
+ {
+ 1;
+ }
+ else
+ {
+ {
+
+ 0;
+ }
+ }
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-499.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-499.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,16 @@
+class X {
+ static Main () : void
+ {
+ mutable x = 1;
+ match (x) {
+ | 0=>
+ ();
+ | _ => ()
+ }
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-500.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-500.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,74 @@
+using System;
+using System.Reflection;
+
+[AttributeUsage(AttributeTargets.Field, AllowMultiple=false)]
+class SomeCustomAttribute : Attribute {
+ public this ()
+ {
+ }
+}
+
+class MainClass {
+
+ [SomeCustomAttribute]
+ public mutable a : int;
+
+ [SomeCustomAttribute]
+ public mutable x : int;
+
+ [SomeCustomAttribute]
+ public mutable y : int;
+
+ public static Main () : int
+ {
+ mutable t = typeof (MainClass);
+ mutable fia = t.GetFields();
+
+ {
+
+ mutable temp_2_return_ = Nemerle.Extensions.DefaultValue(int);
+
+ mutable temp_1_break_loop_ = false;
+
+ foreach ( fi :> FieldInfo in fia)
+
+ when (!temp_1_break_loop_ ) {
+ mutable ca = fi.GetCustomAttributes(typeof (SomeCustomAttribute), false);
+ // System.Console.WriteLine ("Field: {0} [{1}]", fi.Name, ca.Length);
+ when (ca.Length != 1)
+ {
+ temp_1_break_loop_ = true;
+ temp_2_return_ = 1;
+ }
+ }
+
+ if( temp_1_break_loop_ )
+
+ {
+
+ temp_2_return_;
+
+ }
+
+ else
+
+ {
+
+ {
+
+ Console.WriteLine ("OK");
+
+ 0;
+
+ }
+
+ }
+
+ }
+ }
+}
+/*
+BEGIN-OUTPUT
+OK
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-501.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-501.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,34 @@
+using System;
+
+public class Tests {
+
+ public delegate FilterStackFrame(mutable o : object) : bool;
+
+ public static DumpException(_fsf : FilterStackFrame) : void {
+ }
+
+ public static foo (mutable continueInteraction : out bool) : void {
+ continueInteraction = false;
+
+ try {
+ }
+ catch {
+ | _ex is Exception => {
+ DumpException(fun( _o : object) {
+ true;
+ });
+ }
+ }
+ }
+
+ public static Main (_args : array [String]) : void {
+ mutable b = Nemerle.Extensions.DefaultValue (bool);
+
+ foo (out b);
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-503.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-503.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,24 @@
+// Compiler options:
+
+using Nemerle.Imperative;
+
+class Foo {
+ static Main () : int
+ {
+
+ for (;;) {
+ try {
+ break;
+ } catch {
+ | _ =>
+ continue;
+ }
+ }
+ return 0;
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-504.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-504.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,62 @@
+// Compiler options:
+
+// This ensures that any "unreachable code" warning will error out
+// rather than generate invalid IL
+
+class Foo
+{
+ public static mutable y : int = 1;
+ public static f () : int { 0; }
+ public static Main () : int
+ {
+ mutable x = 0;
+
+ {
+
+ mutable temp_2_return_ = Nemerle.Extensions.DefaultValue(int);
+
+ mutable temp_1_break_loop_ = false;
+
+ do {
+ x = f ();
+ if (x != 0)
+ {
+ /*continue*/();
+ }
+ else { {
+ {
+ temp_1_break_loop_ = true;
+ temp_2_return_ = 0;
+ }
+ } when( !temp_1_break_loop_ ) { }
+ }
+ } while (x > y && !temp_1_break_loop_);
+
+ if( temp_1_break_loop_ )
+
+ {
+
+ temp_2_return_;
+
+ }
+
+ else
+
+ {
+
+ {
+
+ 1;
+
+ }
+
+ }
+
+ }
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-506.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-506.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,29 @@
+using System;
+
+namespace ProtectedSetter
+{
+ public abstract class BaseClass
+ {
+ public abstract Name : string { get; internal set;}
+ }
+
+ public class DerivedClass : BaseClass
+ {
+
+ public override Name : String
+ {
+ get {
+ null;
+ }
+ internal set {
+ _ = value;
+ }
+ }
+
+ static Main () : void {}
+ }
+}
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-508.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-508.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,49 @@
+using System;
+
+class OutputParam
+{
+ public static Main(_args : array [string]) : void
+ {
+ mutable a = 0;
+ Method(out a);
+ Console.WriteLine(a);
+ }
+
+ public static Method(mutable a : out int) : void
+ {
+ mutable b = 0;
+
+ {
+
+ mutable temp_1_break_loop_ = false;
+
+ try {
+ b = 5;
+ {
+ Nemerle.Imperative.Return ();
+ }
+ } finally {
+ a = 6;
+ }
+
+ if( temp_1_break_loop_ )
+
+ {
+
+ }
+
+ else
+
+ {
+ ()
+ }
+
+ }
+ }
+}
+
+/*
+BEGIN-OUTPUT
+6
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-509.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-509.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,22 @@
+public delegate DelegateHandler() : void;
+
+public interface EventInterface
+{
+ event OnEvent : DelegateHandler;
+}
+
+public class BaseClass
+{
+ public event OnEvent : DelegateHandler;
+}
+
+public class ExtendingClass : BaseClass, EventInterface
+{
+ public static Main() : void
+ {
+ }
+}
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-511.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-511.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,28 @@
+using System;
+
+public class Foo {
+ public static Main (_args : array [string]) : void
+ {
+ try {
+ f ();
+ }
+ catch {
+ | _ => {}
+ }
+ }
+
+ static f () : void
+ {
+ throw Exception ();
+ mutable hi : string; // W: this expression has been skipped in code generation because of unreachable code
+ try { }
+ finally {
+ Console.WriteLine ("hi = {0}", hi);
+ }
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-512.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-512.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,28 @@
+using System;
+
+public class Foo {
+ public static Main (_args : array [string]) : void
+ {
+ try {
+ f ();
+ }
+ catch {
+ | _ => {}
+ }
+ }
+
+ static f () : void
+ {
+ throw Exception ();
+ mutable hi = ""; // W: this expression has been skipped in code generation because of unreachable code
+ try { }
+ finally {
+ Console.WriteLine ("hi = {0}", hi);
+ }
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-517.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-517.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,20 @@
+// Compiler options: -warn:2
+
+class Test {
+ public static Main () : int
+ { mutable temp_1_goto_ = false;
+ mutable i = 1;
+ when(! true )
+ {
+ }
+
+ i = 0;
+ temp_1_goto_ = false;
+ i;
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Modified: nemerle/trunk/ncc/testsuite/frommcs/test-anon-11.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/frommcs/test-anon-11.n (original)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-anon-11.n Tue Jun 20 18:30:28 2006
@@ -1,19 +1,25 @@
//
// Parameter and return value compilation tests for anonymous methods
//
-delegate D ( x : int) : void;
-delegate E ( x : out int) : void;
+delegate D (mutable x : int) : void;
+delegate E (mutable x : out int) : void;
+
+delegate F (params x : array [int]) : void;
class X {
static Main () : int
{
// This should create an AnonymousMethod with the implicit argument
mutable _d1 = fun() {};
- mutable _d2 = fun ( _a : int) {};
+ mutable _d2 : D = fun ( _a : int) {};
+ mutable _f1 = fun() {};
+ mutable f2 : F = fun ( _a : array [int]) {};
+ f2 (1,2,3,4);
0;
}
}
+
/*
BEGIN-OUTPUT
END-OUTPUT
Added: nemerle/trunk/ncc/testsuite/frommcs/test-anon-33.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-anon-33.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,45 @@
+//
+// This test showed that there were cases where there was no
+// shared "ScopeInfo", and that we could not root and keep a "topmost"
+// variable in the compiler for a CaptureContext.
+//
+// This illustrates two roots of captured scopes, independent of
+// each other
+//
+
+using System;
+
+delegate Do () : void;
+
+class T {
+ static doit (mutable v : int) : void {
+ Console.WriteLine (v);
+ }
+ static Main () : void {
+ mutable arr = array(5);
+ for (mutable i = 0; i < 5; ++i) {
+ arr [i] = fun() {doit (i);};
+ }
+ for (mutable i = 0; i < 5; ++i) {
+ arr [i] ();
+ }
+{
+ for (mutable j = 0; j < 5; ++j) {
+ arr [j] = fun() {doit (j);};
+ }
+}
+ }
+
+}
+
+
+
+/*
+BEGIN-OUTPUT
+5
+5
+5
+5
+5
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-anon-34.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-anon-34.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,74 @@
+//
+// This test is from Nigel Perry, Bugzilla #77060
+//
+// The issue here was that in the past we used to emit the
+// Scope initialization on first use, which is wrong as illustrated
+// in this test (the shared scope is not initialized for differnt
+// code paths).
+//
+// This test is a running test, ensuring that it runs
+//
+#region
+
+using System;
+using System.Collections;
+using System.Text;
+using System.Timers;
+
+#endregion
+
+namespace Delegates
+{ class Space
+ { public mutable Value : int;
+
+ public delegate DoCopy() : void;
+
+ public mutable CopyIt : DoCopy;
+
+ public Leak(mutable useArray : bool,mutable max : int) : void
+ { mutable one = null : DoCopy;
+
+ if(useArray)
+ {
+ mutable work = Nemerle.Extensions.DefaultValue ( array [int]);
+
+ one = fun()
+ { work = array(max);
+ };
+ }
+ else
+ {
+ one = fun() { mutable _xans = (max + 1) * max / 2; (); };
+ }
+
+ Console.WriteLine("Here goes...");
+ one();
+ Console.WriteLine("... made it");
+ }
+ }
+
+ class Program
+ { static SpaceLeak() : void
+ { mutable s = Space();
+
+ Console.WriteLine(s.Value);
+
+ s.Leak(false, 1);
+
+ Console.WriteLine(s.Value);
+ }
+
+ static Main(_args : array [string]) : void
+ { SpaceLeak();
+ }
+ }
+}
+
+/*
+BEGIN-OUTPUT
+0
+Here goes...
+... made it
+0
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-anon-35.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-anon-35.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,35 @@
+//
+// This was a bug which was triggered because I removed a routine
+// inadvertently. The routine was restored, and now the scopes
+// are initialized
+//
+using System;
+using System.Collections;
+using System.Reflection;
+
+public class CustomDict {
+ mutable data : ArrayList;
+
+ public this() {
+ foreach ( o :> object in this)
+ Console.WriteLine (o);
+ }
+
+ public GetEnumerator() : IEnumerator {
+ when (data != null)
+ yield 1;
+ }
+}
+
+public class Tests
+{
+
+ public static Main () : void {
+ _ = CustomDict ();
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-anon-36.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-anon-36.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,17 @@
+public class Test
+{
+ public static Main () : void
+ {
+ _ = Test (fun () {});
+ }
+
+ public this (_test : TestMethod) {}
+ public this (_test2 : TestMethod2) {}
+}
+
+public delegate TestMethod () : void;
+public delegate TestMethod2 (_o : object) : void;
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-anon-37.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-anon-37.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,19 @@
+using System;
+
+public class DelegateInit {
+ public delegate FooDelegate() : void;
+
+ public static _print : FooDelegate =
+ fun() {
+ Console.WriteLine("delegate!");
+ };
+
+ public static Main(_args : array [string]) : void {
+ _print();
+ }
+}
+/*
+BEGIN-OUTPUT
+delegate!
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-iter-12.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-iter-12.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,16 @@
+class X {
+ a () : System.Collections.IEnumerable
+ {
+ lock (this){
+ yield "a";
+ yield "b";
+ }
+ }
+
+ static Main () : void {}
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
Added: nemerle/trunk/ncc/testsuite/frommcs/test-partial-13.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/frommcs/test-partial-13.n Tue Jun 20 18:30:28 2006
@@ -0,0 +1,18 @@
+namespace Test{
+ public partial class Test{
+ public override Equals(_obj : object) : bool{
+ true;
+ }
+ }
+ public partial class Test{
+ public override GetHashCode() : int{
+ 1;
+ }
+ static Main () : void {}
+ }
+}
+
+/*
+BEGIN-OUTPUT
+END-OUTPUT
+*/
More information about the svn
mailing list