diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-08-01 03:16:30 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-08-01 03:16:30 +0000 |
commit | 11a94f2a36f1bb16e4dff6f1834e7fbe30d01eb2 (patch) | |
tree | d1e76221fdae585d92abb0b0987dff855c780390 /test | |
parent | 647d2bc3011022669ed2747d4bee6a4720bed790 (diff) | |
download | ruby-11a94f2a36f1bb16e4dff6f1834e7fbe30d01eb2.tar.gz |
* 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
Diffstat (limited to 'test')
-rw-r--r-- | test/json/json_parser_test.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb index c1c2779b96..40ad500cb6 100644 --- a/test/json/json_parser_test.rb +++ b/test/json/json_parser_test.rb @@ -40,6 +40,18 @@ class JSONParserTest < Test::Unit::TestCase assert_equal({ 'a' => 'b' }, parser.parse) 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 assert_equal([], parse('[]')) assert_equal([], parse(' [ ] ')) @@ -277,7 +289,6 @@ EOT assert_equal data, parse(json) end - class SubArray < Array def <<(v) @shifted = true @@ -438,6 +449,13 @@ EOT assert_equal obj, obj_again end + def test_parsing_frozen_ascii8bit_string + assert_equal( + { 'foo' => 'bar' }, + JSON('{ "foo": "bar" }'.force_encoding(Encoding::ASCII_8BIT).freeze) + ) + end + private def assert_equal_float(expected, actual, delta = 1e-2) |