]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add more nullability tests
authorTimm Bäder <mail@baedert.org>
Tue, 8 Nov 2016 07:44:26 +0000 (08:44 +0100)
committerTimm Bäder <mail@baedert.org>
Tue, 8 Nov 2016 07:44:26 +0000 (08:44 +0100)
tests/Makefile.am
tests/nullability/assignment-to-non-nullable-fail.test [new file with mode: 0644]
tests/nullability/assignment-to-nullable.test [new file with mode: 0644]
tests/nullability/coalesce-operator.vala [new file with mode: 0644]
tests/nullability/non-null-assign.vala [new file with mode: 0644]

index 58767d15d4284f4cd48de8923866e049b4990f0b..c1ef055e684eea0810f81739200cad4d1aefb458 100644 (file)
@@ -237,6 +237,9 @@ TESTS = \
        gir/bug742012.test \
        nullability/local-reference.vala \
        nullability/assignment-to-non-nullable-ok.vala \
+       nullability/assignment-to-non-nullable-fail.test \
+       nullability/coalesce-operator.vala \
+       nullability/non-null-assign.vala
        $(NULL)
 
 check-TESTS: $(TESTS)
diff --git a/tests/nullability/assignment-to-non-nullable-fail.test b/tests/nullability/assignment-to-non-nullable-fail.test
new file mode 100644 (file)
index 0000000..1045ccf
--- /dev/null
@@ -0,0 +1,9 @@
+Invalid Code
+
+void main () {
+       string? s = null;
+
+       string s2;
+       
+       s2 = s; // can't convert string? to string.
+}
diff --git a/tests/nullability/assignment-to-nullable.test b/tests/nullability/assignment-to-nullable.test
new file mode 100644 (file)
index 0000000..010781b
--- /dev/null
@@ -0,0 +1,7 @@
+Invalid Code
+
+void main () {
+       string? s = null;
+
+       string s2 = s; // can't convert string? to string.
+}
diff --git a/tests/nullability/coalesce-operator.vala b/tests/nullability/coalesce-operator.vala
new file mode 100644 (file)
index 0000000..c6d1294
--- /dev/null
@@ -0,0 +1,10 @@
+
+
+void main () {
+       string? s1 = null;
+       string s2;
+
+       //s2 = s1 ?? "foo";
+
+       //assert (s2 == "foo");
+}
diff --git a/tests/nullability/non-null-assign.vala b/tests/nullability/non-null-assign.vala
new file mode 100644 (file)
index 0000000..3bc9e79
--- /dev/null
@@ -0,0 +1,9 @@
+
+
+void main () {
+       string? s = null;
+
+       s = "foo";
+
+       int k = s.length;
+}