]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add invalid "control-flow" tests to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 5 Feb 2018 10:08:25 +0000 (11:08 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 5 Feb 2018 11:39:30 +0000 (12:39 +0100)
tests/Makefile.am
tests/control-flow/break-invalid.test [new file with mode: 0644]
tests/control-flow/continue-invalid.test [new file with mode: 0644]
tests/control-flow/double-catch.test [new file with mode: 0644]
tests/control-flow/finally-return.test [new file with mode: 0644]
tests/control-flow/missing-break.test [new file with mode: 0644]
tests/control-flow/missing-return.test [new file with mode: 0644]
tests/control-flow/unassigned-local-block-variable.test [new file with mode: 0644]
tests/control-flow/unassigned-local-variable.test [new file with mode: 0644]

index bc641846d67b59e0c3ea84f4ef8588ad7908b263..72871304f5aaf358d260a5c8d8cfc858c8a2b87b 100644 (file)
@@ -113,12 +113,20 @@ TESTS = \
        methods/printf-constructor.vala \
        methods/printf-constructor-invalid.test \
        control-flow/break.vala \
+       control-flow/break-invalid.test \
+       control-flow/continue-invalid.test \
+       control-flow/double-catch.test \
        control-flow/expressions-conditional.vala \
+       control-flow/finally-return.test \
        control-flow/for.vala \
        control-flow/foreach.vala \
+       control-flow/missing-break.test \
+       control-flow/missing-return.test \
        control-flow/nested-conditional.vala \
        control-flow/switch.vala \
        control-flow/sideeffects.vala \
+       control-flow/unassigned-local-block-variable.test \
+       control-flow/unassigned-local-variable.test \
        control-flow/while-false.vala \
        control-flow/bug628336.vala \
        control-flow/bug639482.vala \
diff --git a/tests/control-flow/break-invalid.test b/tests/control-flow/break-invalid.test
new file mode 100644 (file)
index 0000000..4daa273
--- /dev/null
@@ -0,0 +1,5 @@
+Invalid Code
+
+void main () {
+       break;
+}
diff --git a/tests/control-flow/continue-invalid.test b/tests/control-flow/continue-invalid.test
new file mode 100644 (file)
index 0000000..98c3b9b
--- /dev/null
@@ -0,0 +1,5 @@
+Invalid Code
+
+void main () {
+       continue;
+}
diff --git a/tests/control-flow/double-catch.test b/tests/control-flow/double-catch.test
new file mode 100644 (file)
index 0000000..3701352
--- /dev/null
@@ -0,0 +1,12 @@
+Invalid Code
+
+errordomain FooError {
+       BAR
+}
+
+void main () {
+       try {
+       } catch (FooError err) {
+       } catch (FooError err) {
+       }
+}
diff --git a/tests/control-flow/finally-return.test b/tests/control-flow/finally-return.test
new file mode 100644 (file)
index 0000000..80c34c1
--- /dev/null
@@ -0,0 +1,8 @@
+Invalid Code
+
+void main () {
+       try {
+       } finally {
+               return;
+       }
+}
diff --git a/tests/control-flow/missing-break.test b/tests/control-flow/missing-break.test
new file mode 100644 (file)
index 0000000..94c7e08
--- /dev/null
@@ -0,0 +1,8 @@
+Invalid Code
+
+void main () {
+       int foo = 0;
+       switch (foo) {
+               case 0:
+       }
+}
diff --git a/tests/control-flow/missing-return.test b/tests/control-flow/missing-return.test
new file mode 100644 (file)
index 0000000..84e8bbf
--- /dev/null
@@ -0,0 +1,7 @@
+Invalid Code
+
+string get_foo () {
+}
+
+void main () {
+}
diff --git a/tests/control-flow/unassigned-local-block-variable.test b/tests/control-flow/unassigned-local-block-variable.test
new file mode 100644 (file)
index 0000000..1191358
--- /dev/null
@@ -0,0 +1,6 @@
+Invalid Code
+
+void main () {
+       string s;
+       print ("%s", s);
+}
diff --git a/tests/control-flow/unassigned-local-variable.test b/tests/control-flow/unassigned-local-variable.test
new file mode 100644 (file)
index 0000000..279b4d9
--- /dev/null
@@ -0,0 +1,11 @@
+Invalid Code
+
+void main () {
+       bool cond = false;
+
+       string s;
+       if (cond) {
+               s = "foo";
+       }
+       print ("%s", s);
+}