[vala/wip/baedert/nullable: 6/25] add some nullability tests



commit 617d71f84945a05dc46ac97c3efa2f88bb6a970e
Author: Timm Bäder <mail baedert org>
Date:   Sat Nov 5 18:57:22 2016 +0100

    add some nullability tests

 tests/Makefile.am                                  |    2 ++
 .../nullability/assignment-to-non-nullable-ok.vala |   10 ++++++++++
 tests/nullability/local-reference.vala             |   10 ++++++++++
 3 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bc7e104..58767d1 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 0000000..0968915
--- /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 0000000..079e51c
--- /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;
+       }
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]