aboutsummaryrefslogtreecommitdiffstats
path: root/test/json/test_json_encoding.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-04-11 11:14:36 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-04-11 11:14:36 +0000
commitcfaddc2a3248dd0ce4a370fdbab44ca88adf5722 (patch)
tree6c004c0c73ea77dc6c77033632241f6ba4f77a58 /test/json/test_json_encoding.rb
parent8e7b572d97f0a19a8467f3a299d72c49ba51a293 (diff)
downloadruby-cfaddc2a3248dd0ce4a370fdbab44ca88adf5722.tar.gz
* ext/json/*, test/json/*, defs/default_gems: Gemify JSON library.
[fix GH-867][Feature #11057] * test/ruby/test_extlibs.rb: removed json gem from existence extentions. * gems/bundled_gems: added json gem into bundled gem. * lib/rdoc/rubygems_hook.rb: ignored no json environment. * lib/rubygems/test_case.rb, test/rubygems/*: ditto. * lib/rdoc/test_case.rb, test/rdoc/*: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/json/test_json_encoding.rb')
-rw-r--r--test/json/test_json_encoding.rb65
1 files changed, 0 insertions, 65 deletions
diff --git a/test/json/test_json_encoding.rb b/test/json/test_json_encoding.rb
deleted file mode 100644
index fa7d878920..0000000000
--- a/test/json/test_json_encoding.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env ruby
-# encoding: utf-8
-
-require 'test/unit'
-require File.join(File.dirname(__FILE__), 'setup_variant')
-
-class TestJSONEncoding < Test::Unit::TestCase
- include JSON
-
- def setup
- @utf_8 = '["© ≠ €!"]'
- @parsed = [ "© ≠ €!" ]
- @generated = '["\u00a9 \u2260 \u20ac!"]'
- 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 = @utf_8.encode('utf-16be', 'utf-8')
- @utf_16be_ascii_8bit = @utf_16be.dup.force_encoding(Encoding::ASCII_8BIT)
- @utf_16le = @utf_8.encode('utf-16le', 'utf-8')
- @utf_16le_ascii_8bit = @utf_16le.dup.force_encoding(Encoding::ASCII_8BIT)
- @utf_32be = @utf_8.encode('utf-32be', 'utf-8')
- @utf_32be_ascii_8bit = @utf_32be.dup.force_encoding(Encoding::ASCII_8BIT)
- @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
- @utf_16le, = Iconv.iconv('utf-16le', 'utf-8', @utf_8)
- @utf_16le_ascii_8bit = @utf_16le.dup
- @utf_32be, = Iconv.iconv('utf-32be', 'utf-8', @utf_8)
- @utf_32be_ascii_8bit = @utf_32be.dup
- @utf_32le, = Iconv.iconv('utf-32le', 'utf-8', @utf_8)
- @utf_32le_ascii_8bit = @utf_32le.dup
- end
- end
-
- def test_parse
- assert_equal @parsed, JSON.parse(@utf_8)
- assert_equal @parsed, JSON.parse(@utf_16be)
- assert_equal @parsed, JSON.parse(@utf_16le)
- assert_equal @parsed, JSON.parse(@utf_32be)
- assert_equal @parsed, JSON.parse(@utf_32le)
- end
-
- def test_parse_ascii_8bit
- assert_equal @parsed, JSON.parse(@utf_8_ascii_8bit)
- assert_equal @parsed, JSON.parse(@utf_16be_ascii_8bit)
- assert_equal @parsed, JSON.parse(@utf_16le_ascii_8bit)
- assert_equal @parsed, JSON.parse(@utf_32be_ascii_8bit)
- assert_equal @parsed, JSON.parse(@utf_32le_ascii_8bit)
- end
-
- def test_generate
- assert_equal @generated, JSON.generate(@parsed, :ascii_only => true)
- if defined?(::Encoding)
- assert_equal @generated, JSON.generate(@utf_16_data, :ascii_only => true)
- else
- # XXX checking of correct utf8 data is not as strict (yet?) without :ascii_only
- assert_raises(JSON::GeneratorError) { JSON.generate(@utf_16_data, :ascii_only => true) }
- end
- end
-end