scout 5.7.1 → 5.7.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +5 -0
- data/lib/scout/command/run.rb +1 -1
- data/lib/scout/server.rb +2 -1
- data/lib/scout/streamer.rb +3 -2
- data/lib/scout/streamer_daemon.rb +4 -4
- data/lib/scout/version.rb +1 -1
- data/test/scout_test.rb +7 -8
- data/vendor/httpclient/README.txt +759 -0
- data/vendor/httpclient/bin/httpclient +65 -0
- data/vendor/httpclient/lib/hexdump.rb +50 -0
- data/vendor/httpclient/lib/http-access2.rb +55 -0
- data/vendor/httpclient/lib/http-access2/cookie.rb +1 -0
- data/vendor/httpclient/lib/http-access2/http.rb +1 -0
- data/vendor/httpclient/lib/httpclient.rb +1156 -0
- data/vendor/httpclient/lib/httpclient/auth.rb +899 -0
- data/vendor/httpclient/lib/httpclient/cacert.p7s +1912 -0
- data/vendor/httpclient/lib/httpclient/connection.rb +88 -0
- data/vendor/httpclient/lib/httpclient/cookie.rb +438 -0
- data/vendor/httpclient/lib/httpclient/http.rb +1046 -0
- data/vendor/httpclient/lib/httpclient/include_client.rb +83 -0
- data/vendor/httpclient/lib/httpclient/session.rb +1025 -0
- data/vendor/httpclient/lib/httpclient/ssl_config.rb +403 -0
- data/vendor/httpclient/lib/httpclient/timeout.rb +140 -0
- data/vendor/httpclient/lib/httpclient/util.rb +178 -0
- data/vendor/httpclient/lib/httpclient/version.rb +3 -0
- data/vendor/httpclient/lib/oauthclient.rb +110 -0
- data/vendor/httpclient/sample/async.rb +8 -0
- data/vendor/httpclient/sample/auth.rb +11 -0
- data/vendor/httpclient/sample/cookie.rb +18 -0
- data/vendor/httpclient/sample/dav.rb +103 -0
- data/vendor/httpclient/sample/howto.rb +49 -0
- data/vendor/httpclient/sample/oauth_buzz.rb +57 -0
- data/vendor/httpclient/sample/oauth_friendfeed.rb +59 -0
- data/vendor/httpclient/sample/oauth_salesforce_10.rb +63 -0
- data/vendor/httpclient/sample/oauth_twitter.rb +61 -0
- data/vendor/httpclient/sample/ssl/0cert.pem +22 -0
- data/vendor/httpclient/sample/ssl/0key.pem +30 -0
- data/vendor/httpclient/sample/ssl/1000cert.pem +19 -0
- data/vendor/httpclient/sample/ssl/1000key.pem +18 -0
- data/vendor/httpclient/sample/ssl/htdocs/index.html +10 -0
- data/vendor/httpclient/sample/ssl/ssl_client.rb +22 -0
- data/vendor/httpclient/sample/ssl/webrick_httpsd.rb +29 -0
- data/vendor/httpclient/sample/stream.rb +21 -0
- data/vendor/httpclient/sample/thread.rb +27 -0
- data/vendor/httpclient/sample/wcat.rb +21 -0
- data/vendor/httpclient/test/ca-chain.cert +44 -0
- data/vendor/httpclient/test/ca.cert +23 -0
- data/vendor/httpclient/test/client.cert +19 -0
- data/vendor/httpclient/test/client.key +15 -0
- data/vendor/httpclient/test/helper.rb +129 -0
- data/vendor/httpclient/test/htdigest +1 -0
- data/vendor/httpclient/test/htpasswd +2 -0
- data/vendor/httpclient/test/runner.rb +2 -0
- data/vendor/httpclient/test/server.cert +19 -0
- data/vendor/httpclient/test/server.key +15 -0
- data/vendor/httpclient/test/sslsvr.rb +65 -0
- data/vendor/httpclient/test/subca.cert +21 -0
- data/vendor/httpclient/test/test_auth.rb +321 -0
- data/vendor/httpclient/test/test_cookie.rb +391 -0
- data/vendor/httpclient/test/test_hexdump.rb +14 -0
- data/vendor/httpclient/test/test_http-access2.rb +507 -0
- data/vendor/httpclient/test/test_httpclient.rb +1783 -0
- data/vendor/httpclient/test/test_include_client.rb +52 -0
- data/vendor/httpclient/test/test_ssl.rb +235 -0
- data/vendor/multi_json/.document +5 -0
- data/vendor/multi_json/.rspec +3 -0
- data/vendor/multi_json/.travis.yml +11 -0
- data/vendor/multi_json/.yardopts +6 -0
- data/vendor/multi_json/CHANGELOG.md +169 -0
- data/vendor/multi_json/CONTRIBUTING.md +46 -0
- data/vendor/multi_json/Gemfile +31 -0
- data/vendor/multi_json/LICENSE.md +20 -0
- data/vendor/multi_json/README.md +109 -0
- data/vendor/multi_json/Rakefile +12 -0
- data/vendor/multi_json/lib/multi_json.rb +157 -0
- data/vendor/multi_json/lib/multi_json/adapter.rb +48 -0
- data/vendor/multi_json/lib/multi_json/adapters/gson.rb +19 -0
- data/vendor/multi_json/lib/multi_json/adapters/jr_jackson.rb +19 -0
- data/vendor/multi_json/lib/multi_json/adapters/json_common.rb +25 -0
- data/vendor/multi_json/lib/multi_json/adapters/json_gem.rb +11 -0
- data/vendor/multi_json/lib/multi_json/adapters/json_pure.rb +11 -0
- data/vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb +34 -0
- data/vendor/multi_json/lib/multi_json/adapters/oj.rb +24 -0
- data/vendor/multi_json/lib/multi_json/adapters/ok_json.rb +22 -0
- data/vendor/multi_json/lib/multi_json/adapters/yajl.rb +19 -0
- data/vendor/multi_json/lib/multi_json/convertible_hash_keys.rb +43 -0
- data/vendor/multi_json/lib/multi_json/load_error.rb +11 -0
- data/vendor/multi_json/lib/multi_json/options.rb +48 -0
- data/vendor/multi_json/lib/multi_json/vendor/okjson.rb +606 -0
- data/vendor/multi_json/lib/multi_json/version.rb +20 -0
- data/vendor/multi_json/multi_json.gemspec +22 -0
- data/vendor/multi_json/spec/adapter_shared_example.rb +235 -0
- data/vendor/multi_json/spec/has_options.rb +119 -0
- data/vendor/multi_json/spec/helper.rb +35 -0
- data/vendor/multi_json/spec/json_common_shared_example.rb +30 -0
- data/vendor/multi_json/spec/multi_json_spec.rb +226 -0
- data/vendor/{signature → pusher}/.document +0 -0
- data/vendor/{json_pure/diagrams/.keep → pusher/.gemtest} +0 -0
- data/vendor/pusher/.gitignore +23 -0
- data/vendor/pusher/.travis.yml +15 -0
- data/vendor/pusher/Gemfile +2 -0
- data/vendor/{pusher-gem → pusher}/LICENSE +1 -1
- data/vendor/pusher/README.md +186 -0
- data/vendor/{pusher-gem → pusher}/Rakefile +0 -0
- data/vendor/{pusher-gem → pusher}/examples/async_message.rb +0 -0
- data/vendor/pusher/lib/pusher.rb +60 -0
- data/vendor/{pusher-gem → pusher}/lib/pusher/channel.rb +47 -54
- data/vendor/pusher/lib/pusher/client.rb +306 -0
- data/vendor/pusher/lib/pusher/request.rb +107 -0
- data/vendor/pusher/lib/pusher/resource.rb +36 -0
- data/vendor/pusher/lib/pusher/webhook.rb +110 -0
- data/vendor/{pusher-gem → pusher}/pusher.gemspec +6 -5
- data/vendor/pusher/spec/channel_spec.rb +127 -0
- data/vendor/pusher/spec/client_spec.rb +464 -0
- data/vendor/{pusher-gem → pusher}/spec/spec_helper.rb +12 -0
- data/vendor/pusher/spec/web_hook_spec.rb +117 -0
- data/vendor/signature/.travis.yml +15 -0
- data/vendor/signature/Gemfile +1 -1
- data/vendor/signature/README.md +38 -28
- data/vendor/signature/lib/signature.rb +97 -15
- data/vendor/signature/lib/signature/query_encoder.rb +47 -0
- data/vendor/signature/lib/signature/version.rb +1 -1
- data/vendor/signature/signature.gemspec +3 -2
- data/vendor/signature/spec/signature_spec.rb +164 -55
- data/vendor/signature/spec/spec_helper.rb +2 -3
- metadata +120 -145
- data/vendor/json_pure/.gitignore +0 -12
- data/vendor/json_pure/.travis.yml +0 -20
- data/vendor/json_pure/CHANGES +0 -282
- data/vendor/json_pure/COPYING +0 -58
- data/vendor/json_pure/COPYING-json-jruby +0 -57
- data/vendor/json_pure/GPL +0 -340
- data/vendor/json_pure/Gemfile +0 -11
- data/vendor/json_pure/README-json-jruby.markdown +0 -33
- data/vendor/json_pure/README.rdoc +0 -358
- data/vendor/json_pure/Rakefile +0 -412
- data/vendor/json_pure/TODO +0 -1
- data/vendor/json_pure/VERSION +0 -1
- data/vendor/json_pure/data/example.json +0 -1
- data/vendor/json_pure/data/index.html +0 -38
- data/vendor/json_pure/data/prototype.js +0 -4184
- data/vendor/json_pure/ext/json/ext/fbuffer/fbuffer.h +0 -181
- data/vendor/json_pure/ext/json/ext/generator/depend +0 -1
- data/vendor/json_pure/ext/json/ext/generator/extconf.rb +0 -14
- data/vendor/json_pure/ext/json/ext/generator/generator.c +0 -1435
- data/vendor/json_pure/ext/json/ext/generator/generator.h +0 -148
- data/vendor/json_pure/ext/json/ext/parser/depend +0 -1
- data/vendor/json_pure/ext/json/ext/parser/extconf.rb +0 -13
- data/vendor/json_pure/ext/json/ext/parser/parser.c +0 -2204
- data/vendor/json_pure/ext/json/ext/parser/parser.h +0 -77
- data/vendor/json_pure/ext/json/ext/parser/parser.rl +0 -927
- data/vendor/json_pure/install.rb +0 -23
- data/vendor/json_pure/java/src/json/ext/ByteListTranscoder.java +0 -167
- data/vendor/json_pure/java/src/json/ext/Generator.java +0 -444
- data/vendor/json_pure/java/src/json/ext/GeneratorMethods.java +0 -232
- data/vendor/json_pure/java/src/json/ext/GeneratorService.java +0 -43
- data/vendor/json_pure/java/src/json/ext/GeneratorState.java +0 -543
- data/vendor/json_pure/java/src/json/ext/OptionsReader.java +0 -114
- data/vendor/json_pure/java/src/json/ext/Parser.java +0 -2644
- data/vendor/json_pure/java/src/json/ext/Parser.rl +0 -968
- data/vendor/json_pure/java/src/json/ext/ParserService.java +0 -35
- data/vendor/json_pure/java/src/json/ext/RuntimeInfo.java +0 -121
- data/vendor/json_pure/java/src/json/ext/StringDecoder.java +0 -167
- data/vendor/json_pure/java/src/json/ext/StringEncoder.java +0 -106
- data/vendor/json_pure/java/src/json/ext/Utils.java +0 -89
- data/vendor/json_pure/json-java.gemspec +0 -23
- data/vendor/json_pure/json.gemspec +0 -37
- data/vendor/json_pure/json_pure.gemspec +0 -39
- data/vendor/json_pure/lib/json.rb +0 -62
- data/vendor/json_pure/lib/json/add/bigdecimal.rb +0 -28
- data/vendor/json_pure/lib/json/add/complex.rb +0 -22
- data/vendor/json_pure/lib/json/add/core.rb +0 -11
- data/vendor/json_pure/lib/json/add/date.rb +0 -34
- data/vendor/json_pure/lib/json/add/date_time.rb +0 -50
- data/vendor/json_pure/lib/json/add/exception.rb +0 -31
- data/vendor/json_pure/lib/json/add/ostruct.rb +0 -31
- data/vendor/json_pure/lib/json/add/range.rb +0 -29
- data/vendor/json_pure/lib/json/add/rational.rb +0 -22
- data/vendor/json_pure/lib/json/add/regexp.rb +0 -30
- data/vendor/json_pure/lib/json/add/struct.rb +0 -30
- data/vendor/json_pure/lib/json/add/symbol.rb +0 -25
- data/vendor/json_pure/lib/json/add/time.rb +0 -38
- data/vendor/json_pure/lib/json/common.rb +0 -487
- data/vendor/json_pure/lib/json/ext.rb +0 -21
- data/vendor/json_pure/lib/json/ext/.keep +0 -0
- data/vendor/json_pure/lib/json/generic_object.rb +0 -70
- data/vendor/json_pure/lib/json/pure.rb +0 -21
- data/vendor/json_pure/lib/json/pure/generator.rb +0 -522
- data/vendor/json_pure/lib/json/pure/parser.rb +0 -359
- data/vendor/json_pure/lib/json/version.rb +0 -8
- data/vendor/json_pure/tests/fixtures/fail1.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail10.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail11.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail12.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail13.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail14.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail18.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail19.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail2.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail20.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail21.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail22.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail23.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail24.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail25.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail27.json +0 -2
- data/vendor/json_pure/tests/fixtures/fail28.json +0 -2
- data/vendor/json_pure/tests/fixtures/fail3.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail4.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail5.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail6.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail7.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail8.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail9.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass1.json +0 -56
- data/vendor/json_pure/tests/fixtures/pass15.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass16.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass17.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass2.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass26.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass3.json +0 -6
- data/vendor/json_pure/tests/setup_variant.rb +0 -11
- data/vendor/json_pure/tests/test_json.rb +0 -545
- data/vendor/json_pure/tests/test_json_addition.rb +0 -196
- data/vendor/json_pure/tests/test_json_encoding.rb +0 -65
- data/vendor/json_pure/tests/test_json_fixtures.rb +0 -35
- data/vendor/json_pure/tests/test_json_generate.rb +0 -322
- data/vendor/json_pure/tests/test_json_generic_object.rb +0 -75
- data/vendor/json_pure/tests/test_json_string_matching.rb +0 -39
- data/vendor/json_pure/tests/test_json_unicode.rb +0 -72
- data/vendor/json_pure/tools/fuzz.rb +0 -139
- data/vendor/json_pure/tools/server.rb +0 -62
- data/vendor/pusher-gem/Gemfile +0 -2
- data/vendor/pusher-gem/README.md +0 -80
- data/vendor/pusher-gem/lib/pusher.rb +0 -107
- data/vendor/pusher-gem/lib/pusher/request.rb +0 -107
- data/vendor/pusher-gem/spec/channel_spec.rb +0 -274
- data/vendor/pusher-gem/spec/pusher_spec.rb +0 -87
- data/vendor/ruby-hmac/History.txt +0 -15
- data/vendor/ruby-hmac/Manifest.txt +0 -11
- data/vendor/ruby-hmac/README.md +0 -41
- data/vendor/ruby-hmac/Rakefile +0 -23
- data/vendor/ruby-hmac/lib/hmac-md5.rb +0 -11
- data/vendor/ruby-hmac/lib/hmac-rmd160.rb +0 -11
- data/vendor/ruby-hmac/lib/hmac-sha1.rb +0 -11
- data/vendor/ruby-hmac/lib/hmac-sha2.rb +0 -25
- data/vendor/ruby-hmac/lib/hmac.rb +0 -118
- data/vendor/ruby-hmac/lib/ruby_hmac.rb +0 -2
- data/vendor/ruby-hmac/ruby-hmac.gemspec +0 -33
- data/vendor/ruby-hmac/test/test_hmac.rb +0 -89
- data/vendor/signature/VERSION +0 -1
@@ -1,56 +0,0 @@
|
|
1
|
-
[
|
2
|
-
"JSON Test Pattern pass1",
|
3
|
-
{"object with 1 member":["array with 1 element"]},
|
4
|
-
{},
|
5
|
-
[],
|
6
|
-
-42,
|
7
|
-
true,
|
8
|
-
false,
|
9
|
-
null,
|
10
|
-
{
|
11
|
-
"integer": 1234567890,
|
12
|
-
"real": -9876.543210,
|
13
|
-
"e": 0.123456789e-12,
|
14
|
-
"E": 1.234567890E+34,
|
15
|
-
"": 23456789012E666,
|
16
|
-
"zero": 0,
|
17
|
-
"one": 1,
|
18
|
-
"space": " ",
|
19
|
-
"quote": "\"",
|
20
|
-
"backslash": "\\",
|
21
|
-
"controls": "\b\f\n\r\t",
|
22
|
-
"slash": "/ & \/",
|
23
|
-
"alpha": "abcdefghijklmnopqrstuvwyz",
|
24
|
-
"ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
|
25
|
-
"digit": "0123456789",
|
26
|
-
"special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
|
27
|
-
"hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
|
28
|
-
"true": true,
|
29
|
-
"false": false,
|
30
|
-
"null": null,
|
31
|
-
"array":[ ],
|
32
|
-
"object":{ },
|
33
|
-
"address": "50 St. James Street",
|
34
|
-
"url": "http://www.JSON.org/",
|
35
|
-
"comment": "// /* <!-- --",
|
36
|
-
"# -- --> */": " ",
|
37
|
-
" s p a c e d " :[1,2 , 3
|
38
|
-
|
39
|
-
,
|
40
|
-
|
41
|
-
4 , 5 , 6 ,7 ],
|
42
|
-
"compact": [1,2,3,4,5,6,7],
|
43
|
-
"jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
|
44
|
-
"quotes": "" \u0022 %22 0x22 034 "",
|
45
|
-
"\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
|
46
|
-
: "A key can be any string"
|
47
|
-
},
|
48
|
-
0.5 ,98.6
|
49
|
-
,
|
50
|
-
99.44
|
51
|
-
,
|
52
|
-
|
53
|
-
1066
|
54
|
-
|
55
|
-
|
56
|
-
,"rosebud"]
|
@@ -1 +0,0 @@
|
|
1
|
-
["Illegal backslash escape: \x15"]
|
@@ -1 +0,0 @@
|
|
1
|
-
["Illegal backslash escape: \'"]
|
@@ -1 +0,0 @@
|
|
1
|
-
["Illegal backslash escape: \017"]
|
@@ -1 +0,0 @@
|
|
1
|
-
[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
|
@@ -1 +0,0 @@
|
|
1
|
-
["tab\ character\ in\ string\ "]
|
@@ -1,545 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require File.join(File.dirname(__FILE__), 'setup_variant')
|
6
|
-
require 'stringio'
|
7
|
-
require 'tempfile'
|
8
|
-
require 'ostruct'
|
9
|
-
|
10
|
-
unless Array.method_defined?(:permutation)
|
11
|
-
begin
|
12
|
-
require 'enumerator'
|
13
|
-
require 'permutation'
|
14
|
-
class Array
|
15
|
-
def permutation
|
16
|
-
Permutation.for(self).to_enum.map { |x| x.project }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
rescue LoadError
|
20
|
-
warn "Skipping permutation tests."
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class TestJSON < Test::Unit::TestCase
|
25
|
-
include JSON
|
26
|
-
|
27
|
-
def setup
|
28
|
-
@ary = [1, "foo", 3.14, 4711.0, 2.718, nil, [1,-2,3], false, true].map do
|
29
|
-
|x| [x]
|
30
|
-
end
|
31
|
-
@ary_to_parse = ["1", '"foo"', "3.14", "4711.0", "2.718", "null",
|
32
|
-
"[1,-2,3]", "false", "true"].map do
|
33
|
-
|x| "[#{x}]"
|
34
|
-
end
|
35
|
-
@hash = {
|
36
|
-
'a' => 2,
|
37
|
-
'b' => 3.141,
|
38
|
-
'c' => 'c',
|
39
|
-
'd' => [ 1, "b", 3.14 ],
|
40
|
-
'e' => { 'foo' => 'bar' },
|
41
|
-
'g' => "\"\0\037",
|
42
|
-
'h' => 1000.0,
|
43
|
-
'i' => 0.001
|
44
|
-
}
|
45
|
-
@json = '{"a":2,"b":3.141,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},'\
|
46
|
-
'"g":"\\"\\u0000\\u001f","h":1.0E3,"i":1.0E-3}'
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_construction
|
50
|
-
parser = JSON::Parser.new('test')
|
51
|
-
assert_equal 'test', parser.source
|
52
|
-
end
|
53
|
-
|
54
|
-
def assert_equal_float(expected, is)
|
55
|
-
assert_in_delta(expected.first, is.first, 1e-2)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_parse_simple_arrays
|
59
|
-
assert_equal([], parse('[]'))
|
60
|
-
assert_equal([], parse(' [ ] '))
|
61
|
-
assert_equal([nil], parse('[null]'))
|
62
|
-
assert_equal([false], parse('[false]'))
|
63
|
-
assert_equal([true], parse('[true]'))
|
64
|
-
assert_equal([-23], parse('[-23]'))
|
65
|
-
assert_equal([23], parse('[23]'))
|
66
|
-
assert_equal([0.23], parse('[0.23]'))
|
67
|
-
assert_equal([0.0], parse('[0e0]'))
|
68
|
-
assert_raises(JSON::ParserError) { parse('[+23.2]') }
|
69
|
-
assert_raises(JSON::ParserError) { parse('[+23]') }
|
70
|
-
assert_raises(JSON::ParserError) { parse('[.23]') }
|
71
|
-
assert_raises(JSON::ParserError) { parse('[023]') }
|
72
|
-
assert_equal_float [3.141], parse('[3.141]')
|
73
|
-
assert_equal_float [-3.141], parse('[-3.141]')
|
74
|
-
assert_equal_float [3.141], parse('[3141e-3]')
|
75
|
-
assert_equal_float [3.141], parse('[3141.1e-3]')
|
76
|
-
assert_equal_float [3.141], parse('[3141E-3]')
|
77
|
-
assert_equal_float [3.141], parse('[3141.0E-3]')
|
78
|
-
assert_equal_float [-3.141], parse('[-3141.0e-3]')
|
79
|
-
assert_equal_float [-3.141], parse('[-3141e-3]')
|
80
|
-
assert_raises(ParserError) { parse('[NaN]') }
|
81
|
-
assert parse('[NaN]', :allow_nan => true).first.nan?
|
82
|
-
assert_raises(ParserError) { parse('[Infinity]') }
|
83
|
-
assert_equal [1.0/0], parse('[Infinity]', :allow_nan => true)
|
84
|
-
assert_raises(ParserError) { parse('[-Infinity]') }
|
85
|
-
assert_equal [-1.0/0], parse('[-Infinity]', :allow_nan => true)
|
86
|
-
assert_equal([""], parse('[""]'))
|
87
|
-
assert_equal(["foobar"], parse('["foobar"]'))
|
88
|
-
assert_equal([{}], parse('[{}]'))
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_parse_simple_objects
|
92
|
-
assert_equal({}, parse('{}'))
|
93
|
-
assert_equal({}, parse(' { } '))
|
94
|
-
assert_equal({ "a" => nil }, parse('{ "a" : null}'))
|
95
|
-
assert_equal({ "a" => nil }, parse('{"a":null}'))
|
96
|
-
assert_equal({ "a" => false }, parse('{ "a" : false } '))
|
97
|
-
assert_equal({ "a" => false }, parse('{"a":false}'))
|
98
|
-
assert_raises(JSON::ParserError) { parse('{false}') }
|
99
|
-
assert_equal({ "a" => true }, parse('{"a":true}'))
|
100
|
-
assert_equal({ "a" => true }, parse(' { "a" : true } '))
|
101
|
-
assert_equal({ "a" => -23 }, parse(' { "a" : -23 } '))
|
102
|
-
assert_equal({ "a" => -23 }, parse(' { "a" : -23 } '))
|
103
|
-
assert_equal({ "a" => 23 }, parse('{"a":23 } '))
|
104
|
-
assert_equal({ "a" => 23 }, parse(' { "a" : 23 } '))
|
105
|
-
assert_equal({ "a" => 0.23 }, parse(' { "a" : 0.23 } '))
|
106
|
-
assert_equal({ "a" => 0.23 }, parse(' { "a" : 0.23 } '))
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_parse_json_primitive_values
|
110
|
-
assert_raise(JSON::ParserError) { JSON.parse('') }
|
111
|
-
assert_raise(JSON::ParserError) { JSON.parse('', :quirks_mode => true) }
|
112
|
-
assert_raise(TypeError) { JSON::Parser.new(nil).parse }
|
113
|
-
assert_raise(TypeError) { JSON::Parser.new(nil, :quirks_mode => true).parse }
|
114
|
-
assert_raise(TypeError) { JSON.parse(nil) }
|
115
|
-
assert_raise(TypeError) { JSON.parse(nil, :quirks_mode => true) }
|
116
|
-
assert_raise(JSON::ParserError) { JSON.parse(' /* foo */ ') }
|
117
|
-
assert_raise(JSON::ParserError) { JSON.parse(' /* foo */ ', :quirks_mode => true) }
|
118
|
-
parser = JSON::Parser.new('null')
|
119
|
-
assert_equal false, parser.quirks_mode?
|
120
|
-
assert_raise(JSON::ParserError) { parser.parse }
|
121
|
-
assert_raise(JSON::ParserError) { JSON.parse('null') }
|
122
|
-
assert_equal nil, JSON.parse('null', :quirks_mode => true)
|
123
|
-
parser = JSON::Parser.new('null', :quirks_mode => true)
|
124
|
-
assert_equal true, parser.quirks_mode?
|
125
|
-
assert_equal nil, parser.parse
|
126
|
-
assert_raise(JSON::ParserError) { JSON.parse('false') }
|
127
|
-
assert_equal false, JSON.parse('false', :quirks_mode => true)
|
128
|
-
assert_raise(JSON::ParserError) { JSON.parse('true') }
|
129
|
-
assert_equal true, JSON.parse('true', :quirks_mode => true)
|
130
|
-
assert_raise(JSON::ParserError) { JSON.parse('23') }
|
131
|
-
assert_equal 23, JSON.parse('23', :quirks_mode => true)
|
132
|
-
assert_raise(JSON::ParserError) { JSON.parse('1') }
|
133
|
-
assert_equal 1, JSON.parse('1', :quirks_mode => true)
|
134
|
-
assert_raise(JSON::ParserError) { JSON.parse('3.141') }
|
135
|
-
assert_in_delta 3.141, JSON.parse('3.141', :quirks_mode => true), 1E-3
|
136
|
-
assert_raise(JSON::ParserError) { JSON.parse('18446744073709551616') }
|
137
|
-
assert_equal 2 ** 64, JSON.parse('18446744073709551616', :quirks_mode => true)
|
138
|
-
assert_raise(JSON::ParserError) { JSON.parse('"foo"') }
|
139
|
-
assert_equal 'foo', JSON.parse('"foo"', :quirks_mode => true)
|
140
|
-
assert_raise(JSON::ParserError) { JSON.parse('NaN', :allow_nan => true) }
|
141
|
-
assert JSON.parse('NaN', :quirks_mode => true, :allow_nan => true).nan?
|
142
|
-
assert_raise(JSON::ParserError) { JSON.parse('Infinity', :allow_nan => true) }
|
143
|
-
assert JSON.parse('Infinity', :quirks_mode => true, :allow_nan => true).infinite?
|
144
|
-
assert_raise(JSON::ParserError) { JSON.parse('-Infinity', :allow_nan => true) }
|
145
|
-
assert JSON.parse('-Infinity', :quirks_mode => true, :allow_nan => true).infinite?
|
146
|
-
assert_raise(JSON::ParserError) { JSON.parse('[ 1, ]', :quirks_mode => true) }
|
147
|
-
end
|
148
|
-
|
149
|
-
if Array.method_defined?(:permutation)
|
150
|
-
def test_parse_more_complex_arrays
|
151
|
-
a = [ nil, false, true, "foßbar", [ "n€st€d", true ], { "nested" => true, "n€ßt€ð2" => {} }]
|
152
|
-
a.permutation.each do |perm|
|
153
|
-
json = pretty_generate(perm)
|
154
|
-
assert_equal perm, parse(json)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_parse_complex_objects
|
159
|
-
a = [ nil, false, true, "foßbar", [ "n€st€d", true ], { "nested" => true, "n€ßt€ð2" => {} }]
|
160
|
-
a.permutation.each do |perm|
|
161
|
-
s = "a"
|
162
|
-
orig_obj = perm.inject({}) { |h, x| h[s.dup] = x; s = s.succ; h }
|
163
|
-
json = pretty_generate(orig_obj)
|
164
|
-
assert_equal orig_obj, parse(json)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_parse_arrays
|
170
|
-
assert_equal([1,2,3], parse('[1,2,3]'))
|
171
|
-
assert_equal([1.2,2,3], parse('[1.2,2,3]'))
|
172
|
-
assert_equal([[],[[],[]]], parse('[[],[[],[]]]'))
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_parse_values
|
176
|
-
assert_equal([""], parse('[""]'))
|
177
|
-
assert_equal(["\\"], parse('["\\\\"]'))
|
178
|
-
assert_equal(['"'], parse('["\""]'))
|
179
|
-
assert_equal(['\\"\\'], parse('["\\\\\\"\\\\"]'))
|
180
|
-
assert_equal(["\"\b\n\r\t\0\037"],
|
181
|
-
parse('["\"\b\n\r\t\u0000\u001f"]'))
|
182
|
-
for i in 0 ... @ary.size
|
183
|
-
assert_equal(@ary[i], parse(@ary_to_parse[i]))
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_parse_array
|
188
|
-
assert_equal([], parse('[]'))
|
189
|
-
assert_equal([], parse(' [ ] '))
|
190
|
-
assert_equal([1], parse('[1]'))
|
191
|
-
assert_equal([1], parse(' [ 1 ] '))
|
192
|
-
assert_equal(@ary,
|
193
|
-
parse('[[1],["foo"],[3.14],[47.11e+2],[2718.0E-3],[null],[[1,-2,3]]'\
|
194
|
-
',[false],[true]]'))
|
195
|
-
assert_equal(@ary, parse(%Q{ [ [1] , ["foo"] , [3.14] \t , [47.11e+2]\s
|
196
|
-
, [2718.0E-3 ],\r[ null] , [[1, -2, 3 ]], [false ],[ true]\n ] }))
|
197
|
-
end
|
198
|
-
|
199
|
-
class SubArray < Array
|
200
|
-
def <<(v)
|
201
|
-
@shifted = true
|
202
|
-
super
|
203
|
-
end
|
204
|
-
|
205
|
-
def shifted?
|
206
|
-
@shifted
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
class SubArray2 < Array
|
211
|
-
def to_json(*a)
|
212
|
-
{
|
213
|
-
JSON.create_id => self.class.name,
|
214
|
-
'ary' => to_a,
|
215
|
-
}.to_json(*a)
|
216
|
-
end
|
217
|
-
|
218
|
-
def self.json_create(o)
|
219
|
-
o.delete JSON.create_id
|
220
|
-
o['ary']
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
class SubArrayWrapper
|
225
|
-
def initialize
|
226
|
-
@data = []
|
227
|
-
end
|
228
|
-
|
229
|
-
attr_reader :data
|
230
|
-
|
231
|
-
def [](index)
|
232
|
-
@data[index]
|
233
|
-
end
|
234
|
-
|
235
|
-
def <<(value)
|
236
|
-
@data << value
|
237
|
-
@shifted = true
|
238
|
-
end
|
239
|
-
|
240
|
-
def shifted?
|
241
|
-
@shifted
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
def test_parse_array_custom_array_derived_class
|
246
|
-
res = parse('[1,2]', :array_class => SubArray)
|
247
|
-
assert_equal([1,2], res)
|
248
|
-
assert_equal(SubArray, res.class)
|
249
|
-
assert res.shifted?
|
250
|
-
end
|
251
|
-
|
252
|
-
def test_parse_array_custom_non_array_derived_class
|
253
|
-
res = parse('[1,2]', :array_class => SubArrayWrapper)
|
254
|
-
assert_equal([1,2], res.data)
|
255
|
-
assert_equal(SubArrayWrapper, res.class)
|
256
|
-
assert res.shifted?
|
257
|
-
end
|
258
|
-
|
259
|
-
def test_parse_object
|
260
|
-
assert_equal({}, parse('{}'))
|
261
|
-
assert_equal({}, parse(' { } '))
|
262
|
-
assert_equal({'foo'=>'bar'}, parse('{"foo":"bar"}'))
|
263
|
-
assert_equal({'foo'=>'bar'}, parse(' { "foo" : "bar" } '))
|
264
|
-
end
|
265
|
-
|
266
|
-
class SubHash < Hash
|
267
|
-
def []=(k, v)
|
268
|
-
@item_set = true
|
269
|
-
super
|
270
|
-
end
|
271
|
-
|
272
|
-
def item_set?
|
273
|
-
@item_set
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
class SubHash2 < Hash
|
278
|
-
def to_json(*a)
|
279
|
-
{
|
280
|
-
JSON.create_id => self.class.name,
|
281
|
-
}.merge(self).to_json(*a)
|
282
|
-
end
|
283
|
-
|
284
|
-
def self.json_create(o)
|
285
|
-
o.delete JSON.create_id
|
286
|
-
self[o]
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
class SubOpenStruct < OpenStruct
|
291
|
-
def [](k)
|
292
|
-
__send__(k)
|
293
|
-
end
|
294
|
-
|
295
|
-
def []=(k, v)
|
296
|
-
@item_set = true
|
297
|
-
__send__("#{k}=", v)
|
298
|
-
end
|
299
|
-
|
300
|
-
def item_set?
|
301
|
-
@item_set
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
def test_parse_object_custom_hash_derived_class
|
306
|
-
res = parse('{"foo":"bar"}', :object_class => SubHash)
|
307
|
-
assert_equal({"foo" => "bar"}, res)
|
308
|
-
assert_equal(SubHash, res.class)
|
309
|
-
assert res.item_set?
|
310
|
-
end
|
311
|
-
|
312
|
-
def test_parse_object_custom_non_hash_derived_class
|
313
|
-
res = parse('{"foo":"bar"}', :object_class => SubOpenStruct)
|
314
|
-
assert_equal "bar", res.foo
|
315
|
-
assert_equal(SubOpenStruct, res.class)
|
316
|
-
assert res.item_set?
|
317
|
-
end
|
318
|
-
|
319
|
-
def test_parse_generic_object
|
320
|
-
res = parse('{"foo":"bar", "baz":{}}', :object_class => JSON::GenericObject)
|
321
|
-
assert_equal(JSON::GenericObject, res.class)
|
322
|
-
assert_equal "bar", res.foo
|
323
|
-
assert_equal "bar", res["foo"]
|
324
|
-
assert_equal "bar", res[:foo]
|
325
|
-
assert_equal "bar", res.to_hash[:foo]
|
326
|
-
assert_equal(JSON::GenericObject, res.baz.class)
|
327
|
-
end
|
328
|
-
|
329
|
-
def test_generate_core_subclasses_with_new_to_json
|
330
|
-
obj = SubHash2["foo" => SubHash2["bar" => true]]
|
331
|
-
obj_json = JSON(obj)
|
332
|
-
obj_again = JSON.parse(obj_json, :create_additions => true)
|
333
|
-
assert_kind_of SubHash2, obj_again
|
334
|
-
assert_kind_of SubHash2, obj_again['foo']
|
335
|
-
assert obj_again['foo']['bar']
|
336
|
-
assert_equal obj, obj_again
|
337
|
-
assert_equal ["foo"], JSON(JSON(SubArray2["foo"]), :create_additions => true)
|
338
|
-
end
|
339
|
-
|
340
|
-
def test_generate_core_subclasses_with_default_to_json
|
341
|
-
assert_equal '{"foo":"bar"}', JSON(SubHash["foo" => "bar"])
|
342
|
-
assert_equal '["foo"]', JSON(SubArray["foo"])
|
343
|
-
end
|
344
|
-
|
345
|
-
def test_generate_of_core_subclasses
|
346
|
-
obj = SubHash["foo" => SubHash["bar" => true]]
|
347
|
-
obj_json = JSON(obj)
|
348
|
-
obj_again = JSON(obj_json)
|
349
|
-
assert_kind_of Hash, obj_again
|
350
|
-
assert_kind_of Hash, obj_again['foo']
|
351
|
-
assert obj_again['foo']['bar']
|
352
|
-
assert_equal obj, obj_again
|
353
|
-
end
|
354
|
-
|
355
|
-
def test_parser_reset
|
356
|
-
parser = Parser.new(@json)
|
357
|
-
assert_equal(@hash, parser.parse)
|
358
|
-
assert_equal(@hash, parser.parse)
|
359
|
-
end
|
360
|
-
|
361
|
-
def test_comments
|
362
|
-
json = <<EOT
|
363
|
-
{
|
364
|
-
"key1":"value1", // eol comment
|
365
|
-
"key2":"value2" /* multi line
|
366
|
-
* comment */,
|
367
|
-
"key3":"value3" /* multi line
|
368
|
-
// nested eol comment
|
369
|
-
* comment */
|
370
|
-
}
|
371
|
-
EOT
|
372
|
-
assert_equal(
|
373
|
-
{ "key1" => "value1", "key2" => "value2", "key3" => "value3" },
|
374
|
-
parse(json))
|
375
|
-
json = <<EOT
|
376
|
-
{
|
377
|
-
"key1":"value1" /* multi line
|
378
|
-
// nested eol comment
|
379
|
-
/* illegal nested multi line comment */
|
380
|
-
* comment */
|
381
|
-
}
|
382
|
-
EOT
|
383
|
-
assert_raises(ParserError) { parse(json) }
|
384
|
-
json = <<EOT
|
385
|
-
{
|
386
|
-
"key1":"value1" /* multi line
|
387
|
-
// nested eol comment
|
388
|
-
closed multi comment */
|
389
|
-
and again, throw an Error */
|
390
|
-
}
|
391
|
-
EOT
|
392
|
-
assert_raises(ParserError) { parse(json) }
|
393
|
-
json = <<EOT
|
394
|
-
{
|
395
|
-
"key1":"value1" /*/*/
|
396
|
-
}
|
397
|
-
EOT
|
398
|
-
assert_equal({ "key1" => "value1" }, parse(json))
|
399
|
-
end
|
400
|
-
|
401
|
-
def test_backslash
|
402
|
-
data = [ '\\.(?i:gif|jpe?g|png)$' ]
|
403
|
-
json = '["\\\\.(?i:gif|jpe?g|png)$"]'
|
404
|
-
assert_equal json, JSON.generate(data)
|
405
|
-
assert_equal data, JSON.parse(json)
|
406
|
-
#
|
407
|
-
data = [ '\\"' ]
|
408
|
-
json = '["\\\\\""]'
|
409
|
-
assert_equal json, JSON.generate(data)
|
410
|
-
assert_equal data, JSON.parse(json)
|
411
|
-
#
|
412
|
-
json = '["/"]'
|
413
|
-
data = JSON.parse(json)
|
414
|
-
assert_equal ['/'], data
|
415
|
-
assert_equal json, JSON.generate(data)
|
416
|
-
#
|
417
|
-
json = '["\""]'
|
418
|
-
data = JSON.parse(json)
|
419
|
-
assert_equal ['"'], data
|
420
|
-
assert_equal json, JSON.generate(data)
|
421
|
-
json = '["\\\'"]'
|
422
|
-
data = JSON.parse(json)
|
423
|
-
assert_equal ["'"], data
|
424
|
-
assert_equal '["\'"]', JSON.generate(data)
|
425
|
-
end
|
426
|
-
|
427
|
-
def test_wrong_inputs
|
428
|
-
assert_raises(ParserError) { JSON.parse('"foo"') }
|
429
|
-
assert_raises(ParserError) { JSON.parse('123') }
|
430
|
-
assert_raises(ParserError) { JSON.parse('[] bla') }
|
431
|
-
assert_raises(ParserError) { JSON.parse('[] 1') }
|
432
|
-
assert_raises(ParserError) { JSON.parse('[] []') }
|
433
|
-
assert_raises(ParserError) { JSON.parse('[] {}') }
|
434
|
-
assert_raises(ParserError) { JSON.parse('{} []') }
|
435
|
-
assert_raises(ParserError) { JSON.parse('{} {}') }
|
436
|
-
assert_raises(ParserError) { JSON.parse('[NULL]') }
|
437
|
-
assert_raises(ParserError) { JSON.parse('[FALSE]') }
|
438
|
-
assert_raises(ParserError) { JSON.parse('[TRUE]') }
|
439
|
-
assert_raises(ParserError) { JSON.parse('[07] ') }
|
440
|
-
assert_raises(ParserError) { JSON.parse('[0a]') }
|
441
|
-
assert_raises(ParserError) { JSON.parse('[1.]') }
|
442
|
-
assert_raises(ParserError) { JSON.parse(' ') }
|
443
|
-
end
|
444
|
-
|
445
|
-
def test_nesting
|
446
|
-
assert_raises(JSON::NestingError) { JSON.parse '[[]]', :max_nesting => 1 }
|
447
|
-
assert_raises(JSON::NestingError) { JSON.parser.new('[[]]', :max_nesting => 1).parse }
|
448
|
-
assert_equal [[]], JSON.parse('[[]]', :max_nesting => 2)
|
449
|
-
too_deep = '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'
|
450
|
-
too_deep_ary = eval too_deep
|
451
|
-
assert_raises(JSON::NestingError) { JSON.parse too_deep }
|
452
|
-
assert_raises(JSON::NestingError) { JSON.parser.new(too_deep).parse }
|
453
|
-
assert_raises(JSON::NestingError) { JSON.parse too_deep, :max_nesting => 100 }
|
454
|
-
ok = JSON.parse too_deep, :max_nesting => 101
|
455
|
-
assert_equal too_deep_ary, ok
|
456
|
-
ok = JSON.parse too_deep, :max_nesting => nil
|
457
|
-
assert_equal too_deep_ary, ok
|
458
|
-
ok = JSON.parse too_deep, :max_nesting => false
|
459
|
-
assert_equal too_deep_ary, ok
|
460
|
-
ok = JSON.parse too_deep, :max_nesting => 0
|
461
|
-
assert_equal too_deep_ary, ok
|
462
|
-
assert_raises(JSON::NestingError) { JSON.generate [[]], :max_nesting => 1 }
|
463
|
-
assert_equal '[[]]', JSON.generate([[]], :max_nesting => 2)
|
464
|
-
assert_raises(JSON::NestingError) { JSON.generate too_deep_ary }
|
465
|
-
assert_raises(JSON::NestingError) { JSON.generate too_deep_ary, :max_nesting => 100 }
|
466
|
-
ok = JSON.generate too_deep_ary, :max_nesting => 101
|
467
|
-
assert_equal too_deep, ok
|
468
|
-
ok = JSON.generate too_deep_ary, :max_nesting => nil
|
469
|
-
assert_equal too_deep, ok
|
470
|
-
ok = JSON.generate too_deep_ary, :max_nesting => false
|
471
|
-
assert_equal too_deep, ok
|
472
|
-
ok = JSON.generate too_deep_ary, :max_nesting => 0
|
473
|
-
assert_equal too_deep, ok
|
474
|
-
end
|
475
|
-
|
476
|
-
def test_symbolize_names
|
477
|
-
assert_equal({ "foo" => "bar", "baz" => "quux" },
|
478
|
-
JSON.parse('{"foo":"bar", "baz":"quux"}'))
|
479
|
-
assert_equal({ :foo => "bar", :baz => "quux" },
|
480
|
-
JSON.parse('{"foo":"bar", "baz":"quux"}', :symbolize_names => true))
|
481
|
-
end
|
482
|
-
|
483
|
-
def test_load
|
484
|
-
assert_equal @hash, JSON.load(@json)
|
485
|
-
tempfile = Tempfile.open('json')
|
486
|
-
tempfile.write @json
|
487
|
-
tempfile.rewind
|
488
|
-
assert_equal @hash, JSON.load(tempfile)
|
489
|
-
stringio = StringIO.new(@json)
|
490
|
-
stringio.rewind
|
491
|
-
assert_equal @hash, JSON.load(stringio)
|
492
|
-
assert_equal nil, JSON.load(nil)
|
493
|
-
assert_equal nil, JSON.load('')
|
494
|
-
end
|
495
|
-
|
496
|
-
def test_load_with_options
|
497
|
-
small_hash = JSON("foo" => 'bar')
|
498
|
-
symbol_hash = { :foo => 'bar' }
|
499
|
-
assert_equal symbol_hash, JSON.load(small_hash, nil, :symbolize_names => true)
|
500
|
-
end
|
501
|
-
|
502
|
-
def test_dump
|
503
|
-
too_deep = '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'
|
504
|
-
assert_equal too_deep, JSON.dump(eval(too_deep))
|
505
|
-
assert_kind_of String, Marshal.dump(eval(too_deep))
|
506
|
-
assert_raises(ArgumentError) { JSON.dump(eval(too_deep), 100) }
|
507
|
-
assert_raises(ArgumentError) { Marshal.dump(eval(too_deep), 100) }
|
508
|
-
assert_equal too_deep, JSON.dump(eval(too_deep), 101)
|
509
|
-
assert_kind_of String, Marshal.dump(eval(too_deep), 101)
|
510
|
-
output = StringIO.new
|
511
|
-
JSON.dump(eval(too_deep), output)
|
512
|
-
assert_equal too_deep, output.string
|
513
|
-
output = StringIO.new
|
514
|
-
JSON.dump(eval(too_deep), output, 101)
|
515
|
-
assert_equal too_deep, output.string
|
516
|
-
end
|
517
|
-
|
518
|
-
def test_big_integers
|
519
|
-
json1 = JSON([orig = (1 << 31) - 1])
|
520
|
-
assert_equal orig, JSON[json1][0]
|
521
|
-
json2 = JSON([orig = 1 << 31])
|
522
|
-
assert_equal orig, JSON[json2][0]
|
523
|
-
json3 = JSON([orig = (1 << 62) - 1])
|
524
|
-
assert_equal orig, JSON[json3][0]
|
525
|
-
json4 = JSON([orig = 1 << 62])
|
526
|
-
assert_equal orig, JSON[json4][0]
|
527
|
-
json5 = JSON([orig = 1 << 64])
|
528
|
-
assert_equal orig, JSON[json5][0]
|
529
|
-
end
|
530
|
-
|
531
|
-
if defined?(JSON::Ext::Parser)
|
532
|
-
def test_allocate
|
533
|
-
parser = JSON::Ext::Parser.new("{}")
|
534
|
-
assert_raise(TypeError, '[ruby-core:35079]') {parser.__send__(:initialize, "{}")}
|
535
|
-
parser = JSON::Ext::Parser.allocate
|
536
|
-
assert_raise(TypeError, '[ruby-core:35079]') {parser.source}
|
537
|
-
end
|
538
|
-
end
|
539
|
-
|
540
|
-
def test_argument_encoding
|
541
|
-
source = "{}".force_encoding("ascii-8bit")
|
542
|
-
JSON::Parser.new(source)
|
543
|
-
assert_equal Encoding::ASCII_8BIT, source.encoding
|
544
|
-
end if defined?(Encoding::ASCII_8BIT)
|
545
|
-
end
|