Add [Category ("NotWorking")] to failing test.
[mono.git] / mono / tests / finalizer-exception.cs
1 using System;
2 using System.Threading;
3
4 public class FinalizerException {
5         ~FinalizerException () {
6                 throw new Exception ();
7         }
8
9         /*
10          * We allocate the exception object deep down the stack so
11          * that it doesn't get pinned.
12          */
13         public static unsafe void MakeException (int depth) {
14                 // Avoid tail calls
15                 int* values = stackalloc int [20];
16                 if (depth <= 0) {
17                         new FinalizerException ();
18                         return;
19                 }
20                 MakeException (depth - 1);
21         }
22
23         public static int Main () { 
24                 AppDomain.CurrentDomain.UnhandledException += (sender, args) => {
25                         Console.WriteLine ("caught");
26                         Environment.Exit (0);
27                 };
28
29                 MakeException (1024);
30
31                 GC.Collect ();
32                 GC.WaitForPendingFinalizers ();
33
34                 Thread.Sleep (Timeout.Infinite); // infinite wait so we don't race against the unhandled exception callback
35
36                 return 2;
37         }
38 }