Skip to content

Commit b15221c

Browse files
committed
close #5
1 parent d54a617 commit b15221c

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

lib/string/pattern/add_to_ruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def to_sp
263263
pats = "[" + pats + "]" unless set
264264
when :interval
265265
size = text.sub(",", "-").sub("{", "").sub("}", "")
266-
size.chop! if size[-1] == "-"
266+
size+=(default_infinite+size.chop.to_i).to_s if size[-1] == "-"
267267
pats = size + ":" + pats
268268
if !patg.empty?
269269
patg << pats

spec/string/pattern/add_to_ruby_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@
8383
it '/[m-z]+\d+\w+[ab]+/i.to_sp' do
8484
expect(/[m-z]+\d+\w+[ab]+/i.to_sp).to eq ["1-10:[mnopqrstuvwxyzMNOPQRSTUVWXYZ]", "1-10:n", "1-10:Ln_", "1-10:[aAbB]"]
8585
end
86+
it '/a{3,}/.to_sp' do
87+
expect(/a{3,}/.to_sp).to eq '3-13:[a]'
88+
end
89+
it '/a{3,8}/.to_sp' do
90+
expect(/a{3,8}/.to_sp).to eq '3-8:[a]'
91+
end
92+
it '/a{3}/.to_sp' do
93+
expect(/a{3}/.to_sp).to eq '3:[a]'
94+
end
95+
it '/a{15,}/.to_sp' do
96+
expect(/a{15,}/.to_sp).to eq '15-25:[a]'
97+
end
8698

8799
end
88100

spec/string/pattern/generate_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,7 @@
464464
regexp = /a{3}/
465465
expect(regexp.gen.match?(regexp)).to eq true
466466
end
467-
#todo: 3 or more is returning now always 3
468-
xit 'accepts a{3,}' do
467+
it 'accepts a{3,}' do
469468
regexp = /a{3}/
470469
expect(regexp.gen.match?(regexp)).to eq true
471470
end

0 commit comments

Comments
 (0)