summaryrefslogtreecommitdiff
path: root/tests/structs
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2009-01-16 13:49:52 +0000
committerJürg Billeter <juergbi@src.gnome.org>2009-01-16 13:49:52 +0000
commitca66af7b180add4f06213b6d80de08ef45fb5c3e (patch)
treed5393cde83398b570dcb48c5972edee05e111e9e /tests/structs
parentdbd89897490c486012e955b6a73e5aaf7dd79336 (diff)
downloadvala-ca66af7b180add4f06213b6d80de08ef45fb5c3e.tar.gz
Rearrange test cases
2009-01-16 Jürg Billeter <j@bitron.ch> * tests/: Rearrange test cases svn path=/trunk/; revision=2349
Diffstat (limited to 'tests/structs')
-rw-r--r--tests/structs/structs.test85
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/structs/structs.test b/tests/structs/structs.test
new file mode 100644
index 000000000..4b39feeb4
--- /dev/null
+++ b/tests/structs/structs.test
@@ -0,0 +1,85 @@
+
+Program: test
+
+using GLib;
+
+struct SimpleStruct {
+ public int field;
+}
+
+public struct PublicStruct {
+ public int field;
+}
+
+struct StructWithPrivateField {
+ private int field;
+
+ public void test () {
+ field = 1;
+ stdout.printf ("StructWithPrivateField: field = %d\n", field);
+ }
+}
+
+struct StructWithCreationMethod {
+ public StructWithCreationMethod () {
+ stdout.printf ("StructWithCreationMethod\n");
+ }
+
+ public int field;
+}
+
+struct StructWithNamedCreationMethod {
+ public StructWithNamedCreationMethod.named () {
+ stdout.printf ("StructWithNamedCreationMethod\n");
+ }
+
+ public int field;
+}
+
+void test_in_parameter (SimpleStruct st) {
+ stdout.printf ("test_in_parameter: st.field = %d\n", st.field);
+}
+
+void test_in_nullable_parameter (SimpleStruct? st) {
+ assert (st.field == 1);
+}
+
+void test_ref_parameter (ref SimpleStruct st) {
+ stdout.printf ("test_ref_parameter: st.field = %d\n", st.field);
+ st.field++;
+}
+
+void test_out_parameter (out SimpleStruct st) {
+ st = SimpleStruct ();
+ st.field = 3;
+}
+
+void main () {
+ stdout.printf ("Structs Test:\n");
+
+ stdout.printf ("new SimpleStruct ()\n");
+ var simple_struct = SimpleStruct ();
+ stdout.printf ("new PublicStruct ()\n");
+ var public_struct = PublicStruct ();
+ stdout.printf ("new StructWithCreationMethod ()\n");
+ var struct_with_creation_method = StructWithCreationMethod ();
+ stdout.printf ("new StructWithNamedCreationMethod ()\n");
+ var struct_with_named_creation_method = StructWithNamedCreationMethod.named ();
+
+ stdout.printf ("new SimpleStruct () { field = 1 }\n");
+ simple_struct = SimpleStruct () { field = 1 };
+ stdout.printf ("simple_struct.field = %d\n", simple_struct.field);
+
+ test_in_parameter (simple_struct);
+ test_in_nullable_parameter (simple_struct);
+ test_ref_parameter (ref simple_struct);
+ stdout.printf ("after test_ref_parameter: st.field = %d\n", simple_struct.field);
+ test_out_parameter (out simple_struct);
+ stdout.printf ("after test_out_parameter: st.field = %d\n", simple_struct.field);
+
+ var struct_with_private_field = StructWithPrivateField ();
+ struct_with_private_field.test ();
+
+ stdout.printf (".\n");
+}
+