Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for Callable.bind() #1278

Merged
merged 1 commit into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/project/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
6 changes: 6 additions & 0 deletions test/src/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions test/src/example.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class Example : public Control {
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;
Expand Down