Skip to content

Conversation

@Curtis-Barnhart
Copy link
Contributor

@Curtis-Barnhart Curtis-Barnhart commented Dec 26, 2025

Resolves #786

Previously anonymous functions could not be tested for connection in assert_connected and assert_not_connected. The connection assertions relied on using the names of methods instead of references to them, which gets a little messy with anonymous function because they are all just named "<anonymous function>" (or something similar, I don't remember exactly what).

This PR implements a new system for testing signal/method connection that stores references to methods instead of just their names (and adds tests to make sure this behavior is well documented). The signature of the assertion methods was also a little bit complicated and untyped, and so I took the liberty of adding a push_error informing the user they have incorrectly called the assertion method in the case that they have. I can certainly remove this part if it is found unnecessary.

…string identifiers, allowing callables to be anonymous
Copy link
Owner

@bitwes bitwes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. These signal asserts are very unwieldy, and this is a good patch to get the new assert functionality.

Just a minor change to not replicate the ugliness of SignalAssertParameters.others. Changing _get_connection_info to return a dictionary might help refactoring that class later too (it needs it).

return true
return false
push_error("Signal connection assertion called with bad signature. Read Docstring for correct signature.")
return [connected, signal_name, method_name, signal_object_name, method_object_name]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should return a dictionary, an array is too fragile.

Comment on lines +1449 to +1454
var conn_result = _get_connection_info(p1, p2, p3, p4)
var connected = conn_result[0]
var signal_name = conn_result[1]
var method_name = conn_result[2]
var signal_object_name = conn_result[3]
var method_object_name = conn_result[4]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing _get_connection_info to return a dictionary means we can use the dictionary values directly.

Comment on lines +1474 to +1479
var conn_result = _get_connection_info(p1, p2, p3, p4)
var connected = conn_result[0]
var signal_name = conn_result[1]
var method_name = conn_result[2]
var signal_object_name = conn_result[3]
var method_object_name = conn_result[4]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as assert_connected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

assert_connected does not work with anonymous functions

2 participants