summaryrefslogtreecommitdiff
path: root/test/ostruct
diff options
context:
space:
mode:
Diffstat (limited to 'test/ostruct')
-rw-r--r--test/ostruct/test_ostruct.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index d07fef3a83..560979e887 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -246,4 +246,22 @@ class TC_OpenStruct < Test::Unit::TestCase
os = OpenStruct.new(method: :foo)
assert_equal(os.object_id, os.method!(:object_id).call)
end
+
+ def test_mistaken_subclass
+ sub = Class.new(OpenStruct) do
+ def [](k)
+ __send__(k)
+ super
+ end
+
+ def []=(k, v)
+ @item_set = true
+ __send__("#{k}=", v)
+ super
+ end
+ end
+ o = sub.new
+ o.foo = 42
+ assert_equal 42, o.foo
+ end
end