From b60d64b001c8819e6626b00efbeae96560368a08 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 6 Jun 2007 22:38:42 +0000 Subject: * lib/json/common.rb: Ponder offering parse\! method. * lib/json/editor.rb: be a bit more robust while loading data. * ext/json/ext/{generator,parser}/extconf.rb: add a have_header directive for st.h * test/json: fix some tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/json/test_json_unicode.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test/json/test_json_unicode.rb') diff --git a/test/json/test_json_unicode.rb b/test/json/test_json_unicode.rb index a23e50edf9..a91f4b576c 100755 --- a/test/json/test_json_unicode.rb +++ b/test/json/test_json_unicode.rb @@ -39,15 +39,17 @@ class TC_JSONUnicode < Test::Unit::TestCase def test_chars (0..0x7f).each do |i| - c = ('%c' % i)[0] # c is a character object json = '["\u%04x"]' % i - assert_equal c, JSON.parse(json).first - if c == ?\b + if RUBY_VERSION >= "1.9." + i = i.chr + end + assert_equal i, JSON.parse(json).first[0] + if i == ?\b generated = JSON.generate(["" << i]) assert '["\b"]' == generated || '["\10"]' == generated - elsif [?\n, ?\r, ?\t, ?\f].include?(c) + elsif [?\n, ?\r, ?\t, ?\f].include?(i) assert_equal '[' << ('' << i).dump << ']', JSON.generate(["" << i]) - elsif i < 0x20 + elsif i.chr < 0x20.chr assert_equal json, JSON.generate(["" << i]) end end -- cgit v1.2.3