Debian Codegraph @

modules/gdscript/tests/scripts/parser/features/truthiness.gd

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