[runtime] Synthesize IList and IReadOnlyList for the element type of enum errays...
[mono.git] / mono / tests / sgen-bridge-xref.cs
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Threading;
5
6 public class Bridge {
7         public int __test;
8         public string id;
9         public List<object> link = new List<object> ();
10         
11         ~Bridge () {
12         }
13 }
14
15 class Driver {
16         static WeakReference<Bridge> root, child;
17
18         static void SetupLinks () {
19                 var a = new Bridge () { id = "bridge" };
20                 var b = new Bridge () { id = "child" };
21                 a.link.Add (b);
22                 a.__test = 1;
23                 b.__test = 0;
24                 root = new WeakReference<Bridge> (a, true);
25                 child = new WeakReference<Bridge> (b, true);
26         }
27
28         static int Main ()
29         {
30                 var t = new Thread (SetupLinks);
31                 t.Start ();
32                 t.Join ();
33                 
34                 GC.Collect ();
35                 Bridge a, b;
36                 a = b = null;
37                 Console.WriteLine ("try get A {0}", root.TryGetTarget (out a));
38                 Console.WriteLine ("try get B {0}", child.TryGetTarget (out b));
39                 Console.WriteLine ("a is null {0}", a == null);
40                 Console.WriteLine ("b is null {0}", b == null);
41                 if (a == null || b == null)
42                         return 1;
43
44                 Console.WriteLine ("a test {0}", a.__test);
45                 Console.WriteLine ("b test {0}", b.__test);
46
47                 if (a.__test != 1 || b.__test != 3)
48                         return 2;
49
50                 return 0;
51         }
52 }