Alias Struct#select as Struct#filter. Patch by Kenichi Kamiya.

[Fix GH-#1862] [#1784]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
marcandre 2018-09-16 04:00:14 +00:00
parent 2b3982ad1c
commit c22b853737
6 changed files with 53 additions and 22 deletions

View file

@ -212,6 +212,13 @@ module TestStruct
assert_raise(ArgumentError) { o.select(1) }
end
def test_filter
klass = @Struct.new(:a, :b, :c, :d, :e, :f)
o = klass.new(1, 2, 3, 4, 5, 6)
assert_equal([1, 3, 5], o.filter {|v| v % 2 != 0 })
assert_raise(ArgumentError) { o.filter(1) }
end
def test_big_struct
klass1 = @Struct.new(*('a'..'z').map(&:to_sym))
o = klass1.new