diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-04-19 20:50:52 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-09-14 18:42:08 +0200 |
commit | c0083c0f90238f0eec01604dd9c952c8c5dc3c22 (patch) | |
tree | e7efc33ba4a25d8195f8089bf08be19311722da6 /modules/gdscript/tests/scripts/parser/features/bitwise_operators.gd | |
parent | a9b600bac0a9a8fdd3b217c6d3cb6639ae80c1f8 (diff) | |
download | redot-engine-c0083c0f90238f0eec01604dd9c952c8c5dc3c22.tar.gz |
Add dozens of new integration tests to the GDScript test suite
This also ignores `.out` files in the file format static checks.
Diffstat (limited to 'modules/gdscript/tests/scripts/parser/features/bitwise_operators.gd')
-rw-r--r-- | modules/gdscript/tests/scripts/parser/features/bitwise_operators.gd | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/parser/features/bitwise_operators.gd b/modules/gdscript/tests/scripts/parser/features/bitwise_operators.gd new file mode 100644 index 0000000000..de502c6ed1 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/bitwise_operators.gd @@ -0,0 +1,50 @@ +enum Flags { + FIRE = 1 << 1, + ICE = 1 << 2, + SLIPPERY = 1 << 3, + STICKY = 1 << 4, + NONSOLID = 1 << 5, + + ALL = FIRE | ICE | SLIPPERY | STICKY | NONSOLID, +} + + +func test(): + var flags = Flags.FIRE | Flags.SLIPPERY + print(flags) + + flags = Flags.FIRE & Flags.SLIPPERY + print(flags) + + flags = Flags.FIRE ^ Flags.SLIPPERY + print(flags) + + flags = Flags.ALL & (Flags.FIRE | Flags.ICE) + print(flags) + + flags = (Flags.ALL & Flags.FIRE) | Flags.ICE + print(flags) + + flags = Flags.ALL & Flags.FIRE | Flags.ICE + print(flags) + + # Enum value must be casted to an integer. Otherwise, a parser error is emitted. + flags &= int(Flags.ICE) + print(flags) + + flags ^= int(Flags.ICE) + print(flags) + + flags |= int(Flags.STICKY | Flags.SLIPPERY) + print(flags) + + print() + + var num = 2 << 4 + print(num) + + num <<= 2 + print(num) + + num >>= 2 + print(num) |