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



commit 3ace2bc8cf028d4d4e5811dd86a066d671101e91
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 dd73b41cd..d8cdc045d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -631,6 +631,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/yield-call-requires-async-context.test \
        semantic/yield-call-requires-async-method.test \
        semantic/yield-creation-requires-async-context.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]