GDScript: Replace assert() with Utils.check() in tests

This commit is contained in:
Danil Alexeev 2024-08-28 17:41:52 +03:00
parent f648de1a83
commit c1322d41e6
No known key found for this signature in database
GPG key ID: 124453E157DA8DC7
32 changed files with 275 additions and 347 deletions

View file

@ -1,30 +1,32 @@
func test():
# The assertions below should all evaluate to `true` for this test to pass.
assert(true)
assert(not false)
assert(500)
assert(not 0)
assert(500.5)
assert(not 0.0)
assert("non-empty string")
assert(["non-empty array"])
assert({"non-empty": "dictionary"})
assert(Vector2(1, 0))
assert(Vector2i(-1, -1))
assert(Vector3(0, 0, 0.0001))
assert(Vector3i(0, 0, 10000))
# The checks below should all evaluate to `true` for this test to pass.
Utils.check(true)
Utils.check(not false)
Utils.check(500)
Utils.check(not 0)
Utils.check(500.5)
Utils.check(not 0.0)
Utils.check("non-empty string")
Utils.check(["non-empty array"])
Utils.check({"non-empty": "dictionary"})
Utils.check(Vector2(1, 0))
Utils.check(Vector2i(-1, -1))
Utils.check(Vector3(0, 0, 0.0001))
Utils.check(Vector3i(0, 0, 10000))
# Zero position is `true` only if the Rect2's size is non-zero.
assert(Rect2(0, 0, 0, 1))
Utils.check(Rect2(0, 0, 0, 1))
# Zero size is `true` only if the position is non-zero.
assert(Rect2(1, 1, 0, 0))
Utils.check(Rect2(1, 1, 0, 0))
# Zero position is `true` only if the Rect2's size is non-zero.
assert(Rect2i(0, 0, 0, 1))
Utils.check(Rect2i(0, 0, 0, 1))
# Zero size is `true` only if the position is non-zero.
assert(Rect2i(1, 1, 0, 0))
Utils.check(Rect2i(1, 1, 0, 0))
# A fully black color is only truthy if its alpha component is not equal to `1`.
assert(Color(0, 0, 0, 0.5))
Utils.check(Color(0, 0, 0, 0.5))
print("ok")