summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2023-10-22 10:07:09 -0500
committerGitHub <noreply@github.com>2023-10-22 10:07:09 -0500
commitedb52293d9a407161a17be875a3539a724551057 (patch)
treefdc94635776ee063998caa86058a9c2f9b6befe1
parent379ce2b5e5dd5d15bf0a633f86f60686dee35176 (diff)
parent421c61e7306b6707e0bfcb88c7b88ce7f47820b0 (diff)
downloadredot-cpp-edb52293d9a407161a17be875a3539a724551057.tar.gz
Merge pull request #1278 from dsnopek/gdextension-callable-bind-test
Add test for `Callable.bind()`
-rw-r--r--test/project/main.gd3
-rw-r--r--test/src/example.cpp6
-rw-r--r--test/src/example.h2
3 files changed, 11 insertions, 0 deletions
diff --git a/test/project/main.gd b/test/project/main.gd
index f51ef3b..41a5e02 100644
--- a/test/project/main.gd
+++ b/test/project/main.gd
@@ -83,6 +83,9 @@ func _ready():
var array: Array[int] = [1, 2, 3]
assert_equal(example.test_tarray_arg(array), 6)
+ example.callable_bind()
+ assert_equal(custom_signal_emitted, ["bound", 11])
+
# String += operator
assert_equal(example.test_string_ops(), "ABCĎE")
diff --git a/test/src/example.cpp b/test/src/example.cpp
index 759cc4f..3bb0cb2 100644
--- a/test/src/example.cpp
+++ b/test/src/example.cpp
@@ -176,6 +176,7 @@ void Example::_bind_methods() {
ClassDB::bind_method(D_METHOD("return_last_rpc_arg"), &Example::return_last_rpc_arg);
ClassDB::bind_method(D_METHOD("def_args", "a", "b"), &Example::def_args, DEFVAL(100), DEFVAL(200));
+ ClassDB::bind_method(D_METHOD("callable_bind"), &Example::callable_bind);
ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static);
ClassDB::bind_static_method("Example", D_METHOD("test_static2"), &Example::test_static2);
@@ -496,6 +497,11 @@ int Example::return_last_rpc_arg() {
return last_rpc_arg;
}
+void Example::callable_bind() {
+ Callable c = Callable(this, "emit_custom_signal").bind("bound", 11);
+ c.call();
+}
+
// Properties.
void Example::set_custom_position(const Vector2 &pos) {
custom_position = pos;
diff --git a/test/src/example.h b/test/src/example.h
index 4dfda23..e922c48 100644
--- a/test/src/example.h
+++ b/test/src/example.h
@@ -157,6 +157,8 @@ public:
void test_send_rpc(int p_value);
int return_last_rpc_arg();
+ void callable_bind();
+
// Property.
void set_custom_position(const Vector2 &pos);
Vector2 get_custom_position() const;