[vala/0.50] tests: Add "generics reference transfer" test to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.50] tests: Add "generics reference transfer" test to increase coverage
- Date: Wed, 28 Apr 2021 07:07:53 +0000 (UTC)
commit 3ab71ea6d3500856545e8b8736bcee907e58b3c4
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Apr 18 22:33:26 2021 +0200
tests: Add "generics reference transfer" test to increase coverage
tests/Makefile.am | 1 +
tests/generics/reference-transfer.vala | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 79656a816..0343c0fdf 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -678,6 +678,7 @@ TESTS = \
generics/parameter-sizeof-initializer.vala \
generics/member-dup-destroy.vala \
generics/property-int-cast.vala \
+ generics/reference-transfer.vala \
generics/string-literal-comparison.vala \
generics/type-parameter-properties.vala \
generics/value-pointer-type-access.vala \
diff --git a/tests/generics/reference-transfer.vala b/tests/generics/reference-transfer.vala
new file mode 100644
index 000000000..da2c1e305
--- /dev/null
+++ b/tests/generics/reference-transfer.vala
@@ -0,0 +1,24 @@
+class Bar<G> {
+ public G g;
+ public Bar (G g) {
+ this.g = g;
+ assert (g == "bar");
+ }
+}
+
+void bar<G> (Bar<G> g) {
+ var t = (owned) g.g;
+ assert (g.g == null);
+ assert (t == "bar");
+}
+
+void foo<G> (owned G g) {
+ var t = (owned) g;
+ assert (g == null);
+ assert (t == "foo");
+}
+
+void main () {
+ foo<string> ("foo");
+ bar<string> (new Bar<string> ("bar"));
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]