diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-09-15 19:09:34 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-09-15 19:57:39 +0200 |
commit | c6ca09dc6f0fdf693c2a4445e556861691a81152 (patch) | |
tree | 486146583022e3bf72af033e21f13d6311856fd9 /modules/gdscript/tests/scripts/runtime/features/recursion.gd | |
parent | 520462e98c15ef583f24ea39fb874a388d377b1c (diff) | |
download | redot-engine-c6ca09dc6f0fdf693c2a4445e556861691a81152.tar.gz |
Add more integration tests to the GDScript test suite
This also fixes a typo in the `bitwise_float_right_operand.gd` test.
Diffstat (limited to 'modules/gdscript/tests/scripts/runtime/features/recursion.gd')
-rw-r--r-- | modules/gdscript/tests/scripts/runtime/features/recursion.gd | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/features/recursion.gd b/modules/gdscript/tests/scripts/runtime/features/recursion.gd new file mode 100644 index 0000000000..a35485022e --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/recursion.gd @@ -0,0 +1,19 @@ +func is_prime(number: int, divisor: int = 2) -> bool: + print(divisor) + if number <= 2: + return (number == 2) + elif number % divisor == 0: + return false + elif divisor * divisor > number: + return true + + return is_prime(number, divisor + 1) + +func test(): + # Not a prime number. + print(is_prime(989)) + + print() + + # Largest prime number below 10000. + print(is_prime(9973)) |