[vala/0.40] tests: Add invalid "return" tests to increase coverage



commit 0c8e72e463e76910bfde303814366226efbd39ba
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Feb 20 09:33:19 2020 +0100

    tests: Add invalid "return" tests to increase coverage

 tests/Makefile.am                            |  4 ++++
 tests/semantic/return-in-nonvoid.test        |  8 ++++++++
 tests/semantic/return-in-void.test           |  8 ++++++++
 tests/semantic/return-missing-ownership.test |  9 +++++++++
 tests/semantic/return-missing-transfer.test  | 12 ++++++++++++
 5 files changed, 41 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1d2ca29a4..3fe9e6b00 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -753,6 +753,10 @@ TESTS = \
        semantic/property-void.test \
        semantic/reference-transfer-not-supported.test \
        semantic/reference-transfer-unavailable.test \
+       semantic/return-in-nonvoid.test \
+       semantic/return-in-void.test \
+       semantic/return-missing-ownership.test \
+       semantic/return-missing-transfer.test \
        semantic/signal-clash-inherited.test \
        semantic/signal-compact-class.test \
        semantic/signal-detail-invalid.test \
diff --git a/tests/semantic/return-in-nonvoid.test b/tests/semantic/return-in-nonvoid.test
new file mode 100644
index 000000000..95d11f6ae
--- /dev/null
+++ b/tests/semantic/return-in-nonvoid.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+int foo () {
+       return;
+}
+
+void main () {
+}
diff --git a/tests/semantic/return-in-void.test b/tests/semantic/return-in-void.test
new file mode 100644
index 000000000..03f8ec681
--- /dev/null
+++ b/tests/semantic/return-in-void.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+void foo () {
+       return 23;
+}
+
+void main () {
+}
diff --git a/tests/semantic/return-missing-ownership.test b/tests/semantic/return-missing-ownership.test
new file mode 100644
index 000000000..233c34308
--- /dev/null
+++ b/tests/semantic/return-missing-ownership.test
@@ -0,0 +1,9 @@
+Invalid Code
+
+unowned string foo () {
+       var s = "foo";
+       return s;
+}
+
+void main () {
+}
diff --git a/tests/semantic/return-missing-transfer.test b/tests/semantic/return-missing-transfer.test
new file mode 100644
index 000000000..6112120d2
--- /dev/null
+++ b/tests/semantic/return-missing-transfer.test
@@ -0,0 +1,12 @@
+Invalid Code
+
+string bar () {
+       return "bar";
+}
+
+unowned string foo () {
+       return bar ();
+}
+
+void main () {
+}


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