2010-06-21 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / tests / test-inline-call-stack.cs
blob5374c89924af11e99439c1ddec951f6974188f99
1 using System;
2 using System.Diagnostics;
3 using System.Reflection;
4 using Library;
7 namespace Program {
8 public class Test {
9 public static string TestPassed (bool value) {
10 return value ? "PASSED" : "FAILED";
12 public static string TestFailed (bool value) {
13 return TestPassed (! value);
16 public static int Main () {
17 MethodBase myMethodBase = MethodBase.GetCurrentMethod ();
18 MethodBase inlinedMethodBase = InlinedMethods.GetCurrentMethod ();
20 Assembly myExecutingAssembly = Assembly.GetExecutingAssembly ();
21 Assembly inlinedExecutingAssembly = InlinedMethods.GetExecutingAssembly ();
23 Assembly myCallingAssembly = Assembly.GetCallingAssembly ();
24 Assembly inlinedCallingAssembly = InlinedMethods.CallCallingAssembly ();
26 StackFrame myStackFrame = new StackFrame ();
27 StackFrame inlinedStackFrame = InlinedMethods.GetStackFrame ();
29 string myConstructorCalledFrom = new CallingAssemblyDependant ().CalledFrom;
30 string inlinedConstructorCalledFrom = CallingAssemblyDependant.CalledFromLibrary ();
32 StaticFlag.Flag = true;
33 bool strictFlag = ResourceStrictFieldInit.Single.Flag;
34 bool relaxedFlag = ResourceRelaxedFieldInit.Single.Flag;
36 Console.WriteLine ("[{0}]CurrentMethod: my {1}, inlined {2}, equals {3}",
37 TestFailed (myMethodBase == inlinedMethodBase),
38 myMethodBase.Name, inlinedMethodBase.Name,
39 myMethodBase == inlinedMethodBase);
41 Console.WriteLine ("[{0}]ExecutingAssembly: my {1}, inlined {2}, equals {3}",
42 TestFailed (myExecutingAssembly == inlinedExecutingAssembly),
43 myExecutingAssembly.GetName ().Name, inlinedExecutingAssembly.GetName ().Name,
44 myExecutingAssembly == inlinedExecutingAssembly);
46 Console.WriteLine ("[{0}]CallingAssembly: my {1}, inlined {2}, equals {3}",
47 TestFailed (myCallingAssembly == inlinedCallingAssembly),
48 myCallingAssembly.GetName ().Name, inlinedCallingAssembly.GetName ().Name,
49 myCallingAssembly == inlinedCallingAssembly);
51 Console.WriteLine ("[{0}]StackFrame.GetMethod: my {1}, inlined {2}, equals {3}",
52 TestFailed (myStackFrame.GetMethod ().Name == inlinedStackFrame.GetMethod ().Name),
53 myStackFrame.GetMethod ().Name, inlinedStackFrame.GetMethod ().Name,
54 myStackFrame.GetMethod ().Name == inlinedStackFrame.GetMethod ().Name);
56 Console.WriteLine ("[{0}]ConstructorCalledFrom: my {1}, inlined {2}, equals {3}",
57 TestFailed (myConstructorCalledFrom == inlinedConstructorCalledFrom),
58 myConstructorCalledFrom, inlinedConstructorCalledFrom,
59 myConstructorCalledFrom == inlinedConstructorCalledFrom);
61 Console.WriteLine ("[{0}]strictFlag: {1}, relaxedFlag: {2}",
62 TestFailed ((strictFlag != relaxedFlag)),
63 strictFlag, relaxedFlag);
64 if ((myMethodBase != inlinedMethodBase) &&
65 (myExecutingAssembly != inlinedExecutingAssembly) &&
66 (myCallingAssembly != inlinedCallingAssembly) &&
67 (myStackFrame.GetMethod ().Name != inlinedStackFrame.GetMethod ().Name) &&
68 (myConstructorCalledFrom != inlinedConstructorCalledFrom) &&
69 (strictFlag == relaxedFlag)) {
70 return 0;
71 } else {
72 return 1;