Closed lars-hoeck closed 1 year ago
You are using the assert in a wrong way :)
If you want to get the autocompletion of the functions of an assert, you have to use the typed asserts.
e.g. assert_array()
For testsing equivalence you can always use assert_that(<current>).is_equal(<expected>)
, the assert is automatically typed.
func test_poolarrayassert():
var p1 := PoolByteArray()
p1.append(1)
p1.append(2)
p1.append(3)
var p2 := PoolByteArray()
p2.append(2)
p2.append(3)
assert_array(p1).has_size(3).contains([2])
assert_array(p1).contains_exactly([1,2,3])
assert_that(p1).is_equal(p2)
In your example you are trying to test an array against an integer.
The error is not good, yes, we can think about implementing a type check on assert_array(<>).is_equal(<expected>)
.
To fail with an appropriate error message.
Expecting to be equal:
<current>
But the expectend value is not an array
<expected value> + type info
Ahh this typo will haunt me forever, thanks.
Ahh this typo will haunt me forever, thanks.
np ;)
The used Godot version: Godot Engine v3.5.1.stable.official.6fed1ffa3
OS including version: Windows 10 Acer Switch Alpha 12
Describe the bug In Debug: Its not possible to assert that two variables of type PoolTypeArray are equal. Return "Invalid call. Nonexisting 'Array' constructor". In Run: Test is succesfull even when wrong.
Steps to Reproduce Run following in Debug
Minimal reproduction project:
I think a assert_poolbytearray, would improve the situation because i dont have to use assert_that. The error massage is pretty clear "Invalid call. Nonexisting 'Array' constructor" , so we need to include a check for all types that don't have array constructor or throw an error in assert_that that its not possible, so we need to use a assert_datatype.