oj 3.11.5 → 3.16.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1421 -0
- data/README.md +19 -5
- data/RELEASE_NOTES.md +61 -0
- data/ext/oj/buf.h +20 -6
- data/ext/oj/cache.c +329 -0
- data/ext/oj/cache.h +22 -0
- data/ext/oj/cache8.c +10 -9
- data/ext/oj/circarray.c +8 -6
- data/ext/oj/circarray.h +2 -2
- data/ext/oj/code.c +19 -33
- data/ext/oj/code.h +2 -2
- data/ext/oj/compat.c +27 -77
- data/ext/oj/custom.c +86 -179
- data/ext/oj/debug.c +126 -0
- data/ext/oj/dump.c +256 -249
- data/ext/oj/dump.h +26 -12
- data/ext/oj/dump_compat.c +565 -642
- data/ext/oj/dump_leaf.c +17 -63
- data/ext/oj/dump_object.c +65 -187
- data/ext/oj/dump_strict.c +27 -51
- data/ext/oj/encoder.c +43 -0
- data/ext/oj/err.c +2 -13
- data/ext/oj/err.h +24 -8
- data/ext/oj/extconf.rb +21 -6
- data/ext/oj/fast.c +149 -149
- data/ext/oj/intern.c +313 -0
- data/ext/oj/intern.h +22 -0
- data/ext/oj/mem.c +318 -0
- data/ext/oj/mem.h +53 -0
- data/ext/oj/mimic_json.c +121 -106
- data/ext/oj/object.c +85 -162
- data/ext/oj/odd.c +89 -67
- data/ext/oj/odd.h +15 -15
- data/ext/oj/oj.c +542 -411
- data/ext/oj/oj.h +99 -73
- data/ext/oj/parse.c +175 -187
- data/ext/oj/parse.h +26 -24
- data/ext/oj/parser.c +1600 -0
- data/ext/oj/parser.h +101 -0
- data/ext/oj/rails.c +112 -159
- data/ext/oj/rails.h +1 -1
- data/ext/oj/reader.c +11 -14
- data/ext/oj/reader.h +4 -2
- data/ext/oj/resolve.c +5 -24
- data/ext/oj/rxclass.c +7 -6
- data/ext/oj/rxclass.h +1 -1
- data/ext/oj/saj.c +22 -33
- data/ext/oj/saj2.c +584 -0
- data/ext/oj/saj2.h +23 -0
- data/ext/oj/scp.c +5 -28
- data/ext/oj/sparse.c +28 -72
- data/ext/oj/stream_writer.c +50 -40
- data/ext/oj/strict.c +56 -61
- data/ext/oj/string_writer.c +72 -39
- data/ext/oj/trace.h +31 -4
- data/ext/oj/usual.c +1218 -0
- data/ext/oj/usual.h +69 -0
- data/ext/oj/util.h +1 -1
- data/ext/oj/val_stack.c +14 -3
- data/ext/oj/val_stack.h +8 -7
- data/ext/oj/validate.c +46 -0
- data/ext/oj/wab.c +63 -88
- data/lib/oj/active_support_helper.rb +1 -3
- data/lib/oj/bag.rb +7 -1
- data/lib/oj/easy_hash.rb +4 -5
- data/lib/oj/error.rb +1 -2
- data/lib/oj/json.rb +162 -150
- data/lib/oj/mimic.rb +9 -7
- data/lib/oj/saj.rb +20 -6
- data/lib/oj/schandler.rb +5 -4
- data/lib/oj/state.rb +12 -8
- data/lib/oj/version.rb +1 -2
- data/lib/oj.rb +2 -0
- data/pages/Compatibility.md +1 -1
- data/pages/InstallOptions.md +20 -0
- data/pages/JsonGem.md +15 -0
- data/pages/Modes.md +8 -3
- data/pages/Options.md +43 -5
- data/pages/Parser.md +309 -0
- data/pages/Rails.md +14 -2
- data/test/_test_active.rb +8 -9
- data/test/_test_active_mimic.rb +7 -8
- data/test/_test_mimic_rails.rb +17 -20
- data/test/activerecord/result_test.rb +5 -6
- data/test/activesupport6/encoding_test.rb +63 -28
- data/test/{activesupport5 → activesupport7}/abstract_unit.rb +16 -12
- data/test/{activesupport5 → activesupport7}/decoding_test.rb +2 -10
- data/test/{activesupport5 → activesupport7}/encoding_test.rb +86 -50
- data/test/{activesupport5 → activesupport7}/encoding_test_cases.rb +6 -0
- data/test/{activesupport5 → activesupport7}/time_zone_test_helpers.rb +8 -0
- data/test/files.rb +15 -15
- data/test/foo.rb +16 -45
- data/test/helper.rb +11 -8
- data/test/isolated/shared.rb +3 -2
- data/test/json_gem/json_addition_test.rb +2 -2
- data/test/json_gem/json_common_interface_test.rb +8 -6
- data/test/json_gem/json_encoding_test.rb +0 -0
- data/test/json_gem/json_ext_parser_test.rb +1 -0
- data/test/json_gem/json_fixtures_test.rb +3 -2
- data/test/json_gem/json_generator_test.rb +56 -38
- data/test/json_gem/json_generic_object_test.rb +11 -11
- data/test/json_gem/json_parser_test.rb +54 -47
- data/test/json_gem/json_string_matching_test.rb +9 -9
- data/test/json_gem/test_helper.rb +7 -3
- data/test/mem.rb +34 -0
- data/test/perf.rb +22 -27
- data/test/perf_compat.rb +31 -33
- data/test/perf_dump.rb +50 -0
- data/test/perf_fast.rb +80 -82
- data/test/perf_file.rb +27 -29
- data/test/perf_object.rb +65 -69
- data/test/perf_once.rb +59 -0
- data/test/perf_parser.rb +183 -0
- data/test/perf_saj.rb +46 -54
- data/test/perf_scp.rb +58 -69
- data/test/perf_simple.rb +41 -39
- data/test/perf_strict.rb +74 -82
- data/test/perf_wab.rb +67 -69
- data/test/prec.rb +5 -5
- data/test/sample/change.rb +0 -1
- data/test/sample/dir.rb +0 -1
- data/test/sample/doc.rb +0 -1
- data/test/sample/file.rb +0 -1
- data/test/sample/group.rb +0 -1
- data/test/sample/hasprops.rb +0 -1
- data/test/sample/layer.rb +0 -1
- data/test/sample/rect.rb +0 -1
- data/test/sample/shape.rb +0 -1
- data/test/sample/text.rb +0 -1
- data/test/sample.rb +16 -16
- data/test/sample_json.rb +8 -8
- data/test/test_compat.rb +95 -43
- data/test/test_custom.rb +73 -51
- data/test/test_debian.rb +7 -10
- data/test/test_fast.rb +135 -79
- data/test/test_file.rb +41 -30
- data/test/test_gc.rb +16 -5
- data/test/test_generate.rb +5 -5
- data/test/test_hash.rb +5 -5
- data/test/test_integer_range.rb +9 -9
- data/test/test_null.rb +20 -20
- data/test/test_object.rb +99 -96
- data/test/test_parser.rb +11 -0
- data/test/test_parser_debug.rb +27 -0
- data/test/test_parser_saj.rb +337 -0
- data/test/test_parser_usual.rb +251 -0
- data/test/test_rails.rb +2 -2
- data/test/test_saj.rb +10 -8
- data/test/test_scp.rb +37 -39
- data/test/test_strict.rb +40 -32
- data/test/test_various.rb +165 -84
- data/test/test_wab.rb +48 -44
- data/test/test_writer.rb +47 -47
- data/test/tests.rb +13 -5
- data/test/tests_mimic.rb +12 -3
- data/test/tests_mimic_addition.rb +12 -3
- metadata +74 -128
- data/ext/oj/hash.c +0 -131
- data/ext/oj/hash.h +0 -19
- data/ext/oj/hash_test.c +0 -491
- data/test/activesupport4/decoding_test.rb +0 -108
- data/test/activesupport4/encoding_test.rb +0 -531
- data/test/activesupport4/test_helper.rb +0 -41
- data/test/activesupport5/test_helper.rb +0 -72
- data/test/bar.rb +0 -35
- data/test/baz.rb +0 -16
- data/test/zoo.rb +0 -13
data/test/test_scp.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
4
|
+
$LOAD_PATH << __dir__
|
5
5
|
|
6
6
|
require 'helper'
|
7
7
|
require 'socket'
|
@@ -23,23 +23,22 @@ $json = %{{
|
|
23
23
|
}}
|
24
24
|
|
25
25
|
class NoHandler < Oj::ScHandler
|
26
|
-
def initialize()
|
27
|
-
end
|
28
26
|
end
|
29
27
|
|
30
28
|
class AllHandler < Oj::ScHandler
|
31
29
|
attr_accessor :calls
|
32
30
|
|
33
|
-
def initialize
|
31
|
+
def initialize
|
32
|
+
super
|
34
33
|
@calls = []
|
35
34
|
end
|
36
35
|
|
37
|
-
def hash_start
|
36
|
+
def hash_start
|
38
37
|
@calls << [:hash_start]
|
39
38
|
{}
|
40
39
|
end
|
41
40
|
|
42
|
-
def hash_end
|
41
|
+
def hash_end
|
43
42
|
@calls << [:hash_end]
|
44
43
|
end
|
45
44
|
|
@@ -47,15 +46,16 @@ class AllHandler < Oj::ScHandler
|
|
47
46
|
@calls << [:hash_key, key]
|
48
47
|
return 'too' if 'two' == key
|
49
48
|
return :symbol if 'symbol' == key
|
49
|
+
|
50
50
|
key
|
51
51
|
end
|
52
52
|
|
53
|
-
def array_start
|
53
|
+
def array_start
|
54
54
|
@calls << [:array_start]
|
55
55
|
[]
|
56
56
|
end
|
57
57
|
|
58
|
-
def array_end
|
58
|
+
def array_end
|
59
59
|
@calls << [:array_end]
|
60
60
|
end
|
61
61
|
|
@@ -63,11 +63,11 @@ class AllHandler < Oj::ScHandler
|
|
63
63
|
@calls << [:add_value, value]
|
64
64
|
end
|
65
65
|
|
66
|
-
def hash_set(
|
66
|
+
def hash_set(_h, key, value)
|
67
67
|
@calls << [:hash_set, key, value]
|
68
68
|
end
|
69
69
|
|
70
|
-
def array_append(
|
70
|
+
def array_append(_a, value)
|
71
71
|
@calls << [:array_append, value]
|
72
72
|
end
|
73
73
|
|
@@ -75,18 +75,19 @@ end # AllHandler
|
|
75
75
|
|
76
76
|
class Closer < AllHandler
|
77
77
|
attr_accessor :io
|
78
|
+
|
78
79
|
def initialize(io)
|
79
80
|
super()
|
80
81
|
@io = io
|
81
82
|
end
|
82
83
|
|
83
|
-
def hash_start
|
84
|
+
def hash_start
|
84
85
|
@calls << [:hash_start]
|
85
86
|
@io.close
|
86
87
|
{}
|
87
88
|
end
|
88
89
|
|
89
|
-
def hash_set(
|
90
|
+
def hash_set(_h, key, value)
|
90
91
|
@calls << [:hash_set, key, value]
|
91
92
|
@io.close
|
92
93
|
end
|
@@ -135,14 +136,14 @@ class ScpTest < Minitest::Test
|
|
135
136
|
handler = AllHandler.new()
|
136
137
|
json = %{12345}
|
137
138
|
Oj.sc_parse(handler, json)
|
138
|
-
assert_equal([[:add_value,
|
139
|
+
assert_equal([[:add_value, 12_345]], handler.calls)
|
139
140
|
end
|
140
141
|
|
141
142
|
def test_float
|
142
143
|
handler = AllHandler.new()
|
143
144
|
json = %{12345.6789}
|
144
145
|
Oj.sc_parse(handler, json)
|
145
|
-
assert_equal([[:add_value,
|
146
|
+
assert_equal([[:add_value, 12_345.6789]], handler.calls)
|
146
147
|
end
|
147
148
|
|
148
149
|
def test_float_exp
|
@@ -151,7 +152,7 @@ class ScpTest < Minitest::Test
|
|
151
152
|
Oj.sc_parse(handler, json)
|
152
153
|
assert_equal(1, handler.calls.size)
|
153
154
|
assert_equal(:add_value, handler.calls[0][0])
|
154
|
-
assert_equal((
|
155
|
+
assert_equal((12_345.6789e7 * 10_000).to_i, (handler.calls[0][1] * 10_000).to_i)
|
155
156
|
end
|
156
157
|
|
157
158
|
def test_array_empty
|
@@ -230,9 +231,9 @@ class ScpTest < Minitest::Test
|
|
230
231
|
[:array_start],
|
231
232
|
[:hash_start],
|
232
233
|
[:hash_key, 'num'],
|
233
|
-
[:hash_set,
|
234
|
+
[:hash_set, 'num', 3],
|
234
235
|
[:hash_key, 'string'],
|
235
|
-
[:hash_set,
|
236
|
+
[:hash_set, 'string', 'message'],
|
236
237
|
[:hash_key, 'hash'],
|
237
238
|
[:hash_start],
|
238
239
|
[:hash_key, 'h2'],
|
@@ -243,17 +244,17 @@ class ScpTest < Minitest::Test
|
|
243
244
|
[:array_append, 2],
|
244
245
|
[:array_append, 3],
|
245
246
|
[:array_end],
|
246
|
-
[:hash_set,
|
247
|
+
[:hash_set, 'a', []],
|
247
248
|
[:hash_end],
|
248
|
-
[:hash_set,
|
249
|
+
[:hash_set, 'h2', {}],
|
249
250
|
[:hash_end],
|
250
|
-
[:hash_set,
|
251
|
+
[:hash_set, 'hash', {}],
|
251
252
|
[:hash_end],
|
252
253
|
[:array_append, {}],
|
253
254
|
[:array_end],
|
254
|
-
[:hash_set,
|
255
|
+
[:hash_set, 'array', []],
|
255
256
|
[:hash_key, 'boolean'],
|
256
|
-
[:hash_set,
|
257
|
+
[:hash_set, 'boolean', true],
|
257
258
|
[:hash_end],
|
258
259
|
[:add_value, {}]], handler.calls)
|
259
260
|
end
|
@@ -320,8 +321,7 @@ class ScpTest < Minitest::Test
|
|
320
321
|
end
|
321
322
|
|
322
323
|
def test_pipe
|
323
|
-
|
324
|
-
return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
|
324
|
+
skip 'needs fork' unless Process.respond_to?(:fork)
|
325
325
|
|
326
326
|
handler = AllHandler.new()
|
327
327
|
json = %{{"one":true,"two":false}}
|
@@ -347,18 +347,15 @@ class ScpTest < Minitest::Test
|
|
347
347
|
end
|
348
348
|
|
349
349
|
def test_bad_bignum
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
Oj.sc_parse(handler, json)
|
355
|
-
end
|
350
|
+
handler = AllHandler.new()
|
351
|
+
json = %|{"big":-e123456789}|
|
352
|
+
assert_raises Exception do # Can be either Oj::ParseError or ArgumentError depending on Ruby version
|
353
|
+
Oj.sc_parse(handler, json)
|
356
354
|
end
|
357
355
|
end
|
358
356
|
|
359
357
|
def test_pipe_close
|
360
|
-
|
361
|
-
return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
|
358
|
+
skip 'needs fork' unless Process.respond_to?(:fork)
|
362
359
|
|
363
360
|
json = %{{"one":true,"two":false}}
|
364
361
|
IO.pipe do |read_io, write_io|
|
@@ -372,7 +369,7 @@ class ScpTest < Minitest::Test
|
|
372
369
|
rescue Exception => e
|
373
370
|
err = e.class.to_s
|
374
371
|
end
|
375
|
-
assert_equal(
|
372
|
+
assert_equal('IOError', err)
|
376
373
|
assert_equal([[:hash_start],
|
377
374
|
[:hash_key, 'one'],
|
378
375
|
[:hash_set, 'one', true]], handler.calls)
|
@@ -381,8 +378,8 @@ class ScpTest < Minitest::Test
|
|
381
378
|
write_io.write json[0..11]
|
382
379
|
sleep(0.1)
|
383
380
|
begin
|
384
|
-
write_io.write json[12
|
385
|
-
rescue Exception
|
381
|
+
write_io.write json[12..]
|
382
|
+
rescue Exception
|
386
383
|
# ignore, should fail to write
|
387
384
|
end
|
388
385
|
write_io.close
|
@@ -399,15 +396,16 @@ class ScpTest < Minitest::Test
|
|
399
396
|
# Not able to open a socket to run the test. Might be Travis.
|
400
397
|
return
|
401
398
|
end
|
402
|
-
Thread.start(json) do |
|
399
|
+
Thread.start(json) do |_j|
|
403
400
|
c = server.accept()
|
404
401
|
c.puts json[0..11]
|
405
402
|
10.times {
|
406
403
|
break if c.closed?
|
404
|
+
|
407
405
|
sleep(0.1)
|
408
406
|
}
|
409
407
|
unless c.closed?
|
410
|
-
c.puts json[12
|
408
|
+
c.puts json[12..]
|
411
409
|
c.close
|
412
410
|
end
|
413
411
|
end
|
@@ -424,7 +422,7 @@ class ScpTest < Minitest::Test
|
|
424
422
|
rescue Exception => e
|
425
423
|
err = e.class.to_s
|
426
424
|
end
|
427
|
-
assert_equal(
|
425
|
+
assert_equal('IOError', err)
|
428
426
|
assert_equal([[:hash_start],
|
429
427
|
[:hash_key, 'one'],
|
430
428
|
[:hash_set, 'one', true]], handler.calls)
|
data/test/test_strict.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
$LOAD_PATH << __dir__
|
5
|
+
@oj_dir = File.dirname(File.expand_path(__dir__))
|
6
6
|
%w(lib ext).each do |dir|
|
7
|
-
|
7
|
+
$LOAD_PATH << File.join(@oj_dir, dir)
|
8
8
|
end
|
9
9
|
|
10
10
|
require 'minitest'
|
@@ -52,16 +52,16 @@ class StrictJuice < Minitest::Test
|
|
52
52
|
|
53
53
|
def test_fixnum
|
54
54
|
dump_and_load(0, false)
|
55
|
-
dump_and_load(
|
56
|
-
dump_and_load(-
|
55
|
+
dump_and_load(12_345, false)
|
56
|
+
dump_and_load(-54_321, false)
|
57
57
|
dump_and_load(1, false)
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_float
|
61
61
|
dump_and_load(0.0, false)
|
62
|
-
dump_and_load(
|
62
|
+
dump_and_load(12_345.6789, false)
|
63
63
|
dump_and_load(70.35, false)
|
64
|
-
dump_and_load(-
|
64
|
+
dump_and_load(-54_321.012, false)
|
65
65
|
dump_and_load(1.7775, false)
|
66
66
|
dump_and_load(2.5024, false)
|
67
67
|
dump_and_load(2.48e16, false)
|
@@ -69,6 +69,16 @@ class StrictJuice < Minitest::Test
|
|
69
69
|
dump_and_load(-2.48e100 * 1.0e10, false)
|
70
70
|
end
|
71
71
|
|
72
|
+
def test_invalid_float
|
73
|
+
begin
|
74
|
+
Oj.load("64ecb72d29191067f91ff95b")
|
75
|
+
rescue Oj::ParseError => e
|
76
|
+
assert(e.message == "Invalid float")
|
77
|
+
return
|
78
|
+
end
|
79
|
+
assert(false, "*** expected an exception")
|
80
|
+
end
|
81
|
+
|
72
82
|
def test_nan_dump
|
73
83
|
assert_equal('null', Oj.dump(0/0.0, :nan => :null))
|
74
84
|
assert_equal('3.3e14159265358979323846', Oj.dump(0/0.0, :nan => :huge))
|
@@ -78,7 +88,7 @@ class StrictJuice < Minitest::Test
|
|
78
88
|
assert(true)
|
79
89
|
return
|
80
90
|
end
|
81
|
-
assert(false,
|
91
|
+
assert(false, '*** expected an exception')
|
82
92
|
end
|
83
93
|
|
84
94
|
def test_infinity_dump
|
@@ -90,7 +100,7 @@ class StrictJuice < Minitest::Test
|
|
90
100
|
assert(true)
|
91
101
|
return
|
92
102
|
end
|
93
|
-
assert(false,
|
103
|
+
assert(false, '*** expected an exception')
|
94
104
|
end
|
95
105
|
|
96
106
|
def test_neg_infinity_dump
|
@@ -102,7 +112,7 @@ class StrictJuice < Minitest::Test
|
|
102
112
|
assert(true)
|
103
113
|
return
|
104
114
|
end
|
105
|
-
assert(false,
|
115
|
+
assert(false, '*** expected an exception')
|
106
116
|
end
|
107
117
|
|
108
118
|
def test_string
|
@@ -115,15 +125,11 @@ class StrictJuice < Minitest::Test
|
|
115
125
|
def test_encode
|
116
126
|
opts = Oj.default_options
|
117
127
|
Oj.default_options = { :ascii_only => false }
|
118
|
-
|
119
|
-
dump_and_load("ぴーたー", false)
|
120
|
-
end
|
128
|
+
dump_and_load('ぴーたー', false)
|
121
129
|
Oj.default_options = { :ascii_only => true }
|
122
|
-
json = Oj.dump(
|
130
|
+
json = Oj.dump('ぴーたー')
|
123
131
|
assert_equal(%{"\\u3074\\u30fc\\u305f\\u30fc"}, json)
|
124
|
-
|
125
|
-
dump_and_load("ぴーたー", false)
|
126
|
-
end
|
132
|
+
dump_and_load('ぴーたー', false)
|
127
133
|
Oj.default_options = opts
|
128
134
|
end
|
129
135
|
|
@@ -152,15 +158,17 @@ class StrictJuice < Minitest::Test
|
|
152
158
|
end
|
153
159
|
|
154
160
|
def test_array_deep
|
155
|
-
dump_and_load([1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20]]]]]]]]]]]]]]]]]]]], false)
|
161
|
+
dump_and_load([1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20]]]]]]]]]]]]]]]]]]]], false)
|
156
162
|
end
|
157
163
|
|
158
164
|
def test_deep_nest
|
165
|
+
skip 'TruffleRuby causes SEGV' if RUBY_ENGINE == 'truffleruby'
|
166
|
+
|
159
167
|
begin
|
160
|
-
n =
|
161
|
-
Oj.strict_load('[' * n + ']' * n)
|
168
|
+
n = 10_000
|
169
|
+
Oj.strict_load(('[' * n) + (']' * n))
|
162
170
|
rescue Exception => e
|
163
|
-
|
171
|
+
refute(e.message)
|
164
172
|
end
|
165
173
|
end
|
166
174
|
|
@@ -207,7 +215,7 @@ class StrictJuice < Minitest::Test
|
|
207
215
|
assert(true)
|
208
216
|
return
|
209
217
|
end
|
210
|
-
assert(false,
|
218
|
+
assert(false, '*** expected an exception')
|
211
219
|
end
|
212
220
|
|
213
221
|
def test_bignum_object
|
@@ -236,7 +244,7 @@ class StrictJuice < Minitest::Test
|
|
236
244
|
assert(true)
|
237
245
|
return
|
238
246
|
end
|
239
|
-
assert(false,
|
247
|
+
assert(false, '*** expected an exception')
|
240
248
|
end
|
241
249
|
|
242
250
|
def test_range
|
@@ -246,7 +254,7 @@ class StrictJuice < Minitest::Test
|
|
246
254
|
assert(true)
|
247
255
|
return
|
248
256
|
end
|
249
|
-
assert(false,
|
257
|
+
assert(false, '*** expected an exception')
|
250
258
|
end
|
251
259
|
|
252
260
|
# Stream IO
|
@@ -263,13 +271,13 @@ class StrictJuice < Minitest::Test
|
|
263
271
|
end
|
264
272
|
|
265
273
|
def test_io_file
|
266
|
-
filename = File.join(
|
267
|
-
File.
|
274
|
+
filename = File.join(__dir__, 'open_file_test.json')
|
275
|
+
File.write(filename, %{{
|
268
276
|
"x":true,
|
269
277
|
"y":58,
|
270
278
|
"z": [1,2,3]
|
271
279
|
}
|
272
|
-
})
|
280
|
+
})
|
273
281
|
f = File.new(filename)
|
274
282
|
obj = Oj.strict_load(f)
|
275
283
|
f.close()
|
@@ -289,7 +297,7 @@ class StrictJuice < Minitest::Test
|
|
289
297
|
assert(true)
|
290
298
|
return
|
291
299
|
end
|
292
|
-
assert(false,
|
300
|
+
assert(false, '*** expected an exception')
|
293
301
|
end
|
294
302
|
|
295
303
|
def test_class
|
@@ -299,7 +307,7 @@ class StrictJuice < Minitest::Test
|
|
299
307
|
assert(true)
|
300
308
|
return
|
301
309
|
end
|
302
|
-
assert(false,
|
310
|
+
assert(false, '*** expected an exception')
|
303
311
|
end
|
304
312
|
|
305
313
|
def test_module
|
@@ -309,7 +317,7 @@ class StrictJuice < Minitest::Test
|
|
309
317
|
assert(true)
|
310
318
|
return
|
311
319
|
end
|
312
|
-
assert(false,
|
320
|
+
assert(false, '*** expected an exception')
|
313
321
|
end
|
314
322
|
|
315
323
|
# symbol_keys option
|
@@ -421,7 +429,7 @@ class StrictJuice < Minitest::Test
|
|
421
429
|
def dump_and_load(obj, trace=false)
|
422
430
|
json = Oj.dump(obj, :indent => 2)
|
423
431
|
puts json if trace
|
424
|
-
loaded = Oj.strict_load(json)
|
432
|
+
loaded = Oj.strict_load(json)
|
425
433
|
if obj.nil?
|
426
434
|
assert_nil(loaded)
|
427
435
|
else
|