summaryrefslogtreecommitdiff
path: root/tests/arrays
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2020-02-25 12:35:15 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2020-03-25 13:02:55 +0100
commit74725956b2c99da3ff289ff2d294c525ff2f85c9 (patch)
treeee09c76f7301cb8013509219094b582b79fe4981 /tests/arrays
parentbd73f1ba11c387c919ad06d44badfd7065d1e35f (diff)
downloadvala-74725956b2c99da3ff289ff2d294c525ff2f85c9.tar.gz
codegen: Append initializer for "_*_size_" of array field in internal struct
Fixes https://gitlab.gnome.org/GNOME/vala/issues/914
Diffstat (limited to 'tests/arrays')
-rw-r--r--tests/arrays/struct-field-initializer.vala33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/arrays/struct-field-initializer.vala b/tests/arrays/struct-field-initializer.vala
new file mode 100644
index 000000000..9534c8490
--- /dev/null
+++ b/tests/arrays/struct-field-initializer.vala
@@ -0,0 +1,33 @@
+[CCode (has_type_id = false)]
+struct Foo {
+ public unowned string[] array;
+ public int i;
+}
+
+[CCode (has_type_id = false)]
+public struct Bar {
+ public unowned string[] array;
+ public int i;
+}
+
+const string[] SARRAY = { "foo", "bar" };
+
+const Foo FOO = { SARRAY, 23 };
+const Bar BAR = { SARRAY, 42 };
+
+void main () {
+ {
+ assert (FOO.array.length == 2);
+ assert (FOO.i == 23);
+ assert (BAR.array.length == 2);
+ assert (BAR.i == 42);
+ }
+ {
+ const Foo foo = { SARRAY, 23 };
+ const Bar bar = { SARRAY, 42 };
+ assert (foo.array.length == 2);
+ assert (foo.i == 23);
+ assert (bar.array.length == 2);
+ assert (bar.i == 42);
+ }
+}