From 9cc62abc6b0245e5f0e4a8f0cd9b6f53a4f9bf77 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 5 Feb 2011 01:30:01 +0000 Subject: * ext/json/parser/parser.h (GET_PARSER): check if initialized. [ruby-core:35079] * ext/json/parser/parser.rl (cParser_initialize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/json/test_json.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/json/test_json.rb') diff --git a/test/json/test_json.rb b/test/json/test_json.rb index 00e52f511a..cb70085242 100755 --- a/test/json/test_json.rb +++ b/test/json/test_json.rb @@ -391,4 +391,11 @@ EOT json5 = JSON([orig = 1 << 64]) assert_equal orig, JSON[json5][0] end + + def test_allocate + json = JSON::Parser.new("{}") + assert_raises(ArgumentError, '[ruby-core:35079]') {json.__send__(:initialize, "{}")} + json = JSON::Parser.allocate + assert_raises(ArgumentError, '[ruby-core:35079]') {json.source} + end end -- cgit v1.2.3