summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-16 04:00:14 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-16 04:00:14 +0000
commitc22b8537378a52b6d3c44f117e03feed98f92f43 (patch)
tree97c87ffa871a6022f52c3fcc36c2ffefc0e9ff0f /test
parent2b3982ad1c3291c3948548d32baac3350e5f32a6 (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_struct.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb
index 384c95f85b..edcd111acb 100644
--- a/test/ruby/test_struct.rb
+++ b/test/ruby/test_struct.rb
@@ -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