mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add a test for duck-type range.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
85eadbbf8c
commit
b08e8d937f
1 changed files with 12 additions and 0 deletions
|
@ -14,4 +14,16 @@ class TestRange < Test::Unit::TestCase
|
|||
r = (arr.shift)..(arr.shift)
|
||||
assert_equal(1..2, r, "[ruby-dev:26383]")
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue