You've already forked linux-packaging-mono
Imported Upstream version 5.14.0.139
Former-commit-id: 4f28317b4329b36d5affaa3634c0a5282733871f
This commit is contained in:
parent
5cffba8add
commit
251cb6b422
@ -744,6 +744,55 @@ namespace MonoTests.System.Reflection.Emit
|
||||
Assert.AreEqual (typeof (TypedRefTarget), TypedReference.GetTargetType (tr));
|
||||
}
|
||||
#endif
|
||||
|
||||
static Action GenerateProblematicMethod (bool add_extra, bool mismatch = false, bool use_vts = false)
|
||||
{
|
||||
Type this_type = typeof(object);
|
||||
Type bound_type = typeof(object);
|
||||
if (mismatch) {
|
||||
this_type = typeof (string);
|
||||
bound_type = typeof (DynamicMethodTest);
|
||||
} else if (use_vts) {
|
||||
this_type = typeof (int);
|
||||
bound_type = typeof (long);
|
||||
}
|
||||
|
||||
Type[] args;
|
||||
if (add_extra)
|
||||
args = new[] { this_type };
|
||||
else
|
||||
args = new Type [0];
|
||||
|
||||
var mb = new DynamicMethod("Peek", null, args, bound_type, true);
|
||||
var il = mb.GetILGenerator ();
|
||||
il.Emit(OpCodes.Ret);
|
||||
return (Action) mb.CreateDelegate(typeof(Action));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtraArgGetsIgnored ()
|
||||
{
|
||||
GenerateProblematicMethod (true) ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExactNumberOfArgsWork ()
|
||||
{
|
||||
GenerateProblematicMethod (false) ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtraArgWithMismatchedTypes ()
|
||||
{
|
||||
GenerateProblematicMethod (true, mismatch: true) ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void ExtraArgWithValueType ()
|
||||
{
|
||||
GenerateProblematicMethod (true, use_vts: true) ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user