diff options
author | tarui <tarui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-05 19:06:08 +0000 |
---|---|---|
committer | tarui <tarui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-05 19:06:08 +0000 |
commit | 9ca738927293df1c7a2a1ed7e2d6cf89527b5438 (patch) | |
tree | ca0329dafd191b1b315e7f3e5f90926cfa916487 /test/ruby | |
parent | 19dec2a19c25f4cfb2511c313fde969436437bd0 (diff) | |
download | ruby-9ca738927293df1c7a2a1ed7e2d6cf89527b5438.tar.gz |
range.c: Range#cover? accepts Range object. [Feature #14473]
* range.c (range_cover): add code for range argument.
If the argument is a Range, check it is or is not
covered by the reciver. If it can be treated as a
sequence, this method treats it that way.
* test/ruby/test_range.rb (class TestRange): add tests
for this feature.
This patch is written by Owen Stephens. thank you!
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_range.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index a845dc4929..c1d9dc1848 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -525,6 +525,52 @@ class TestRange < Test::Unit::TestCase assert_not_operator(5..., :cover?, 0) assert_not_operator(5..., :cover?, "a") assert_operator(5.., :cover?, 10) + + assert_operator(2..5, :cover?, 2..5) + assert_operator(2...6, :cover?, 2...6) + assert_operator(2...6, :cover?, 2..5) + assert_operator(2..5, :cover?, 2...6) + assert_operator(2..5, :cover?, 2..4) + assert_operator(2..5, :cover?, 2...4) + assert_operator(2..5, :cover?, 2...5) + assert_operator(2..5, :cover?, 3..5) + assert_operator(2..5, :cover?, 3..4) + assert_operator(2..5, :cover?, 3...6) + assert_operator(2...6, :cover?, 2...5) + assert_operator(2...6, :cover?, 2..5) + assert_operator(2..6, :cover?, 2...6) + assert_operator(2.., :cover?, 2..) + assert_operator(2.., :cover?, 3..) + assert_operator(1.., :cover?, 1..10) + assert_operator(2.0..5.0, :cover?, 2..3) + assert_operator(2..5, :cover?, 2.0..3.0) + assert_operator(2..5, :cover?, 2.0...3.0) + assert_operator(2..5, :cover?, 2.0...5.0) + assert_operator(2.0..5.0, :cover?, 2.0...3.0) + assert_operator(2.0..5.0, :cover?, 2.0...5.0) + assert_operator('aa'..'zz', :cover?, 'aa'...'bb') + + assert_not_operator(2..5, :cover?, 1..5) + assert_not_operator(2...6, :cover?, 1..5) + assert_not_operator(2..5, :cover?, 1...6) + assert_not_operator(1..3, :cover?, 1...6) + assert_not_operator(2..5, :cover?, 2..6) + assert_not_operator(2...6, :cover?, 2..6) + assert_not_operator(2...6, :cover?, 2...7) + assert_not_operator(2..3, :cover?, 1..4) + assert_not_operator(1..2, :cover?, 1.0..3.0) + assert_not_operator(1.0..2.9, :cover?, 1.0..3.0) + assert_not_operator(1..2, :cover?, 4..3) + assert_not_operator(2..1, :cover?, 1..2) + assert_not_operator(1...2, :cover?, 1...3) + assert_not_operator(2.., :cover?, 1..) + assert_not_operator(2.., :cover?, 1..10) + assert_not_operator(1..10, :cover?, 1..) + assert_not_operator(1..5, :cover?, 3..2) + assert_not_operator(1..10, :cover?, 3...2) + assert_not_operator(1..10, :cover?, 3...3) + assert_not_operator('aa'..'zz', :cover?, 'aa'...'zzz') + assert_not_operator(1..10, :cover?, 1...10.1) end def test_beg_len |