String#upto with sequence of numbers should behave as Integer#upto for x19 #2309

Merged
merged 2 commits into from Apr 23, 2013

Projects

None yet

3 participants

@kachick
Member
kachick commented Apr 23, 2013

MRI(ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux])

'9'.upto('10').to_a #=> ["9", "10"]

Rubinius(rubinius 2.0.0.rc1 (1.9.3 7495528 yyyy-mm-dd JI) [x86_64-unknown-linux-gnu])

 '9'.upto('10').to_a #=> []
@jc00ke jc00ke and 1 other commented on an outdated diff Apr 23, 2013
spec/ruby/core/string/upto_spec.rb
@@ -111,4 +111,17 @@ def other.to_str() "abd" end
end
end
+ ruby_version_is ''...'1.9' do
+ it "stops before the last value if increase the digit" do
@jc00ke
jc00ke Apr 23, 2013 Rubinius member

it "stops before the last value if the digit increases"?

I don't quite understand this description. Can you clarify?

@kachick
kachick Apr 23, 2013 Rubinius member

Thank you for the pointing out.
I'll retry it.

@jc00ke jc00ke commented on an outdated diff Apr 23, 2013
spec/ruby/core/string/upto_spec.rb
@@ -111,4 +111,17 @@ def other.to_str() "abd" end
end
end
+ ruby_version_is ''...'1.9' do
+ it "stops before the last value if increase the digit" do
+ "9".upto("10", true).to_a.should == ["9"]
+ "9".upto("10", false).to_a.should == ["9"]
+ end
+ end
+
+ ruby_version_is '1.9' do
+ it "stops before the last value if increase the digit and exclusive end value" do
@jc00ke
jc00ke Apr 23, 2013 Rubinius member

This one too. Are you saying it "stops before the last value if the digit increases and excludes the ending value?"

Also should these be 2 different specs since the behavior is different based on the truthiness of the 2nd arg?

kachick added some commits Apr 23, 2013
@kachick kachick Add specs for String#upto on sequence of numbers dc64a28
@kachick kachick Fix String#upto on sequence of numbers for X19
MRI(ruby 1.9.3p392 (2013-02-22 revision 39386))
----

    '9'.upto('10').to_a #=> ["9", "10"]

Rubinius(X19)
--------

    '9'.upto('10').to_a #=> []
e5d336a
@dbussink dbussink merged commit 4e33cc3 into rubinius:master Apr 23, 2013

1 check failed

Details default The Travis build failed
@kachick kachick deleted the kachick:fix-string-upto-x19 branch Apr 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment