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



commit a6552034120c860aff0299d4774365ae74ccaa29
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 c10c72b41..d4e365353 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -854,6 +854,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]