Skip to content

Commit

Permalink
restricted name pattern (#151, rggen/rggen#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
taichi-ishitani authored Jan 15, 2025
1 parent c56640e commit 956aa5d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/rggen/core/utility/regexp_patterns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def included(klass)

private

VARIABLE_NAME_PATTERN = /[a-z_]\w*/i
VARIABLE_NAME_PATTERN = /[a-z]\w+/i

def variable_name
VARIABLE_NAME_PATTERN
Expand Down
13 changes: 6 additions & 7 deletions spec/rggen/core/utility/regexp_patterns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@ def regexp_pattern(type)
describe '#variable_name' do
it '識別子名にマッチするす' do
[
/_/i,
/_+/i,
/[a-z]/i,
/[a-z]+/i,
/_\d/i,
/_\d+/i,
/[a-z]{2,}/i,
/[a-z]\d/i,
/[a-z]\d+/i,
/[_a-z]\w+/i
/[a-z]\w+/i
].each do |pattern|
string = random_string(pattern)
expect(string).to match(regexp_pattern(:variable_name))
end

[
/_/,
/_+/,
/_\w+/,
/[a-z]/i,
/\d/i,
/\d+/i,
/\d_/i,
Expand Down

0 comments on commit 956aa5d

Please sign in to comment.