Additional tests for Type.GetType() with delegates.
authorAleksey Kliger <aleksey@xamarin.com>
Wed, 7 Oct 2015 22:58:17 +0000 (18:58 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Wed, 7 Oct 2015 22:58:17 +0000 (18:58 -0400)
Test that exotic compositions of modifiers are parsed correctly.

mcs/class/corlib/Test/System.Reflection/AssemblyTest.cs
mcs/class/corlib/Test/System/TypeTest.cs

index fffd1e9e3d684d89ade98ca36819b710a7d729fe..867efc7379d78f83eb79a8a31a28388a49099d31 100644 (file)
@@ -9,7 +9,7 @@
 //
 // (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)
+// 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
index 0b550c046a0e30c7f5d5858c2be372a1c4e5dc4e..a843bc20da4d59b3fdeee839d94693c9eb8592b3 100644 (file)
@@ -3,8 +3,10 @@
 // Authors:
 //     Zoltan Varga (vargaz@freemail.hu)
 //  Patrik Torstensson
+//  Aleksey Kliger (aleksey@xamarin.com)
 //
 // (C) 2003 Ximian, Inc.  http://www.ximian.com
+// Copyright (C) 2015 Xamarin, Inc. (http://www.xamarin.com)
 // 
 
 using NUnit.Framework;
@@ -3901,6 +3903,43 @@ namespace MonoTests.System
                                }, false, false);
                        Assert.AreEqual (typeof (MyRealEnum).MakePointerType (), res, "#12");
 
+                       tname = typeof (MyRealEnum).FullName + "*&";
+                       res = Type.GetType (tname, name => {
+                                       return Assembly.Load (name);
+                               },(asm,name,ignore) => {
+                                       return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
+                               }, false, false);
+                       Assert.AreEqual (typeof (MyRealEnum).MakePointerType ().MakeByRefType(),
+                                        res, "#13");
+
+                       tname = typeof (MyRealEnum).FullName + "[,]&";
+                       res = Type.GetType (tname, name => {
+                                       return Assembly.Load (name);
+                               },(asm,name,ignore) => {
+                                       return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
+                               }, false, false);
+                       Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (2).MakeByRefType (),
+                                        res, "#14");
+
+                       tname = typeof (MyRealEnum).FullName + "*[]";
+                       res = Type.GetType (tname, name => {
+                                       return Assembly.Load (name);
+                               },(asm,name,ignore) => {
+                                       return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
+                               }, false, false);
+                       Assert.AreEqual (typeof (MyRealEnum).MakePointerType().MakeArrayType(),
+                                        res, "#15");
+
+                       // not a very useful type, but ought to be parsed correctly
+                       tname = typeof (MyRealEnum).FullName + "[]**[]*&";
+                       res = Type.GetType (tname, name => {
+                                       return Assembly.Load (name);
+                               },(asm,name,ignore) => {
+                                       return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
+                               }, false, false);
+                       Assert.AreEqual (typeof (MyRealEnum).MakeArrayType().MakePointerType().MakePointerType().MakeArrayType().MakePointerType().MakeByRefType(),
+                                        res, "#16");
+
                        // assembly resolve without type resolve
                        res = Type.GetType ("System.String,mscorlib", delegate (AssemblyName aname) { return typeof (int).Assembly; }, null);
                        Assert.AreEqual (typeof (string), res);
@@ -3997,6 +4036,7 @@ namespace MonoTests.System
                [Test]
                public void NewGetTypeErrors () {
                        MustANE (null);
+                       MustAE ("!@#$%^&*");
                        MustAE (string.Format ("{0}[{1}&]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
                        MustAE (string.Format ("{0}[{1}*]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
                        MustAE (string.Format ("{0}&&", typeof (MyRealEnum).FullName));