oj 2.11.5 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of oj might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +8 -11
- data/ext/oj/dump.c +55 -14
- data/ext/oj/object.c +188 -3
- data/ext/oj/oj.c +18 -6
- data/ext/oj/oj.h +4 -1
- data/ext/oj/parse.c +4 -1
- data/ext/oj/parse.h +1 -0
- data/ext/oj/sparse.c +3 -1
- data/lib/oj/version.rb +1 -1
- data/test/bug.rb +40 -51
- data/test/bug2.rb +10 -0
- data/test/io.rb +48 -0
- data/test/{test_range.rb → mod.rb} +6 -9
- data/test/struct.rb +29 -0
- data/test/test_compat.rb +62 -0
- data/test/test_file.rb +14 -3
- data/test/test_object.rb +185 -17
- data/test/test_serializer.rb +59 -0
- data/test/test_various.rb +5 -15
- data/test/write_timebars.rb +31 -0
- data/test/zip.rb +34 -0
- metadata +10 -7
- data/test/perf1.rb +0 -64
- data/test/perf2.rb +0 -76
- data/test/perf_obj_old.rb +0 -213
- data/test/test_bigd.rb +0 -63
data/test/test_bigd.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
$VERBOSE = true
|
5
|
-
|
6
|
-
%w(lib ext test).each do |dir|
|
7
|
-
$LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'rubygems' if RUBY_VERSION.start_with?('1.8.')
|
11
|
-
|
12
|
-
#require "minitest/spec"
|
13
|
-
require "minitest/autorun"
|
14
|
-
|
15
|
-
require "oj"
|
16
|
-
|
17
|
-
# Uncomment this line and test_big_decimal will fail
|
18
|
-
require "active_support/json"
|
19
|
-
|
20
|
-
# With ActiveSupport 4.0, neither of these settings affect BigDecimal#to_json,
|
21
|
-
# only BigDecimal#as_json
|
22
|
-
#
|
23
|
-
# ActiveSupport.encode_big_decimal_as_string = false
|
24
|
-
# ActiveSupport::JSON::Encoding.encode_big_decimal_as_string = false
|
25
|
-
|
26
|
-
describe Oj do
|
27
|
-
|
28
|
-
# Options set by default in Rails 4.0 / Rabl
|
29
|
-
def options
|
30
|
-
{
|
31
|
-
:bigdecimal_as_decimal=>true, # default = true
|
32
|
-
:use_to_json=>true, # default = false
|
33
|
-
:mode=>:compat, # default = object
|
34
|
-
:time_format=>:ruby, # default = unix
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_big_decimal
|
39
|
-
orig = BigDecimal.new("3.14159265359")
|
40
|
-
puts "*** to_s: #{orig.to_s}"
|
41
|
-
puts "*** to_json: #{orig.to_json}"
|
42
|
-
puts "*** JSON.dump: #{JSON.dump(orig)}"
|
43
|
-
json = Oj.dump(orig, options)
|
44
|
-
puts "*** json: #{json}"
|
45
|
-
|
46
|
-
value = Oj.load(json)
|
47
|
-
puts "*** value: #{value.class}"
|
48
|
-
assert_equal(value, orig)
|
49
|
-
|
50
|
-
# by default, without active support
|
51
|
-
# assert_equal("0.314159265359E1", json)
|
52
|
-
# in Rails 4.1, with active support
|
53
|
-
# assert_equal("3.14159265359", json)
|
54
|
-
end
|
55
|
-
|
56
|
-
# Floats are unaffected
|
57
|
-
def test_float
|
58
|
-
orig = 3.14159265359
|
59
|
-
json = Oj.dump(orig, options)
|
60
|
-
assert_equal("3.14159265359", json)
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|