summaryrefslogtreecommitdiff
path: root/test/ruby/test_struct.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_struct.rb')
-rw-r--r--test/ruby/test_struct.rb18
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