summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/json/generator/generator.c1
-rw-r--r--ext/json/parser/parser.rl2
-rwxr-xr-xtest/json/test_json_generate.rb33
4 files changed, 32 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 340ab62..5a652d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Jan 13 21:08:22 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
+
+ * 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@ruby-lang.org>
* test/net/http/test_http.rb: get rid of accessing DNS actually
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
index aee385e..7805cde 100644
--- a/ext/json/generator/generator.c
+++ b/ext/json/generator/generator.c
@@ -901,6 +901,7 @@ static FBuffer *cState_prepare_buffer(VALUE self)
} 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);
diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl
index 9bc5efb..e29f46d 100644
--- a/ext/json/parser/parser.rl
+++ b/ext/json/parser/parser.rl
@@ -611,7 +611,7 @@ static VALUE convert_encoding(VALUE source)
* 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
*/
diff --git a/test/json/test_json_generate.rb b/test/json/test_json_generate.rb
index 2d4e1ee..8db0b78 100755
--- a/test/json/test_json_generate.rb
+++ b/test/json/test_json_generate.rb
@@ -73,6 +73,19 @@ EOT
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
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
+ 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
+ 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