D-Bus: Remove extra semicolon to avoid C warning
[vala-lang.git] / tests / structs / structs.vala
blob2a5c06c476fb56da783ebbaf28056e574ec4470a
1 using GLib;
3 struct SimpleStruct {
4 public int field;
7 public struct PublicStruct {
8 public int field;
11 struct StructWithPrivateField {
12 private int field;
14 public void test () {
15 field = 1;
16 stdout.printf ("StructWithPrivateField: field = %d\n", field);
20 struct StructWithCreationMethod {
21 public StructWithCreationMethod () {
22 stdout.printf ("StructWithCreationMethod\n");
25 public int field;
28 struct StructWithNamedCreationMethod {
29 public StructWithNamedCreationMethod.named () {
30 stdout.printf ("StructWithNamedCreationMethod\n");
33 public int field;
36 void test_in_parameter (SimpleStruct st) {
37 stdout.printf ("test_in_parameter: st.field = %d\n", st.field);
40 void test_in_nullable_parameter (SimpleStruct? st) {
41 assert (st.field == 1);
44 void test_ref_parameter (ref SimpleStruct st) {
45 stdout.printf ("test_ref_parameter: st.field = %d\n", st.field);
46 st.field++;
49 void test_out_parameter (out SimpleStruct st) {
50 st = SimpleStruct ();
51 st.field = 3;
54 void main () {
55 stdout.printf ("Structs Test:\n");
57 stdout.printf ("new SimpleStruct ()\n");
58 var simple_struct = SimpleStruct ();
59 stdout.printf ("new PublicStruct ()\n");
60 var public_struct = PublicStruct ();
61 stdout.printf ("new StructWithCreationMethod ()\n");
62 var struct_with_creation_method = StructWithCreationMethod ();
63 stdout.printf ("new StructWithNamedCreationMethod ()\n");
64 var struct_with_named_creation_method = StructWithNamedCreationMethod.named ();
66 stdout.printf ("new SimpleStruct () { field = 1 }\n");
67 simple_struct = SimpleStruct () { field = 1 };
68 stdout.printf ("simple_struct.field = %d\n", simple_struct.field);
70 test_in_parameter (simple_struct);
71 test_in_nullable_parameter (simple_struct);
72 test_ref_parameter (ref simple_struct);
73 stdout.printf ("after test_ref_parameter: st.field = %d\n", simple_struct.field);
74 test_out_parameter (out simple_struct);
75 stdout.printf ("after test_out_parameter: st.field = %d\n", simple_struct.field);
77 var struct_with_private_field = StructWithPrivateField ();
78 struct_with_private_field.test ();
80 stdout.printf (".\n");