]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add "type-parameter property clash" test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 14 Dec 2021 09:38:37 +0000 (10:38 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 9 Jan 2022 09:01:30 +0000 (10:01 +0100)
This needs to be handled gracefully. So throwing an error is no option.

tests/Makefile.am
tests/generics/type-parameter-property-clash.vala [new file with mode: 0644]

index c0ea7d230eff131779819914d1cd484ab9a57c6f..c3f6dc6137b650c374c5fba9355d79d1a610fcdd 100644 (file)
@@ -736,6 +736,7 @@ TESTS = \
        generics/reference-transfer.vala \
        generics/string-literal-comparison.vala \
        generics/type-parameter-properties.vala \
+       generics/type-parameter-property-clash.vala \
        generics/value-pointer-type-access.vala \
        generics/bug640330.vala \
        generics/bug640330-2.test \
diff --git a/tests/generics/type-parameter-property-clash.vala b/tests/generics/type-parameter-property-clash.vala
new file mode 100644 (file)
index 0000000..760f5d1
--- /dev/null
@@ -0,0 +1,13 @@
+class Foo<G> : Object {
+       public Type foo_g_type { get { return typeof (G); } }
+}
+
+class Bar<G> : Foo<G> {
+       public Type bar_g_type { get { return typeof (G); } }
+}
+
+void main () {
+       var bar = new Bar<string> ();
+       assert (bar.bar_g_type == typeof (string));
+       assert (bar.foo_g_type == typeof (string));
+}