Skip to content

Commit

Permalink
Fix command pattern test
Browse files Browse the repository at this point in the history
  • Loading branch information
ysakasin committed Nov 8, 2020
1 parent 76e07e1 commit 10c244f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/bcdice/common_command/repeat.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/test_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]"))
Expand All @@ -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"))
Expand Down

0 comments on commit 10c244f

Please sign in to comment.