codegen: Fix floating reference regression with Variants
[vala-gnome.git] / tests / basic-types / glists.vala
blob0d25e448184aaa3d139d86f8e5d9d95f3aa12cf7
1 void test_glist () {
2 var list = new GLib.List<string> ();
3 list.prepend ("foo");
4 list.prepend ("bar");
5 assert (list.nth_data (1) == "foo");
6 list = null;
8 var list2 = new GLib.List<unowned string> ();
9 list2.prepend ("foo");
10 list2.prepend ("bar");
11 assert (list2.nth_data (1) == "foo");
12 list2 = null;
15 void test_gslist () {
16 var list = new GLib.SList<string> ();
17 list.prepend ("foo");
18 list.prepend ("bar");
19 assert (list.nth_data (1) == "foo");
20 list = null;
22 var list2 = new GLib.SList<unowned string> ();
23 list2.prepend ("foo");
24 list2.prepend ("bar");
25 assert (list2.nth_data (1) == "foo");
26 list2 = null;
29 void test_gqueue () {
30 var queue = new GLib.Queue<string> ();
31 queue.push_head ("foo");
32 queue.push_head ("bar");
33 assert (queue.peek_nth (1) == "foo");
34 queue = null;
36 var queue2 = new GLib.Queue<unowned string> ();
37 queue2.push_head ("foo");
38 queue2.push_head ("bar");
39 assert (queue2.peek_nth (1) == "foo");
40 queue2 = null;
43 void test_gnode () {
44 var nodes = new GLib.Node<string> ();
45 nodes.append_data ("foo");
46 nodes.append_data ("bar");
47 assert (nodes.nth_child (1).data == "bar");
48 nodes = null;
50 var nodes2 = new GLib.Node<unowned string> ();
51 nodes2.append_data ("foo");
52 nodes2.append_data ("bar");
53 assert (nodes2.nth_child (1).data == "bar");
54 nodes2 = null;
57 void main () {
58 test_glist ();
59 test_gslist ();
60 test_gqueue ();
61 test_gnode ();