Explorar o código

tests for guards against void types

svn path=/trunk/mcs/; revision=101698
Jb Evain %!s(int64=17) %!d(string=hai) anos
pai
achega
abe9a3fbfb

+ 24 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest.cs

@@ -147,6 +147,15 @@ namespace MonoTests.System.Linq.Expressions {
 			Assert.AreEqual ("foo", p.ToString ());
 		}
 
+		[Test]
+		[Category ("NotDotNet")]
+		[Category ("NotWorking")]
+		[ExpectedException (typeof (ArgumentException))]
+		public void VoidParameter ()
+		{
+			Expression.Parameter (typeof (void), "hello");
+		}
+
 		static int buffer;
 
 		public static int Identity (int i)
@@ -227,5 +236,20 @@ namespace MonoTests.System.Linq.Expressions {
 
 			Assert.AreEqual ("gazonk42", del ());
 		}
+
+		[Test]
+		public void HoistedLocals ()
+		{
+			var left = Expression.Parameter (typeof (int), "left");
+			var right = Expression.Parameter (typeof (int), "right");
+
+			var l = Expression.Lambda<Func<int, int, int>> (
+				Expression.Invoke (
+					Expression.Quote (
+						Expression.Lambda<Func<int>> (
+							Expression.Add (left, right)))), left, right);
+
+			var lc = l.Compile ();
+		}
 	}
 }

+ 7 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Constant.cs

@@ -140,6 +140,13 @@ namespace MonoTests.System.Linq.Expressions
 			Expression.Constant (0, typeof (double));
 		}
 
+		[Test]
+		[ExpectedException (typeof (ArgumentException))]
+		public void VoidConstant ()
+		{
+			Expression.Constant (null, typeof (void));
+		}
+
 		static T Check<T> (T val)
 		{
 			Expression<Func<T>> l = Expression.Lambda<Func<T>> (Expression.Constant (val), new ParameterExpression [0]);

+ 9 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_New.cs

@@ -85,6 +85,15 @@ namespace MonoTests.System.Linq.Expressions {
 			Expression.New (typeof (Foo).GetConstructor (new [] { typeof (string) }));
 		}
 
+		[Test]
+		[Category ("NotDotNet")]
+		[Category ("NotWorking")]
+		[ExpectedException (typeof (ArgumentException))]
+		public void NewVoid ()
+		{
+			Expression.New (typeof (void));
+		}
+
 		[Test]
 		[ExpectedException (typeof (ArgumentNullException))]
 		public void HasNullArgument ()

+ 9 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_NewArrayBounds.cs

@@ -59,6 +59,15 @@ namespace MonoTests.System.Linq.Expressions {
 			Expression.NewArrayBounds (typeof (int), 1.ToConstant (), "2".ToConstant ());
 		}
 
+		[Test]
+		[Category ("NotDotNet")]
+		[Category ("NotWorking")]
+		[ExpectedException (typeof (ArgumentException))]
+		public void NewVoid ()
+		{
+			Expression.NewArrayBounds (typeof (void), 1.ToConstant ());
+		}
+
 		[Test]
 		public void TestArrayBounds ()
 		{

+ 9 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_NewArrayInit.cs

@@ -66,6 +66,15 @@ namespace MonoTests.System.Linq.Expressions {
 			Expression.NewArrayInit (typeof (int), 1.ToConstant (), "2".ToConstant (), 3.ToConstant ());
 		}
 
+		[Test]
+		[Category ("NotDotNet")]
+		[Category ("NotWorking")]
+		[ExpectedException (typeof (ArgumentException))]
+		public void NewVoid ()
+		{
+			Expression.NewArrayInit (typeof (void), new Expression [0]);
+		}
+
 		[Test]
 		public void TestArrayInit ()
 		{

+ 8 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_TypeAs.cs

@@ -114,5 +114,13 @@ namespace MonoTests.System.Linq.Expressions
 			Assert.IsNotNull (asbar (new Baz ()));
 			Assert.IsNull (asbaz (new Bar ()));
 		}
+
+		[Test]
+		[Category ("NotWorking")]
+		[ExpectedException (typeof (ArgumentException))]
+		public void TypeAsVoid ()
+		{
+			Expression.TypeAs ("yoyo".ToConstant (), typeof (void));
+		}
 	}
 }

+ 9 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_TypeIs.cs

@@ -103,5 +103,14 @@ namespace MonoTests.System.Linq.Expressions
 			Assert.IsFalse (bar_is_foo (new Bar ()));
 			Assert.IsTrue (baz_is_bar (new Baz ()));
 		}
+
+		[Test]
+		[Category ("NotDotNet")]
+		[Category ("NotWorking")]
+		[ExpectedException (typeof (ArgumentException))]
+		public void TypeIsVoid ()
+		{
+			Expression.TypeIs ("yoyo".ToConstant (), typeof (void));
+		}
 	}
 }