diff options
author | Travis Hunter <travis.hunter@blueapron.com> | 2018-10-03 15:19:36 -0400 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-04-16 16:06:36 +0900 |
commit | 55d91a096a840aaff1e08a4286c216da56b6e968 (patch) | |
tree | 332782f96e893997e6c5952d659dce70016a70fa /test/ruby/test_array.rb | |
parent | 97cee1cba6c966e9eb390902f42941daf6f0d1fd (diff) |
Add Array#intersect?
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/1972
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r-- | test/ruby/test_array.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 789531fb8c..bf6a728574 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1100,6 +1100,19 @@ class TestArray < Test::Unit::TestCase assert_not_include(a, [1,2]) end + def test_intersect? + a = @cls[ 1, 2, 3] + assert_send([a, :intersect?, [3]]) + assert_not_send([a, :intersect?, [4]]) + assert_not_send([a, :intersect?, []]) + end + + def test_intersect_big_array + assert_send([@cls[ 1, 4, 5 ]*64, :intersect?, @cls[ 1, 2, 3 ]*64]) + assert_not_send([@cls[ 1, 2, 3 ]*64, :intersect?, @cls[ 4, 5, 6 ]*64]) + assert_not_send([@cls[], :intersect?, @cls[ 1, 2, 3 ]*64]) + end + def test_index a = @cls[ 'cat', 99, /a/, 99, @cls[ 1, 2, 3] ] assert_equal(0, a.index('cat')) |