From 0554ed7ad9cefe0f56e53dc00be88488dfa788bf Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Sun, 16 Dec 2018 20:01:19 +0100 Subject: vala: Array with fixed length don't require explicit instantiation Fixes https://gitlab.gnome.org/GNOME/vala/issues/720 --- tests/Makefile.am | 1 + tests/basic-types/arrays-fixed-assignment.vala | 27 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/basic-types/arrays-fixed-assignment.vala (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 380703da2..1a18f2c13 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,6 +25,7 @@ TESTS = \ basic-types/floats.vala \ basic-types/strings.vala \ basic-types/arrays.vala \ + basic-types/arrays-fixed-assignment.vala \ basic-types/array-uint8-uchar-compat.vala \ basic-types/pointers.vala \ basic-types/sizeof.vala \ diff --git a/tests/basic-types/arrays-fixed-assignment.vala b/tests/basic-types/arrays-fixed-assignment.vala new file mode 100644 index 000000000..0ec0df437 --- /dev/null +++ b/tests/basic-types/arrays-fixed-assignment.vala @@ -0,0 +1,27 @@ +string foo[3]; + +void main () { + { + foo = new string[3]; + } + { + foo = new string[3] { "foo", "bar", "baz" }; + assert (foo[1] == "bar"); + } + { + foo = { "foo", "bar", "baz" }; + assert (foo[1] == "bar"); + } + + { + string bar[3] = new string[3]; + } + { + string bar[3] = new string[3] { "foo", "bar", "baz" }; + assert (bar[1] == "bar"); + } + { + string bar[3] = { "foo", "bar", "baz" }; + assert (bar[1] == "bar"); + } +} -- cgit v1.2.1