[vala/wip/baedert/nullable: 19/25] Add more nullability tests
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/baedert/nullable: 19/25] Add more nullability tests
- Date: Tue, 8 Nov 2016 21:19:39 +0000 (UTC)
commit b010635c7e7d7ad0ee10cec57b05acb10128b193
Author: Timm Bäder <mail baedert org>
Date: Tue Nov 8 08:44:26 2016 +0100
Add more nullability tests
tests/Makefile.am | 3 +++
.../assignment-to-non-nullable-fail.test | 9 +++++++++
tests/nullability/assignment-to-nullable.test | 7 +++++++
tests/nullability/coalesce-operator.vala | 10 ++++++++++
tests/nullability/non-null-assign.vala | 9 +++++++++
5 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 58767d1..c1ef055 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 0000000..1045ccf
--- /dev/null
+++ b/tests/nullability/assignment-to-non-nullable-fail.test
@@ -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
index 0000000..010781b
--- /dev/null
+++ b/tests/nullability/assignment-to-nullable.test
@@ -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
index 0000000..c6d1294
--- /dev/null
+++ b/tests/nullability/coalesce-operator.vala
@@ -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
index 0000000..3bc9e79
--- /dev/null
+++ b/tests/nullability/non-null-assign.vala
@@ -0,0 +1,9 @@
+
+
+void main () {
+ string? s = null;
+
+ s = "foo";
+
+ int k = s.length;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]