[vala/staging] tests: Add "named argument" test to increase coverage



commit 6ce02caa99b0dfb105b0090cb1f3f221b14d22b8
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Fri Jun 26 13:46:07 2020 +0200

    tests: Add "named argument" test to increase coverage

 tests/Makefile.am                 |  1 +
 tests/methods/argument-named.vala | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index aebdf63f4..02af2fd59 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -178,6 +178,7 @@ TESTS = \
        methods/bug791215.vala \
        methods/bug791283.vala \
        methods/argument-array-initilizer.vala \
+       methods/argument-named.vala \
        methods/delegate-target.vala \
        methods/generics.vala \
        methods/params-array.vala \
diff --git a/tests/methods/argument-named.vala b/tests/methods/argument-named.vala
new file mode 100644
index 000000000..b00eb1bd8
--- /dev/null
+++ b/tests/methods/argument-named.vala
@@ -0,0 +1,22 @@
+class Foo {
+       public void bar (...) {
+               var va = va_list ();
+               assert (va.arg<string> () == "foo");
+               assert (va.arg<string> () == "FOO");
+               assert (va.arg<string> () == "manam");
+               assert (va.arg<int> () == 4711);
+       }
+}
+
+void foo (int first, ...) {
+       var va = va_list ();
+       assert (va.arg<string> () == "bar");
+       assert (va.arg<string> () == "BAR");
+       assert (va.arg<string> () == "manam");
+       assert (va.arg<int> () == 42);
+}
+
+void main () {
+       foo (23, bar: "BAR", manam: 42);
+       new Foo ().bar (foo: "FOO", manam: 4711);
+}


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