diff --git a/lib/bcdice/common_command/repeat.rb b/lib/bcdice/common_command/repeat.rb index a4663e492..3c2d4ba70 100644 --- a/lib/bcdice/common_command/repeat.rb +++ b/lib/bcdice/common_command/repeat.rb @@ -1,7 +1,7 @@ module BCDice module CommonCommand class Repeat - PREFIX_PATTERN = /^(rep|repeat|x)\d+/.freeze + PREFIX_PATTERN = /(rep|repeat|x)\d+/.freeze COMMAND_REGEXP = /\A(?:rep|repeat|x)(\d+)(?: |$)/i.freeze REPEAT_LIMIT = 100 diff --git a/test/test_base.rb b/test/test_base.rb index 42ef7109e..010b93252 100644 --- a/test/test_base.rb +++ b/test/test_base.rb @@ -7,7 +7,7 @@ class DummySystem < BCDice::Base class TestBase < Test::Unit::TestCase def test_command_pattern - assert_equal(/^S?([\+\-\dD\(\[]+|\d+B\d+|C|choice|D66|\d+R\d+|\d+U\d+|BCDiceVersion|ABC|XYZ|IP\d+)/i, DummySystem.command_pattern) + assert_equal(/^S?([\+\-\dD\(\[]+|\d+B\d+|C|choice|D66|\d+R\d+|\d+U\d+|BCDiceVersion|ABC|XYZ|IP\d+|(rep|repeat|x)\d+)/i, DummySystem.command_pattern) assert(DummySystem.command_pattern.match?("ABC+123")) assert(DummySystem.command_pattern.match?("XYZ[hoge]")) @@ -24,6 +24,9 @@ def test_command_pattern assert(DummySystem.command_pattern.match?("1R10+5R6")) assert(DummySystem.command_pattern.match?("1U10+2U20")) assert(DummySystem.command_pattern.match?("bcdiceversion")) + assert(DummySystem.command_pattern.match?("x10 1D6")) + assert(DummySystem.command_pattern.match?("rep1 1D6")) + assert(DummySystem.command_pattern.match?("repeat10 1D6")) assert(DummySystem.command_pattern.match?("(1+2)D100<=70")) assert(DummySystem.command_pattern.match?("[1...3]D100<=70"))