From: Rico Tzschichholz Date: Tue, 27 Nov 2018 09:50:12 +0000 (+0100) Subject: tests: Add invalid "switch" tests to increase coverage X-Git-Tag: 0.42.4~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ace2bc8cf028d4d4e5811dd86a066d671101e91;p=thirdparty%2Fvala.git tests: Add invalid "switch" tests to increase coverage --- 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) { + } +}