]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add "unique namespace" test
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 8 Jul 2020 20:57:56 +0000 (22:57 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 26 Jul 2020 08:41:29 +0000 (10:41 +0200)
A namespace symbol is unique for a given name in its CodeContext. This
means attributes are inherited accross all occurances.

tests/Makefile.am
tests/namespace/unique.vala [new file with mode: 0644]

index 630757d69240803001e5e3fc37d76290b08c9181..dc386d6354cf519f21365474041c285e70565aa5 100644 (file)
@@ -77,6 +77,7 @@ TESTS = \
        basic-types/bug788775.vala \
        constants/array-type-invalid.test \
        constants/glog.vala \
+       namespace/unique.vala \
        arrays/cast-silent-invalid.test \
        arrays/class-field-length-cname.vala \
        arrays/constant-element-access.vala \
diff --git a/tests/namespace/unique.vala b/tests/namespace/unique.vala
new file mode 100644 (file)
index 0000000..3ae4108
--- /dev/null
@@ -0,0 +1,16 @@
+namespace GLib {
+       public class ValaFoo {
+       }
+
+       public int vala_foo () {
+               return 42;
+       }
+}
+
+[CCode (cname = "g_vala_foo", cheader_filename = "glib.h")]
+extern int vala_foo ();
+
+void main () {
+       assert (vala_foo () == 42);
+       assert (typeof (ValaFoo).name () == "GValaFoo");
+}