summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 21:20:10 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 21:20:10 +0000
commite44e356b53828d6468114b30e5c169296896f9b1 (patch)
treea24b67a505ccbba2f6b2204bcfc0aa6f7bdd3298 /test
parent3785d2675abf2e4aca07e89596ea6f12b4c474a5 (diff)
* lib/ostruct.rb: Add [] and []=, base on a patch by Thomas Sawyer
[ruby-core:42779] [Feature #6056] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ostruct/test_ostruct.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index 491f950..d82bab9 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -70,14 +70,19 @@ class TC_OpenStruct < Test::Unit::TestCase
assert_equal(a, 'a')
end
- def test_method_missing_handles_square_bracket_equals
- o = OpenStruct.new
- assert_raise(NoMethodError) { o[:foo] = :bar }
+ def test_setter
+ os = OpenStruct.new
+ os[:foo] = :bar
+ assert_equal :bar, os.foo
+ os['foo'] = :baz
+ assert_equal :baz, os.foo
end
- def test_method_missing_handles_square_brackets
- o = OpenStruct.new
- assert_raise(NoMethodError) { o[:foo] }
+ def test_getter
+ os = OpenStruct.new
+ os.foo = :bar
+ assert_equal :bar, os[:foo]
+ assert_equal :bar, os['foo']
end
def test_to_h