[System] Tweak socket test
[mono-project.git] / mono / tests / critical-finalizers.cs
blob671074bb9c7b9529f3c45ae01f7827ee01dded25
1 using System;
2 using System.Runtime.ConstrainedExecution;
4 class P {
6 static public int count = 0;
8 /*
9 public P () {
10 Console.WriteLine ("p");
14 ~P () {
15 count++;
19 class Q : CriticalFinalizerObject {
20 static public int count = 0;
21 static public int first_p_count = -1;
22 static public int last_p_count = 0;
23 ~Q () {
24 count++;
25 if (first_p_count < 0)
26 first_p_count = P.count;
27 last_p_count = P.count;
31 class T : P {
33 static void makeP () {
34 P p = new P ();
35 Q q = new Q ();
36 p = null;
37 q = null;
40 static void callMakeP () {
41 makeP ();
44 static int Main () {
45 for (int i = 0; i < 100; ++i)
46 callMakeP ();
47 GC.Collect ();
48 GC.WaitForPendingFinalizers ();
49 Console.WriteLine (P.count);
50 Console.WriteLine (Q.count);
51 Console.WriteLine (Q.first_p_count);
52 Console.WriteLine (Q.last_p_count);
53 if (P.count == 0)
54 return 1;
55 if (Q.first_p_count < P.count)
56 return 1;
57 return 0;