]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add invalid assignment tests to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Jun 2018 06:02:31 +0000 (08:02 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Jun 2018 06:02:31 +0000 (08:02 +0200)
tests/Makefile.am
tests/semantic/assignment-element-incompatible-ownership.test [new file with mode: 0644]
tests/semantic/assignment-element-incompatible-type.test [new file with mode: 0644]
tests/semantic/assignment-same-variable.vala [new file with mode: 0644]
tests/semantic/assignment-signal-incompatible-method.test [new file with mode: 0644]
tests/semantic/assignment-signal-incompatible-type.test [new file with mode: 0644]

index 4d53645e276ad81e5e78b2823f8c41e3cd81ecfe..dc98b21b067c4bd1809a185eada1834b04e696bb 100644 (file)
@@ -467,6 +467,11 @@ TESTS = \
        parser/yield-method.test \
        parser/bug728574.vala \
        parser/bug749576.vala \
+       semantic/assignment-element-incompatible-ownership.test \
+       semantic/assignment-element-incompatible-type.test \
+       semantic/assignment-same-variable.vala \
+       semantic/assignment-signal-incompatible-method.test \
+       semantic/assignment-signal-incompatible-type.test \
        semantic/class-base-type-invalid.test \
        semantic/class-base-type-less-accessible.test \
        semantic/class-compact-derived-instance-field.test \
diff --git a/tests/semantic/assignment-element-incompatible-ownership.test b/tests/semantic/assignment-element-incompatible-ownership.test
new file mode 100644 (file)
index 0000000..0611c14
--- /dev/null
@@ -0,0 +1,7 @@
+Invalid Code
+
+void main () {
+       string s = "bar";
+       (unowned string)[] sa = { "foo" };
+       sa[0] = (owned) s;
+}
diff --git a/tests/semantic/assignment-element-incompatible-type.test b/tests/semantic/assignment-element-incompatible-type.test
new file mode 100644 (file)
index 0000000..a0de219
--- /dev/null
@@ -0,0 +1,6 @@
+Invalid Code
+
+void main () {
+       string[] sa = { "foo" };
+       sa[0] = 42;
+}
diff --git a/tests/semantic/assignment-same-variable.vala b/tests/semantic/assignment-same-variable.vala
new file mode 100644 (file)
index 0000000..fee85fc
--- /dev/null
@@ -0,0 +1,17 @@
+class Foo {
+       public int i = 23;
+       
+       public Foo () {
+               i = i;
+       }
+}
+
+int i;
+
+void main () {
+       string s = "foo";
+       s = s;
+
+       i = 42;
+       i = i;
+}
diff --git a/tests/semantic/assignment-signal-incompatible-method.test b/tests/semantic/assignment-signal-incompatible-method.test
new file mode 100644 (file)
index 0000000..dec5362
--- /dev/null
@@ -0,0 +1,15 @@
+Invalid Code
+
+class Foo {
+       signal void bar ();
+
+       Foo () {
+               bar += foo;
+       }
+       
+       void foo (string s) {
+       }
+}
+
+void main () {
+}
diff --git a/tests/semantic/assignment-signal-incompatible-type.test b/tests/semantic/assignment-signal-incompatible-type.test
new file mode 100644 (file)
index 0000000..f5578ff
--- /dev/null
@@ -0,0 +1,12 @@
+Invalid Code
+
+class Foo {
+       signal void bar ();
+
+       Foo () {
+               bar += "foo";
+       }
+}
+
+void main () {
+}