diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-22 06:59:00 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-22 06:59:00 +0000 |
commit | 88efadca4aea13b6c5f3cd4b39c932004d4a23e2 (patch) | |
tree | d0c6e0e0506733a3563d3c39826435f94fff1f1d /test | |
parent | 8d9e1ca97219af43e99f8987070130914c18a584 (diff) |
merge revision(s) 54611,54612: [Backport #12291]
* struct.c (struct_make_members_list): extract making member name
list from char* va_list, with creating symbols without
intermediate IDs.
* struct.c (struct_make_members_list, rb_struct_s_def): member
names should be unique. [ruby-core:74971] [Bug #12291]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@54685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/-ext-/struct/test_duplicate.rb | 22 | ||||
-rw-r--r-- | test/ruby/test_struct.rb | 7 |
2 files changed, 29 insertions, 0 deletions
diff --git a/test/-ext-/struct/test_duplicate.rb b/test/-ext-/struct/test_duplicate.rb new file mode 100644 index 0000000000..77d61988b6 --- /dev/null +++ b/test/-ext-/struct/test_duplicate.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: false +require 'test/unit' +require "-test-/struct" + +class Bug::Struct::Test_Duplicate < Test::Unit::TestCase + def test_new_dupilicate + bug12291 = '[ruby-core:74971] [Bug #12291]' + assert_raise_with_message(ArgumentError, /duplicate member/, bug12291) { + Bug::Struct.new_duplicate(nil, "a") + } + assert_raise_with_message(ArgumentError, /duplicate member/, bug12291) { + Bug::Struct.new_duplicate("X", "a") + } + end + + def test_new_dupilicate_under + bug12291 = '[ruby-core:74971] [Bug #12291]' + assert_raise_with_message(ArgumentError, /duplicate member/, bug12291) { + Bug::Struct.new_duplicate_under("x", "a") + } + end +end diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb index df859f75cb..e0c3b5f406 100644 --- a/test/ruby/test_struct.rb +++ b/test/ruby/test_struct.rb @@ -353,6 +353,13 @@ module TestStruct assert_equal "[Bug #9353]", x.send(:a=, "[Bug #9353]") end + def test_new_dupilicate + bug12291 = '[ruby-core:74971] [Bug #12291]' + assert_raise_with_message(ArgumentError, /duplicate member/, bug12291) { + @Struct.new(:a, :a) + } + end + class TopStruct < Test::Unit::TestCase include TestStruct |