]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
add some nullability tests
authorTimm Bäder <mail@baedert.org>
Sat, 5 Nov 2016 17:57:22 +0000 (18:57 +0100)
committerTimm Bäder <mail@baedert.org>
Sat, 5 Nov 2016 20:15:48 +0000 (21:15 +0100)
tests/Makefile.am
tests/nullability/assignment-to-non-nullable-ok.vala [new file with mode: 0644]
tests/nullability/local-reference.vala [new file with mode: 0644]

index bc7e104de8cbdd349de212e545942f84f732a1e5..58767d15d4284f4cd48de8923866e049b4990f0b 100644 (file)
@@ -235,6 +235,8 @@ TESTS = \
        gir/bug651773.test \
        gir/bug667751.test \
        gir/bug742012.test \
+       nullability/local-reference.vala \
+       nullability/assignment-to-non-nullable-ok.vala \
        $(NULL)
 
 check-TESTS: $(TESTS)
diff --git a/tests/nullability/assignment-to-non-nullable-ok.vala b/tests/nullability/assignment-to-non-nullable-ok.vala
new file mode 100644 (file)
index 0000000..0968915
--- /dev/null
@@ -0,0 +1,10 @@
+
+
+void main () {
+       string? s = (string?) "foo";
+
+       if (s != null) {
+               string s2 = s;
+               int k = s2.length;
+       }
+}
diff --git a/tests/nullability/local-reference.vala b/tests/nullability/local-reference.vala
new file mode 100644 (file)
index 0000000..079e51c
--- /dev/null
@@ -0,0 +1,10 @@
+
+
+void main () {
+       string? s = (string?)"something";
+
+       if (s != null) {
+               // fine, s can't be null.
+               int k = s.length;
+       }
+}