[tests] Add callback scope tests
authorJohan Dahlin <johan@gnome.org>
Thu, 2 Sep 2010 20:18:35 +0000 (17:18 -0300)
committerJohan Dahlin <johan@gnome.org>
Thu, 2 Sep 2010 20:19:18 +0000 (17:19 -0300)
And fix a bug in the warning call in the scanner

giscanner/maintransformer.py
tests/warn/Makefile.am
tests/warn/callback-invalid-scope.h [new file with mode: 0644]
tests/warn/callback-missing-scope.h [new file with mode: 0644]

index 9a8d93de517846e95a89181617909fc199bc2f45..1aeb089b10ba27c1935baa7cca0c2fcb7b49cbfe 100644 (file)
@@ -485,9 +485,9 @@ class MainTransformer(object):
                 if scope not in [ast.PARAM_SCOPE_CALL,
                                  ast.PARAM_SCOPE_ASYNC,
                                  ast.PARAM_SCOPE_NOTIFIED]:
-                    message.warn(
+                    message.warn_node(
                         parent,
-                        "Invalid scope %r for parameter %r" % (scope, param.name))
+                        "Invalid scope %r for parameter %r" % (scope, param.argname))
                 else:
                     param.scope = scope
                     param.transfer = ast.PARAM_TRANSFER_NONE
index aefc7a70a9573c0ca0eef8a1dfc3c4bf83387022..2d3c324087b8f806fda813f1e61b9ec1cdb7bf26 100644 (file)
@@ -1,6 +1,8 @@
 include $(top_srcdir)/common.mk
 
 TESTS = \
+       callback-invalid-scope.h \
+       callback-missing-scope.h \
        return-gobject.h \
        unresolved-type.h
 
diff --git a/tests/warn/callback-invalid-scope.h b/tests/warn/callback-invalid-scope.h
new file mode 100644 (file)
index 0000000..c42a49a
--- /dev/null
@@ -0,0 +1,11 @@
+#include "common.h"
+
+/**
+ * test_callback_invalid:
+ * @callback: (scope invalid):
+ *
+ */
+void test_callback_invalid(GCallback *callback, gpointer user_data);
+
+// EXPECT:8: Warning: Test: test_callback_invalid: argument callback: Missing (scope) annotation for callback without GDestroyNotify (valid: call, async)
+// EXPECT:8: Warning: Test: Invalid scope 'invalid' for parameter 'callback'
diff --git a/tests/warn/callback-missing-scope.h b/tests/warn/callback-missing-scope.h
new file mode 100644 (file)
index 0000000..7932198
--- /dev/null
@@ -0,0 +1,5 @@
+#include "common.h"
+
+void test_callback(GCallback *callback, gpointer user_data);
+
+// EXPECT:3: Warning: Test: test_callback: argument callback: Missing (scope) annotation for callback without GDestroyNotify (valid: call, async)