2 using System
.Diagnostics
;
4 using System
.Reflection
;
5 using System
.Text
.RegularExpressions
;
11 public string MethodSpec
;
12 public string[] ExpectedMethods
;
15 public static int Main (string[] args
)
17 var testCase
= new TestCase
{
18 MethodSpec
= "*:Method",
19 ExpectedMethods
= new[] {
22 "N2.Test:Method (int)",
23 "N2.Test:Method (int,string[])",
26 if (!RunTest (testCase
))
29 testCase
= new TestCase
{
30 MethodSpec
= "*:Method (int)",
31 ExpectedMethods
= new[] {
32 "N2.Test:Method (int)",
35 if (!RunTest (testCase
))
38 testCase
= new TestCase
40 MethodSpec
= "N1.Test:Method",
41 ExpectedMethods
= new[] {
45 if (!RunTest (testCase
))
48 testCase
= new TestCase
{
49 MethodSpec
= "Test:Method",
50 ExpectedMethods
= new[] {
53 "N2.Test:Method (int)",
54 "N2.Test:Method (int,string[])",
57 if (!RunTest (testCase
))
60 testCase
= new TestCase
{
61 MethodSpec
= "*:Method(int,string[])",
62 ExpectedMethods
= new[] {
63 "N2.Test:Method (int,string[])",
66 if (!RunTest (testCase
))
69 testCase
= new TestCase
{
70 MethodSpec
= "*:Method();N2.*:Method(int,string[])",
71 ExpectedMethods
= new[] {
74 "N2.Test:Method (int,string[])",
77 if (!RunTest (testCase
))
83 static bool RunTest (TestCase testCase
)
85 var thisProcess
= typeof (MainClass
).Assembly
.Location
;
87 var process
= StartCompileAssemblyProcess (thisProcess
, testCase
.MethodSpec
);
88 var output
= process
.StandardOutput
.ReadToEnd ();
89 process
.WaitForExit ();
91 var lines
= output
.Split (new[] { Environment.NewLine }
, StringSplitOptions
.RemoveEmptyEntries
);
92 foreach (var expectedMethod
in testCase
.ExpectedMethods
) {
93 var sortedExpectedMethods
= testCase
.ExpectedMethods
.OrderBy (x
=> x
).ToArray ();
95 var regex
= new Regex ("converting method void (?<methodName>.*)");
96 var matches
= regex
.Matches (output
);
97 var sortedJittedMethods
= matches
.Cast
<Match
> ().Select (x
=> x
.Groups
["methodName"])
98 .SelectMany (x
=> x
.Captures
.Cast
<Capture
> ())
99 .Select (x
=> x
.Value
)
103 if (sortedJittedMethods
.Length
!= sortedExpectedMethods
.Length
)
106 for (int i
= 0; i
< sortedJittedMethods
.Length
; ++i
) {
107 if (sortedJittedMethods
[i
] != sortedExpectedMethods
[i
])
116 static Process
StartCompileAssemblyProcess (string process
, string methodSpec
)
118 var psi
= new ProcessStartInfo (process
) {
119 UseShellExecute
= false,
120 RedirectStandardOutput
= true,
122 psi
.EnvironmentVariables
["MONO_ENV_OPTIONS"] = "--compile-all";
123 psi
.EnvironmentVariables
["MONO_VERBOSE_METHOD"] = methodSpec
;
125 return Process
.Start (psi
);
133 public static void Method ()
143 public static void Method (int n
)
147 public static void Method ()
151 public static void Method (int n
, string[] args
)