truthiness.gd 858 B

123456789101112131415161718192021222324252627282930
  1. func test():
  2. # The assertions below should all evaluate to `true` for this test to pass.
  3. assert(true)
  4. assert(not false)
  5. assert(500)
  6. assert(not 0)
  7. assert(500.5)
  8. assert(not 0.0)
  9. assert("non-empty string")
  10. assert(["non-empty array"])
  11. assert({"non-empty": "dictionary"})
  12. assert(Vector2(1, 0))
  13. assert(Vector2i(-1, -1))
  14. assert(Vector3(0, 0, 0.0001))
  15. assert(Vector3i(0, 0, 10000))
  16. # Zero position is `true` only if the Rect2's size is non-zero.
  17. assert(Rect2(0, 0, 0, 1))
  18. # Zero size is `true` only if the position is non-zero.
  19. assert(Rect2(1, 1, 0, 0))
  20. # Zero position is `true` only if the Rect2's size is non-zero.
  21. assert(Rect2i(0, 0, 0, 1))
  22. # Zero size is `true` only if the position is non-zero.
  23. assert(Rect2i(1, 1, 0, 0))
  24. # A fully black color is only truthy if its alpha component is not equal to `1`.
  25. assert(Color(0, 0, 0, 0.5))