2003-10-16 22:18:01 -04:00
|
|
|
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
|
2005-06-30 02:27:05 -04:00
|
|
|
|
|
|
|
def test_evaluation_order
|
|
|
|
arr = [1,2]
|
|
|
|
r = (arr.shift)..(arr.shift)
|
|
|
|
assert_equal(1..2, r, "[ruby-dev:26383]")
|
|
|
|
end
|
2005-08-04 01:19:44 -04:00
|
|
|
|
|
|
|
class DuckRange
|
|
|
|
def initialize(b,e)
|
|
|
|
@begin = b
|
|
|
|
@end = e
|
|
|
|
end
|
|
|
|
attr_reader :begin, :end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_duckrange
|
|
|
|
assert_equal("bc", "abcd"[DuckRange.new(1,2)])
|
|
|
|
end
|
2003-10-16 22:18:01 -04:00
|
|
|
end
|