diff options
| author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-11 14:55:00 +0000 |
|---|---|---|
| committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-11 14:55:00 +0000 |
| commit | b64a3e41202c86e5eaa410fe182b3dfdb2b0dc4c (patch) | |
| tree | dfca666818ec67f8c525619dd4075d14b7ebb1ed /test/ruby/test_struct.rb | |
| parent | 0d2b4a6dd8df62fb796b05c734b1d97f1a6f1eda (diff) | |
merge revision(s) r42479,r42490,r42509,r43083,r43084,r43085: [Backport #8756] [Backport #9248]
* parse.y (rb_enc_symname_type): allow ID_ATTRSET for ID_INSTANCE,
ID_GLOBAL, ID_CLASS, ID_JUNK too. [Bug #8756]
* parse.y (rb_id_attrset): fix inconsistency with literals, allow
ID_ATTRSET and return it itself, but ID_JUNK cannot make ID_ATTRSET.
and raise a NameError instead of rb_bug() for invalid argument.
* parse.y (rb_id_attrset, intern_str): allow junk attrset ID for
Struct.
* parse.y (rb_id_attrset): check if the argument is valid type as an
attribute.
* parse.y (rb_id_attrset): allow other than ID_ATTRSET.
* parse.y (intern_str): ditto. try stem ID for ID_INSTANCE,
ID_GLOBAL, ID_CLASS, ID_JUNK too. [Bug #8756]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_struct.rb')
| -rw-r--r-- | test/ruby/test_struct.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb index 1c108777ee..db74438734 100644 --- a/test/ruby/test_struct.rb +++ b/test/ruby/test_struct.rb @@ -142,7 +142,19 @@ class TestStruct < Test::Unit::TestCase klass = Struct.new(:@a) o = klass.new(1) + assert_equal(1, o.__send__(:@a)) assert_equal("#<struct :@a=1>", o.inspect) + o.__send__(:"@a=", 2) + assert_equal(2, o.__send__(:@a)) + assert_equal("#<struct :@a=2>", o.inspect) + o.__send__("@a=", 3) + assert_equal(3, o.__send__(:@a)) + assert_equal("#<struct :@a=3>", o.inspect) + + methods = klass.instance_methods(false) + assert_equal([:@a, :"@a="].inspect, methods.inspect, '[Bug #8756]') + assert_include(methods, :@a) + assert_include(methods, :"@a=") end def test_init_copy @@ -281,4 +293,10 @@ class TestStruct < Test::Unit::TestCase o = klass.new(1, 2, 3, 4, 5, 6) assert_equal({a:1, b:2, c:3, d:4, e:5, f:6}, o.to_h) end + + def test_struct_question_mark + bug9248 = '[ruby-core:59095]' + klass = Struct.new(:a?) + assert_include(klass.new.methods.inspect, ':a?', bug9248) + end end |
