[vala/0.50] tests: Add "element access as ref argument" test to increase coverage



commit daea55dc4f18f171fc6d62de5b9071578b9151d8
Author: Ole André Vadla Ravnås <oleavr gmail com>
Date:   Fri Jan 22 02:40:06 2021 +0100

    tests: Add "element access as ref argument" test to increase coverage

 tests/Makefile.am                               |  1 +
 tests/methods/parameter-ref-element-access.vala | 10 ++++++++++
 2 files changed, 11 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 712f474fa..e0521dd98 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -166,6 +166,7 @@ TESTS = \
        methods/parameter-ref-array-resize.vala \
        methods/parameter-ref-array-resize-captured.vala \
        methods/parameter-ref-delegate.vala \
+       methods/parameter-ref-element-access.vala \
        methods/prepostconditions.vala \
        methods/prepostconditions-captured.vala \
        methods/postconditions.vala \
diff --git a/tests/methods/parameter-ref-element-access.vala b/tests/methods/parameter-ref-element-access.vala
new file mode 100644
index 000000000..743098c21
--- /dev/null
+++ b/tests/methods/parameter-ref-element-access.vala
@@ -0,0 +1,10 @@
+void foo (ref string s) {
+       assert (s == "foo");
+       s = "bar";
+}
+
+void main () {
+       string[] bar = { "manam", "foo" };
+       foo (ref bar[1]);
+       assert (bar[1] == "bar");
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]