* ext/json/*, test/json/json_parser_test.rb: Update json-2.0.2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
647d2bc301
commit
11a94f2a36
@ -1,3 +1,7 @@
|
|||||||
|
Mon Aug 1 12:16:19 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/json/*, test/json/json_parser_test.rb: Update json-2.0.2.
|
||||||
|
|
||||||
Sun Jul 31 16:17:23 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Jul 31 16:17:23 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/win32/resolv/resolv.c (get_dns_server_list): [Win32] get DNS
|
* ext/win32/resolv/resolv.c (get_dns_server_list): [Win32] get DNS
|
||||||
|
@ -951,6 +951,7 @@ static VALUE cState_generate(VALUE self, VALUE obj)
|
|||||||
{
|
{
|
||||||
VALUE result = cState_partial_generate(self, obj);
|
VALUE result = cState_partial_generate(self, obj);
|
||||||
GET_STATE(self);
|
GET_STATE(self);
|
||||||
|
(void)state;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: false
|
# frozen_string_literal: false
|
||||||
module JSON
|
module JSON
|
||||||
# JSON version
|
# JSON version
|
||||||
VERSION = '2.0.1'
|
VERSION = '2.0.2'
|
||||||
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
|
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
|
||||||
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
||||||
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
||||||
|
@ -1670,6 +1670,9 @@ static VALUE convert_encoding(VALUE source)
|
|||||||
#ifdef HAVE_RUBY_ENCODING_H
|
#ifdef HAVE_RUBY_ENCODING_H
|
||||||
rb_encoding *enc = rb_enc_get(source);
|
rb_encoding *enc = rb_enc_get(source);
|
||||||
if (enc == rb_ascii8bit_encoding()) {
|
if (enc == rb_ascii8bit_encoding()) {
|
||||||
|
if (OBJ_FROZEN(source)) {
|
||||||
|
source = rb_str_dup(source);
|
||||||
|
}
|
||||||
FORCE_UTF8(source);
|
FORCE_UTF8(source);
|
||||||
} else {
|
} else {
|
||||||
source = rb_str_conv_enc(source, NULL, rb_utf8_encoding());
|
source = rb_str_conv_enc(source, NULL, rb_utf8_encoding());
|
||||||
@ -1805,7 +1808,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#line 1809 "parser.c"
|
#line 1812 "parser.c"
|
||||||
enum {JSON_start = 1};
|
enum {JSON_start = 1};
|
||||||
enum {JSON_first_final = 10};
|
enum {JSON_first_final = 10};
|
||||||
enum {JSON_error = 0};
|
enum {JSON_error = 0};
|
||||||
@ -1813,7 +1816,7 @@ enum {JSON_error = 0};
|
|||||||
enum {JSON_en_main = 1};
|
enum {JSON_en_main = 1};
|
||||||
|
|
||||||
|
|
||||||
#line 717 "parser.rl"
|
#line 720 "parser.rl"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1830,16 +1833,16 @@ static VALUE cParser_parse(VALUE self)
|
|||||||
GET_PARSER;
|
GET_PARSER;
|
||||||
|
|
||||||
|
|
||||||
#line 1834 "parser.c"
|
#line 1837 "parser.c"
|
||||||
{
|
{
|
||||||
cs = JSON_start;
|
cs = JSON_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 733 "parser.rl"
|
#line 736 "parser.rl"
|
||||||
p = json->source;
|
p = json->source;
|
||||||
pe = p + json->len;
|
pe = p + json->len;
|
||||||
|
|
||||||
#line 1843 "parser.c"
|
#line 1846 "parser.c"
|
||||||
{
|
{
|
||||||
if ( p == pe )
|
if ( p == pe )
|
||||||
goto _test_eof;
|
goto _test_eof;
|
||||||
@ -1873,7 +1876,7 @@ st0:
|
|||||||
cs = 0;
|
cs = 0;
|
||||||
goto _out;
|
goto _out;
|
||||||
tr2:
|
tr2:
|
||||||
#line 709 "parser.rl"
|
#line 712 "parser.rl"
|
||||||
{
|
{
|
||||||
char *np = JSON_parse_value(json, p, pe, &result, 0);
|
char *np = JSON_parse_value(json, p, pe, &result, 0);
|
||||||
if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
|
if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
|
||||||
@ -1883,7 +1886,7 @@ st10:
|
|||||||
if ( ++p == pe )
|
if ( ++p == pe )
|
||||||
goto _test_eof10;
|
goto _test_eof10;
|
||||||
case 10:
|
case 10:
|
||||||
#line 1887 "parser.c"
|
#line 1890 "parser.c"
|
||||||
switch( (*p) ) {
|
switch( (*p) ) {
|
||||||
case 13: goto st10;
|
case 13: goto st10;
|
||||||
case 32: goto st10;
|
case 32: goto st10;
|
||||||
@ -1972,7 +1975,7 @@ case 9:
|
|||||||
_out: {}
|
_out: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 736 "parser.rl"
|
#line 739 "parser.rl"
|
||||||
|
|
||||||
if (cs >= JSON_first_final && p == pe) {
|
if (cs >= JSON_first_final && p == pe) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -565,6 +565,9 @@ static VALUE convert_encoding(VALUE source)
|
|||||||
#ifdef HAVE_RUBY_ENCODING_H
|
#ifdef HAVE_RUBY_ENCODING_H
|
||||||
rb_encoding *enc = rb_enc_get(source);
|
rb_encoding *enc = rb_enc_get(source);
|
||||||
if (enc == rb_ascii8bit_encoding()) {
|
if (enc == rb_ascii8bit_encoding()) {
|
||||||
|
if (OBJ_FROZEN(source)) {
|
||||||
|
source = rb_str_dup(source);
|
||||||
|
}
|
||||||
FORCE_UTF8(source);
|
FORCE_UTF8(source);
|
||||||
} else {
|
} else {
|
||||||
source = rb_str_conv_enc(source, NULL, rb_utf8_encoding());
|
source = rb_str_conv_enc(source, NULL, rb_utf8_encoding());
|
||||||
|
@ -40,6 +40,18 @@ class JSONParserTest < Test::Unit::TestCase
|
|||||||
assert_equal({ 'a' => 'b' }, parser.parse)
|
assert_equal({ 'a' => 'b' }, parser.parse)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_parse_values
|
||||||
|
assert_equal(nil, parse('null'))
|
||||||
|
assert_equal(false, parse('false'))
|
||||||
|
assert_equal(true, parse('true'))
|
||||||
|
assert_equal(-23, parse('-23'))
|
||||||
|
assert_equal(23, parse('23'))
|
||||||
|
assert_in_delta(0.23, parse('0.23'), 1e-2)
|
||||||
|
assert_in_delta(0.0, parse('0e0'), 1e-2)
|
||||||
|
assert_equal("", parse('""'))
|
||||||
|
assert_equal("foobar", parse('"foobar"'))
|
||||||
|
end
|
||||||
|
|
||||||
def test_parse_simple_arrays
|
def test_parse_simple_arrays
|
||||||
assert_equal([], parse('[]'))
|
assert_equal([], parse('[]'))
|
||||||
assert_equal([], parse(' [ ] '))
|
assert_equal([], parse(' [ ] '))
|
||||||
@ -277,7 +289,6 @@ EOT
|
|||||||
assert_equal data, parse(json)
|
assert_equal data, parse(json)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
class SubArray < Array
|
class SubArray < Array
|
||||||
def <<(v)
|
def <<(v)
|
||||||
@shifted = true
|
@shifted = true
|
||||||
@ -438,6 +449,13 @@ EOT
|
|||||||
assert_equal obj, obj_again
|
assert_equal obj, obj_again
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_parsing_frozen_ascii8bit_string
|
||||||
|
assert_equal(
|
||||||
|
{ 'foo' => 'bar' },
|
||||||
|
JSON('{ "foo": "bar" }'.force_encoding(Encoding::ASCII_8BIT).freeze)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def assert_equal_float(expected, actual, delta = 1e-2)
|
def assert_equal_float(expected, actual, delta = 1e-2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user