From 7588c674d52791a15fa7631ba2628d6547ad1185 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 19 Nov 2012 07:31:05 +0000 Subject: struct.c: yield assoc in each_pair * struct.c (rb_struct_each_pair): yield associated pairs so that an unsplat argument can get both, for consistency with Hash, OpenStruct, and etc. [ruby-dev:46533] [Bug #7382] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_struct.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb index b3191902a3..03cb55999c 100644 --- a/test/ruby/test_struct.rb +++ b/test/ruby/test_struct.rb @@ -1,3 +1,4 @@ +# -*- coding: us-ascii -*- require 'test/unit' require 'timeout' require_relative 'envutil' @@ -117,6 +118,10 @@ class TestStruct < Test::Unit::TestCase klass = Struct.new(:a, :b) o = klass.new(1, 2) assert_equal([[:a, 1], [:b, 2]], o.each_pair.to_a) + bug7382 = '[ruby-dev:46533]' + a = [] + o.each_pair {|x| a << x} + assert_equal([[:a, 1], [:b, 2]], a, bug7382) end def test_inspect -- cgit v1.2.1