]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add invalid "switch" tests to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 27 Nov 2018 09:50:12 +0000 (10:50 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 27 Nov 2018 10:12:16 +0000 (11:12 +0100)
tests/Makefile.am
tests/semantic/switch-duplicate-label.test [new file with mode: 0644]
tests/semantic/switch-label-not-compatible.test [new file with mode: 0644]
tests/semantic/switch-label-not-constant.test [new file with mode: 0644]
tests/semantic/switch-type-unsupported.test [new file with mode: 0644]

index 1a8ed5ec1ae8b366a3f5422354d83911cf67bc71..3284569d74e1783dfe81d6640cbc3adcccd8934f 100644 (file)
@@ -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 (file)
index 0000000..d10b929
--- /dev/null
@@ -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 (file)
index 0000000..990f062
--- /dev/null
@@ -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 (file)
index 0000000..7389330
--- /dev/null
@@ -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 (file)
index 0000000..eb8f971
--- /dev/null
@@ -0,0 +1,11 @@
+Invalid Code
+
+struct Foo {
+}
+
+void main () {
+       Foo foo = {};
+
+       switch (foo) {
+       }
+}