[corlib] Tests for System.Reflection.Assembly.GetType(string, bool)
authorAleksey Kliger <aleksey@xamarin.com>
Wed, 7 Oct 2015 15:55:06 +0000 (11:55 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Wed, 7 Oct 2015 15:57:42 +0000 (11:57 -0400)
mcs/class/corlib/Test/System.Reflection/AssemblyTest.cs

index fe18b8ee8db18209e2873aec02212b3bcb1c8f1d..fffd1e9e3d684d89ade98ca36819b710a7d729fe 100644 (file)
@@ -5,9 +5,11 @@
 //     Gonzalo Paniagua Javier (gonzalo@ximian.com)
 //     Philippe Lavoie (philippe.lavoie@cactus.ca)
 //     Sebastien Pouliot (sebastien@ximian.com)
+//      Aleksey Kliger (aleksey@xamarin.com)
 //
 // (c) 2003 Ximian, Inc. (http://www.ximian.com)
 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2015, Xamarin, Inc. (http://www.xamarin.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -89,13 +91,58 @@ namespace MonoTests.System.Reflection
                }
 
                [Test] // bug #49114
-               [Category ("NotWorking")]
                [ExpectedException (typeof (ArgumentException))]
                public void GetType_TypeName_Invalid () 
                {
                        typeof (int).Assembly.GetType ("&blabla", true, true);
                }
 
+               [Test] // bug #17571
+               [ExpectedException (typeof (ArgumentException))]
+               public void GetType_Invalid_RefPtr () {
+                       typeof (int).Assembly.GetType ("System.Int32&*", true, true);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void GetType_Invalid_RefArray () {
+                       typeof (int).Assembly.GetType ("System.Int32&[]", true, true);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void GetType_Invalid_RefGeneric () {
+                       typeof (int).Assembly.GetType ("System.Tuple`1&[System.Int32]", true, true);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void GetType_Invalid_PtrGeneric () {
+                       typeof (int).Assembly.GetType ("System.Tuple`1*[System.Int32]", true, true);
+               }
+
+               [Test]
+               public void GetType_ComposeModifiers () {
+                       var a = typeof(int).Assembly;
+
+                       var e1 = typeof (Int32).MakePointerType().MakeByRefType();
+                       var t1 = a.GetType ("System.Int32*&", true, true);
+                       Assert.AreEqual (e1, t1, "#1");
+
+                       var e2 = typeof (Int32).MakeArrayType(2).MakeByRefType();
+                       var t2 = a.GetType ("System.Int32[,]&", true, true);
+                       Assert.AreEqual (e2, t2, "#2");
+
+                       var e3 = typeof (Int32).MakePointerType().MakeArrayType();
+                       var t3 = a.GetType ("System.Int32*[]", true, true);
+                       Assert.AreEqual (e3, t3, "#3");
+
+                       var e4 = typeof (Int32).MakeArrayType().MakePointerType().MakePointerType().MakeArrayType().MakePointerType().MakeByRefType();
+                       var t4 = a.GetType ("System.Int32[]**[]*&", true, true);
+                       Assert.AreEqual (e4, t4, "#4");
+                               
+               }
+               
                [Test] // bug #334203
                public void GetType_TypeName_AssemblyName ()
                {