[vala/0.40] tests: Add "expression as argument" tests to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] tests: Add "expression as argument" tests to increase coverage
- Date: Tue, 21 Apr 2020 07:48:48 +0000 (UTC)
commit 2a194cbe0a1015f751147e55a349e642ead44062
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Mar 31 22:56:44 2020 +0200
tests: Add "expression as argument" tests to increase coverage
tests/Makefile.am | 2 ++
tests/control-flow/coalesce-as-argument.vala | 12 ++++++++++++
tests/control-flow/conditional-as-argument.vala | 12 ++++++++++++
3 files changed, 26 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b4fe335f0..e80adc429 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -167,6 +167,8 @@ TESTS = \
control-flow/assigned-local-variable.vala \
control-flow/break.vala \
control-flow/break-invalid.test \
+ control-flow/coalesce-as-argument.vala \
+ control-flow/conditional-as-argument.vala \
control-flow/continue-invalid.test \
control-flow/double-catch.test \
control-flow/expressions-conditional.vala \
diff --git a/tests/control-flow/coalesce-as-argument.vala b/tests/control-flow/coalesce-as-argument.vala
new file mode 100644
index 000000000..447c20e7f
--- /dev/null
+++ b/tests/control-flow/coalesce-as-argument.vala
@@ -0,0 +1,12 @@
+void set_foo (string s) {
+ assert (s == "bar");
+}
+
+string get_bar () {
+ return "bar";
+}
+
+void main () {
+ string? s = null;
+ set_foo (s ?? get_bar ());
+}
diff --git a/tests/control-flow/conditional-as-argument.vala b/tests/control-flow/conditional-as-argument.vala
new file mode 100644
index 000000000..0aa7458f9
--- /dev/null
+++ b/tests/control-flow/conditional-as-argument.vala
@@ -0,0 +1,12 @@
+void set_foo (string s) {
+ assert (s == "bar");
+}
+
+string get_bar () {
+ return "bar";
+}
+
+void main () {
+ string? s = null;
+ set_foo (s == null ? get_bar () : "foo");
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]