[前][次][番号順一覧][スレッド一覧]

ruby-changes:37155

From: hsbt <ko1@a...>
Date: Tue, 13 Jan 2015 21:08:35 +0900 (JST)
Subject: [ruby-changes:37155] hsbt:r49236 (trunk): * ext/json, test/json: merge JSON HEAD(259dee6)

hsbt	2015-01-13 21:08:28 +0900 (Tue, 13 Jan 2015)

  New Revision: 49236

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49236

  Log:
    * ext/json, test/json: merge JSON HEAD(259dee6)
      separate imprementation of Typed_Data macro.
      https://github.com/flori/json/compare/v1.8.1...v1.8.2

  Modified files:
    trunk/ChangeLog
    trunk/ext/json/generator/generator.c
    trunk/ext/json/parser/parser.rl
    trunk/test/json/test_json_generate.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49235)
+++ ChangeLog	(revision 49236)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jan 13 21:08:22 2015  SHIBATA Hiroshi  <shibata.hiroshi@g...>
+
+	* ext/json, test/json: merge JSON HEAD(259dee6)
+	  separate imprementation of Typed_Data macro.
+	  https://github.com/flori/json/compare/v1.8.1...v1.8.2
+
 Tue Jan 13 14:16:35 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* test/net/http/test_http.rb: get rid of accessing DNS actually
Index: ext/json/generator/generator.c
===================================================================
--- ext/json/generator/generator.c	(revision 49235)
+++ ext/json/generator/generator.c	(revision 49236)
@@ -901,6 +901,7 @@ static FBuffer *cState_prepare_buffer(VA https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.c#L901
     } else {
         state->object_delim2 = fbuffer_alloc(16);
     }
+    if (state->space_before) fbuffer_append(state->object_delim2, state->space_before, state->space_before_len);
     fbuffer_append_char(state->object_delim2, ':');
     if (state->space) fbuffer_append(state->object_delim2, state->space, state->space_len);
 
Index: ext/json/parser/parser.rl
===================================================================
--- ext/json/parser/parser.rl	(revision 49235)
+++ ext/json/parser/parser.rl	(revision 49236)
@@ -611,7 +611,7 @@ static VALUE convert_encoding(VALUE sour https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L611
  *   the default.
  * * *create_additions*: If set to false, the Parser doesn't create
  *   additions even if a matching class and create_id was found. This option
- *   defaults to true.
+ *   defaults to false.
  * * *object_class*: Defaults to Hash
  * * *array_class*: Defaults to Array
  */
Index: test/json/test_json_generate.rb
===================================================================
--- test/json/test_json_generate.rb	(revision 49235)
+++ test/json/test_json_generate.rb	(revision 49236)
@@ -73,6 +73,19 @@ EOT https://github.com/ruby/ruby/blob/trunk/test/json/test_json_generate.rb#L73
     assert_equal '666', pretty_generate(666, :quirks_mode => true)
   end
 
+  def test_generate_custom
+    state = State.new(:space_before => " ", :space => "   ", :indent => "<i>", :object_nl => "\n", :array_nl => "<a_nl>")
+    json = generate({1=>{2=>3,4=>[5,6]}}, state)
+    assert_equal(<<'EOT'.chomp, json)
+{
+<i>"1" :   {
+<i><i>"2" :   3,
+<i><i>"4" :   [<a_nl><i><i><i>5,<a_nl><i><i><i>6<a_nl><i><i>]
+<i>}
+}
+EOT
+  end
+
   def test_fast_generate
     json = fast_generate(@hash)
     assert_equal(JSON.parse(@json2), JSON.parse(json))
@@ -215,16 +228,18 @@ EOT https://github.com/ruby/ruby/blob/trunk/test/json/test_json_generate.rb#L228
   end
 
   def test_gc
-    assert_in_out_err(%w[-rjson --disable-gems], <<-EOS, [], [])
-      bignum_too_long_to_embed_as_string = 1234567890123456789012345
-      expect = bignum_too_long_to_embed_as_string.to_s
-      GC.stress = true
-
-      10.times do |i|
-        tmp = bignum_too_long_to_embed_as_string.to_json
-        raise "'\#{expect}' is expected, but '\#{tmp}'" unless tmp == expect
-      end
-    EOS
+    if respond_to?(:assert_in_out_err)
+      assert_in_out_err(%w[-rjson --disable-gems], <<-EOS, [], [])
+        bignum_too_long_to_embed_as_string = 1234567890123456789012345
+        expect = bignum_too_long_to_embed_as_string.to_s
+        GC.stress = true
+
+        10.times do |i|
+          tmp = bignum_too_long_to_embed_as_string.to_json
+          raise "'\#{expect}' is expected, but '\#{tmp}'" unless tmp == expect
+        end
+      EOS
+    end
   end if GC.respond_to?(:stress=)
 
   def test_configure_using_configure_and_merge

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]