From 4902ef7d591fb01f6c9f70ec194e147c47935541 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 8 Jul 2011 07:40:41 +0000 Subject: * ext/json/parser/parser.rl (convert_encoding): should not modify the argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/json/test_json.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/json') diff --git a/test/json/test_json.rb b/test/json/test_json.rb index 4c724fd36e..5f186f0c08 100755 --- a/test/json/test_json.rb +++ b/test/json/test_json.rb @@ -398,4 +398,17 @@ EOT json = JSON::Parser.allocate assert_raises(TypeError, '[ruby-core:35079]') {json.source} end + + def test_argument_encoding + source = "{}".force_encoding("ascii-8bit") + JSON::Parser.new(source) + assert_equal Encoding::ASCII_8BIT, source.encoding + end + + def test_frozen_argument + source = "{}".force_encoding("ascii-8bit") + source.freeze + parser = nil + assert_nothing_raised {parser = JSON::Parser.new(source)} + end end -- cgit v1.2.3