diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-04-01 11:15:22 +0100 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2011-05-11 16:50:35 +0200 |
commit | 8058e5af0108e3e59d5b3c4769214aa38bbecaf6 (patch) | |
tree | 158d29f28764f780507940b917b9ff3a7ecd97ef /tests/test_json.rb | |
parent | 28f064362a4c00483fab8078cc97b1431e871d8f (diff) | |
download | json-8058e5af0108e3e59d5b3c4769214aa38bbecaf6.tar.gz |
If a custom :object_class is given, the C extension should not use rb_hash_aset - it should call the object's []= method instead.
Diffstat (limited to 'tests/test_json.rb')
-rwxr-xr-x | tests/test_json.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/test_json.rb b/tests/test_json.rb index 2fc3c09..06ee581 100755 --- a/tests/test_json.rb +++ b/tests/test_json.rb @@ -197,12 +197,22 @@ class TC_JSON < Test::Unit::TestCase o.delete JSON.create_id self[o] end + + def []=(k, v) + @item_set = true + super + end + + def item_set? + @item_set + end end def test_parse_object_custom_class - res = parse('{}', :object_class => SubHash2) - assert_equal({}, res) + res = parse('{"foo":"bar"}', :object_class => SubHash2) + assert_equal({"foo" => "bar"}, res) assert_equal(SubHash2, res.class) + assert res.item_set? end def test_generation_of_core_subclasses_with_new_to_json |