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



commit 320566ea4fd0e657f4319b77e827bdc815afe1d4
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Nov 27 10:50:12 2018 +0100

    tests: Add invalid "switch" tests to increase coverage

 tests/Makefile.am                               |  4 ++++
 tests/semantic/switch-duplicate-label.test      | 11 +++++++++++
 tests/semantic/switch-label-not-compatible.test | 10 ++++++++++
 tests/semantic/switch-label-not-constant.test   | 10 ++++++++++
 tests/semantic/switch-type-unsupported.test     | 11 +++++++++++
 5 files changed, 46 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1a8ed5ec1..3284569d7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -636,6 +636,10 @@ TESTS = \
        semantic/struct-field-initializer.test \
        semantic/struct-invalid-base.test \
        semantic/struct-recursive.test \
+       semantic/switch-duplicate-label.test \
+       semantic/switch-label-not-compatible.test \
+       semantic/switch-label-not-constant.test \
+       semantic/switch-type-unsupported.test \
        semantic/type-argument-ownership-mismatch.test \
        semantic/yield-call-requires-async-context.test \
        semantic/yield-call-requires-async-method.test \
diff --git a/tests/semantic/switch-duplicate-label.test b/tests/semantic/switch-duplicate-label.test
new file mode 100644
index 000000000..d10b9296b
--- /dev/null
+++ b/tests/semantic/switch-duplicate-label.test
@@ -0,0 +1,11 @@
+Invalid Code
+
+void main () {
+       int foo = 23;
+       const int BAR = 42;
+
+       switch (foo) {
+       case BAR: break;
+       case BAR: break;
+       }
+}
diff --git a/tests/semantic/switch-label-not-compatible.test b/tests/semantic/switch-label-not-compatible.test
new file mode 100644
index 000000000..990f06283
--- /dev/null
+++ b/tests/semantic/switch-label-not-compatible.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+void main () {
+       int foo = 23;
+       const int64 BAR = 42;
+
+       switch (foo) {
+       case BAR: break;
+       }
+}
diff --git a/tests/semantic/switch-label-not-constant.test b/tests/semantic/switch-label-not-constant.test
new file mode 100644
index 000000000..73893304c
--- /dev/null
+++ b/tests/semantic/switch-label-not-constant.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+void main () {
+       int foo = 23
+       int bar = 42;
+
+       switch (foo) {
+       case bar: break;
+       }
+}
diff --git a/tests/semantic/switch-type-unsupported.test b/tests/semantic/switch-type-unsupported.test
new file mode 100644
index 000000000..eb8f971d3
--- /dev/null
+++ b/tests/semantic/switch-type-unsupported.test
@@ -0,0 +1,11 @@
+Invalid Code
+
+struct Foo {
+}
+
+void main () {
+       Foo foo = {};
+
+       switch (foo) {
+       }
+}


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