1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/ruby/test_range.rb
shyouhei 4e5325fe1f merge revision(s) 31302:
backported r31286 from trunk

	* numeric.c (ruby_float_step): wrong loop condition.
	  fixes [ruby-core:35753], reported by Joey Zhou.

	* test/ruby/test_range.rb (TestRange#test_step_ruby_core_35753):
	  test above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@31302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Signed-off-by: URABE, Shyouhei <shyouhei@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@31663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-20 22:29:05 +00:00

26 lines
784 B
Ruby

require 'test/unit'
class TestRange < Test::Unit::TestCase
def test_range_string
# XXX: Is this really the test of Range?
assert_equal([], ("a" ... "a").to_a)
assert_equal(["a"], ("a" .. "a").to_a)
assert_equal(["a"], ("a" ... "b").to_a)
assert_equal(["a", "b"], ("a" .. "b").to_a)
end
def test_evaluation_order
arr = [1,2]
r = (arr.shift)..(arr.shift)
assert_equal(1..2, r, "[ruby-dev:26383]")
end
def test_step_ruby_core_35753
assert_equal(6, (1...6.3).step.to_a.size)
assert_equal(5, (1.1...6).step.to_a.size)
assert_equal(5, (1...6).step(1.1).to_a.size)
assert_equal(3, (1.0...6.3).step(1.8).to_a.size)
assert_equal(3, (1.0...6.4).step(1.8).to_a.size)
assert_equal(4, (1.0...6.5).step(1.8).to_a.size)
end
end