New tests.
authorMarek Safar <marek.safar@gmail.com>
Thu, 27 Mar 2008 12:33:21 +0000 (12:33 -0000)
committerMarek Safar <marek.safar@gmail.com>
Thu, 27 Mar 2008 12:33:21 +0000 (12:33 -0000)
svn path=/trunk/mcs/; revision=99117

mcs/tests/gtest-376.cs [new file with mode: 0644]
mcs/tests/gtest-etree-01.cs
mcs/tests/gtest-etree-03.cs [new file with mode: 0644]
mcs/tests/known-issues-gmcs

diff --git a/mcs/tests/gtest-376.cs b/mcs/tests/gtest-376.cs
new file mode 100644 (file)
index 0000000..fd78b6c
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+
+struct S<T> where T : struct
+{
+       static object Box (T? o)
+       {
+               if (o == null)
+                       return null;
+               return (T) o;
+       }
+}
+
+class C
+{
+       public static void Main ()
+       {
+       }
+}
index ce465958084237fcaa099a83c6a5e4d30ee044de..2a26d944eec0cefb1aa1032961e9067f6d53171c 100644 (file)
@@ -197,6 +197,7 @@ class Tester
 
        void AddTest ()
        {
+       /*
                Expression<Func<int, int, int>> e = (int a, int b) => a + b;
                AssertNodeType (e, ExpressionType.Add);
                Assert (50, e.Compile ().Invoke (20, 30));
@@ -217,11 +218,11 @@ class Tester
                Expression<Func<int, MyType, int>> e5 = (int a, MyType b) => a + b;
                AssertNodeType (e5, ExpressionType.Add);
                Assert (31, e5.Compile ().Invoke (1, new MyType (30)));
-/*
+*/
+
                Expression<Func<int, MyType?, int?>> e6 = (int a, MyType? b) => a + b;
                AssertNodeType (e6, ExpressionType.Add);
                Assert (-1, e6.Compile ().Invoke (-31, new MyType (30)));               
-*/
        }
 
        void AddCheckedTest ()
@@ -406,6 +407,25 @@ class Tester
                Assert (3, r4.Invoke (new InverseLogicalOperator (true), 3, 4));
                Assert (4, r4.Invoke (new InverseLogicalOperator (false), 3, 4));
        }
+       
+       void ConstantTest ()
+       {
+               Expression<Func<int>> e1 = () => default (int);
+               AssertNodeType (e1, ExpressionType.Constant);
+               Assert (0, e1.Compile ().Invoke ());
+
+               Expression<Func<int?>> e2 = () => default (int?);
+               AssertNodeType (e2, ExpressionType.Constant);
+               Assert (null, e2.Compile ().Invoke ());         
+               
+               Expression<Func<Tester>> e3 = () => default (Tester);
+               AssertNodeType (e3, ExpressionType.Constant);
+               Assert (null, e3.Compile ().Invoke ());
+               
+               Expression<Func<object>> e4 = () => null;
+               AssertNodeType (e4, ExpressionType.Constant);
+               Assert (null, e4.Compile ().Invoke ());
+       }
 
        void ConvertTest ()
        {
@@ -430,6 +450,10 @@ class Tester
                
                // TODO: redundant return conversion
                // Expression<Func<MyTypeExplicit, int?>> e6 = x => (int?)x;
+               
+               // TODO: redundant convert
+               // TODO: pass null value
+               // Expression<Func<int?, object>> ex = x => (object)x;
        }
 
        void ConvertCheckedTest ()
@@ -790,6 +814,7 @@ class Tester
                e.CallTest ();
                e.CoalesceTest ();
                e.ConditionTest ();
+               e.ConstantTest ();
                e.ConvertTest ();
                e.ConvertCheckedTest ();
                e.DivideTest ();
diff --git a/mcs/tests/gtest-etree-03.cs b/mcs/tests/gtest-etree-03.cs
new file mode 100644 (file)
index 0000000..e6562cc
--- /dev/null
@@ -0,0 +1,27 @@
+using System;
+using System.Linq.Expressions;
+
+struct S<T> where T : struct
+{
+       public static int Test ()
+       {
+               Expression<Func<T?, bool>> e = (T? o) => o == null;
+               if (!e.Compile ().Invoke (null))
+                       return 1;
+               
+               if (e.Compile ().Invoke (default (T)))
+                       return 2;
+               
+               Console.WriteLine ("OK");
+               return 0;
+       }
+}
+
+class C
+{
+       static int Main()
+       {
+               return S<int>.Test ();
+       }
+}
+
index a7612f14efdb7788aab6406218a014c328306d9a..063b04d7aa44d4821a03247365a478b800940f7a 100644 (file)
@@ -13,5 +13,7 @@ gtest-367.cs
 
 ltest-11.cs
 gtest-etree-01.cs
+gtest-etree-03.cs
+
 gtest-334.cs # Will have to really investigate why is it allowed
 gtest-358.cs # Required user-operators rewrite