7 public struct PublicStruct
{
11 struct StructWithPrivateField
{
16 stdout
.printf ("StructWithPrivateField: field = %d\n", field
);
20 struct StructWithCreationMethod
{
21 public StructWithCreationMethod () {
22 stdout
.printf ("StructWithCreationMethod\n");
28 struct StructWithNamedCreationMethod
{
29 public StructWithNamedCreationMethod
.named () {
30 stdout
.printf ("StructWithNamedCreationMethod\n");
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
);
49 void test_out_parameter (out SimpleStruct st
) {
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");