summaryrefslogtreecommitdiff
path: root/test/ostruct/test_ostruct.rb
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2020-09-14 14:03:56 -0400
committerMarc-André Lafortune <github@marc-andre.ca>2020-09-14 16:10:37 -0400
commit67e5f7a9e508d6f33c1dd927753161e8b1d40a09 (patch)
tree0fa905fcf51e4e8701236b4f67b09d505d6cddfc /test/ostruct/test_ostruct.rb
parent39312cf4d6c2ab3f07d688ad1a467c8f84b58db0 (diff)
[ruby/ostruct] Reinstate recent changes
This reverts commit 28e60b0045b5732bca11012d81a5223001faa6b2.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3541
Diffstat (limited to 'test/ostruct/test_ostruct.rb')
-rw-r--r--test/ostruct/test_ostruct.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index 3917cc0417..d07fef3a83 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -225,9 +225,25 @@ class TC_OpenStruct < Test::Unit::TestCase
end
end
+ def test_access_undefined
+ os = OpenStruct.new
+ assert_nil os.foo
+ end
+
def test_overriden_private_methods
os = OpenStruct.new(puts: :foo, format: :bar)
assert_equal(:foo, os.puts)
assert_equal(:bar, os.format)
end
+
+ def test_overriden_public_methods
+ os = OpenStruct.new(method: :foo, class: :bar)
+ assert_equal(:foo, os.method)
+ assert_equal(:bar, os.class)
+ end
+
+ def test_access_original_methods
+ os = OpenStruct.new(method: :foo)
+ assert_equal(os.object_id, os.method!(:object_id).call)
+ end
end