From: Timm Bäder Date: Sat, 5 Nov 2016 17:57:22 +0000 (+0100) Subject: add some nullability tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=617d71f84945a05dc46ac97c3efa2f88bb6a970e;p=thirdparty%2Fvala.git add some nullability tests --- diff --git a/tests/Makefile.am b/tests/Makefile.am index bc7e104de..58767d15d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..09689151b --- /dev/null +++ b/tests/nullability/assignment-to-non-nullable-ok.vala @@ -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 index 000000000..079e51c79 --- /dev/null +++ b/tests/nullability/local-reference.vala @@ -0,0 +1,10 @@ + + +void main () { + string? s = (string?)"something"; + + if (s != null) { + // fine, s can't be null. + int k = s.length; + } +}