summaryrefslogtreecommitdiff
path: root/test/json
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-01 16:26:15 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-01 16:26:15 +0000
commit521876c373ba3d1fac5de2dfe82539d98381bc10 (patch)
treed84c3a56d8a8b637226142718a73282663618ed0 /test/json
parent4a84c27e3ee50c4989591fcde2b7a10c5ccc0395 (diff)
* ext/json/lib/json/common.rb: don't use iconv on 1.9.
patched by Shota Fukumori [ruby-core:33164] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/json')
-rw-r--r--test/json/test_json_encoding.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/test/json/test_json_encoding.rb b/test/json/test_json_encoding.rb
index fdea329..cdeca58 100644
--- a/test/json/test_json_encoding.rb
+++ b/test/json/test_json_encoding.rb
@@ -7,7 +7,6 @@ when 'pure' then require 'json/pure'
when 'ext' then require 'json/ext'
else require 'json'
end
-require 'iconv'
class TC_JSONEncoding < Test::Unit::TestCase
include JSON
@@ -15,19 +14,21 @@ class TC_JSONEncoding < Test::Unit::TestCase
def setup
@utf_8 = '["© ≠ €!"]'
@parsed = [ "© ≠ €!" ]
- @utf_16_data = Iconv.iconv('utf-16be', 'utf-8', @parsed.first)
@generated = '["\u00a9 \u2260 \u20ac!"]'
- if defined?(::Encoding)
+ if String.method_defined?(:encode)
+ @utf_16_data = [@parsed.first.encode('utf-16be', 'utf-8')]
@utf_8_ascii_8bit = @utf_8.dup.force_encoding(Encoding::ASCII_8BIT)
- @utf_16be, = Iconv.iconv('utf-16be', 'utf-8', @utf_8)
+ @utf_16be = @utf_8.encode('utf-16be', 'utf-8')
@utf_16be_ascii_8bit = @utf_16be.dup.force_encoding(Encoding::ASCII_8BIT)
- @utf_16le, = Iconv.iconv('utf-16le', 'utf-8', @utf_8)
+ @utf_16le = @utf_8.encode('utf-16le', 'utf-8')
@utf_16le_ascii_8bit = @utf_16le.dup.force_encoding(Encoding::ASCII_8BIT)
- @utf_32be, = Iconv.iconv('utf-32be', 'utf-8', @utf_8)
+ @utf_32be = @utf_8.encode('utf-32be', 'utf-8')
@utf_32be_ascii_8bit = @utf_32be.dup.force_encoding(Encoding::ASCII_8BIT)
- @utf_32le, = Iconv.iconv('utf-32le', 'utf-8', @utf_8)
+ @utf_32le = @utf_8.encode('utf-32le', 'utf-8')
@utf_32le_ascii_8bit = @utf_32le.dup.force_encoding(Encoding::ASCII_8BIT)
else
+ require 'iconv'
+ @utf_16_data = Iconv.iconv('utf-16be', 'utf-8', @parsed.first)
@utf_8_ascii_8bit = @utf_8.dup
@utf_16be, = Iconv.iconv('utf-16be', 'utf-8', @utf_8)
@utf_16be_ascii_8bit = @utf_16be.dup