diff options
Diffstat (limited to 'tests/src/JIT/Methodical/cctor/misc/Desktop/throw.cs')
-rw-r--r-- | tests/src/JIT/Methodical/cctor/misc/Desktop/throw.cs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/src/JIT/Methodical/cctor/misc/Desktop/throw.cs b/tests/src/JIT/Methodical/cctor/misc/Desktop/throw.cs new file mode 100644 index 0000000000..585da5bf96 --- /dev/null +++ b/tests/src/JIT/Methodical/cctor/misc/Desktop/throw.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + + +using System; +internal class measure +{ + public static int a = 0xCC; +} +internal class test +{ + static test() + { + if (measure.a != 0xCC) + { + Console.WriteLine("in .cctor(), measure.a is {0}", measure.a); + Console.WriteLine("FAILED"); + throw new Exception(); + } + Console.WriteLine("in .cctor(), measure.a is {0}", measure.a); + measure.a = 8; + if (measure.a != 8) + { + Console.WriteLine("in .cctor() after measure.a=8, measure.a is {0}", measure.a); + Console.WriteLine("FAILED"); + throw new Exception(); + } + Console.WriteLine("in .cctor() after measure.a=8, measure.a is {0}", measure.a); + + throw new Exception(); + } +} + +internal class Driver +{ + public static int Main() + { + try + { + Console.WriteLine("Testing .cctor() invocation by calling instance method"); + Console.WriteLine(); + Console.WriteLine("Before calling instance method"); + if (measure.a != 0xCC) + { + Console.WriteLine("in Main(), measure.a is {0}", measure.a); + Console.WriteLine("FAILED"); + return 1; + } + test t = new test(); + Console.WriteLine("After calling instance method"); + if (measure.a != 8) + { + Console.WriteLine("in Main() after new test(), measure.a is {0}", measure.a); + Console.WriteLine("FAILED"); + return -1; + } + } + catch (Exception e) + { + Console.WriteLine(e.StackTrace); + Console.WriteLine(); + Console.WriteLine("PASSED"); + return 100; + } + return -1; + } +} |