summary refs log tree commit
path: root/tests
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-04-01 11:15:22 +0100
committerJon Leighton <j@jonathanleighton.com>2011-04-01 11:15:22 +0100
commitf067f0c9b8b69b80b9e4e035d2130f8fca58370c (patch)
treebe07c8b2d5cf65086fad7b56a09c2145cd5c8478 /tests
parent514d791dd8602ad1d70d45a824927aafe44e838c (diff)
downloadruby-json-f067f0c9b8b69b80b9e4e035d2130f8fca58370c.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')
-rwxr-xr-xtests/test_json.rb14
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