diff options
| author | Sophia Pearson <codergal89@gmail.com> | 2022-05-23 00:02:58 +0200 |
|---|---|---|
| committer | Sophia Pearson <codergal89@gmail.com> | 2022-05-23 00:02:58 +0200 |
| commit | 6fe4972aa48a29d0aafee0461ccd6c635ca9ee6c (patch) | |
| tree | 30ff503136f1d41ccbb35d3bb9fa6ab92f1e839a /Tests/ComponentTests/ParserTests/CommandParserTestBase.gd | |
| parent | f3c50714834d2d5cb204625c63aaeffb50bef236 (diff) | |
| download | texty-6fe4972aa48a29d0aafee0461ccd6c635ca9ee6c.tar.xz texty-6fe4972aa48a29d0aafee0461ccd6c635ca9ee6c.zip | |
commands: add basic command parser infrastructure
Diffstat (limited to 'Tests/ComponentTests/ParserTests/CommandParserTestBase.gd')
| -rw-r--r-- | Tests/ComponentTests/ParserTests/CommandParserTestBase.gd | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Tests/ComponentTests/ParserTests/CommandParserTestBase.gd b/Tests/ComponentTests/ParserTests/CommandParserTestBase.gd new file mode 100644 index 0000000..6e452cb --- /dev/null +++ b/Tests/ComponentTests/ParserTests/CommandParserTestBase.gd @@ -0,0 +1,29 @@ +extends GutTest + +class_name CommandParserTestBase + +const CommandParser = preload("res://Scripts/CommandParser.cs") + +var _instance: CommandParser + +func _to_bits(number: int, bits: int) -> Array: + var result = [] + for bit in bits: + result.append(number & 1) + number = number >> 1 + return result + +func before_each(): + _instance = autofree(CommandParser.new()) + +func generate_capitalization_permutations(text: String) -> Array: + var result = [] + + for permutation in pow(2, text.length()): + var mask = _to_bits(permutation, text.length()) + var copy = String(text) + for index in len(mask): + if mask[index] == 1: + copy[index] = copy[index].to_upper() + result.append(copy) + return result; |
