oj 3.13.17 → 3.16.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -0
  3. data/README.md +4 -2
  4. data/ext/oj/buf.h +7 -6
  5. data/ext/oj/cache.c +29 -26
  6. data/ext/oj/cache.h +3 -2
  7. data/ext/oj/cache8.c +10 -9
  8. data/ext/oj/circarray.c +7 -5
  9. data/ext/oj/circarray.h +2 -2
  10. data/ext/oj/code.c +5 -12
  11. data/ext/oj/code.h +2 -2
  12. data/ext/oj/compat.c +20 -60
  13. data/ext/oj/custom.c +44 -96
  14. data/ext/oj/debug.c +3 -9
  15. data/ext/oj/dump.c +69 -39
  16. data/ext/oj/dump.h +1 -4
  17. data/ext/oj/dump_compat.c +557 -592
  18. data/ext/oj/dump_leaf.c +3 -5
  19. data/ext/oj/dump_object.c +42 -48
  20. data/ext/oj/dump_strict.c +10 -22
  21. data/ext/oj/encoder.c +1 -1
  22. data/ext/oj/err.c +2 -13
  23. data/ext/oj/err.h +9 -12
  24. data/ext/oj/extconf.rb +16 -6
  25. data/ext/oj/fast.c +76 -106
  26. data/ext/oj/intern.c +63 -51
  27. data/ext/oj/intern.h +3 -7
  28. data/ext/oj/mem.c +318 -0
  29. data/ext/oj/mem.h +53 -0
  30. data/ext/oj/mimic_json.c +43 -30
  31. data/ext/oj/object.c +61 -70
  32. data/ext/oj/odd.c +8 -6
  33. data/ext/oj/odd.h +4 -4
  34. data/ext/oj/oj.c +243 -205
  35. data/ext/oj/oj.h +82 -78
  36. data/ext/oj/parse.c +123 -188
  37. data/ext/oj/parse.h +23 -24
  38. data/ext/oj/parser.c +103 -63
  39. data/ext/oj/parser.h +19 -9
  40. data/ext/oj/rails.c +68 -92
  41. data/ext/oj/reader.c +10 -15
  42. data/ext/oj/reader.h +4 -2
  43. data/ext/oj/resolve.c +3 -4
  44. data/ext/oj/rxclass.c +6 -5
  45. data/ext/oj/rxclass.h +1 -1
  46. data/ext/oj/saj.c +10 -9
  47. data/ext/oj/saj2.c +74 -92
  48. data/ext/oj/saj2.h +23 -0
  49. data/ext/oj/scp.c +3 -14
  50. data/ext/oj/sparse.c +22 -70
  51. data/ext/oj/stream_writer.c +43 -35
  52. data/ext/oj/strict.c +20 -52
  53. data/ext/oj/string_writer.c +60 -34
  54. data/ext/oj/trace.h +31 -4
  55. data/ext/oj/usual.c +125 -150
  56. data/ext/oj/usual.h +69 -0
  57. data/ext/oj/util.h +1 -1
  58. data/ext/oj/val_stack.c +14 -3
  59. data/ext/oj/val_stack.h +8 -7
  60. data/ext/oj/wab.c +25 -57
  61. data/lib/oj/active_support_helper.rb +1 -3
  62. data/lib/oj/bag.rb +7 -1
  63. data/lib/oj/easy_hash.rb +4 -5
  64. data/lib/oj/error.rb +0 -1
  65. data/lib/oj/json.rb +162 -150
  66. data/lib/oj/mimic.rb +6 -2
  67. data/lib/oj/state.rb +9 -6
  68. data/lib/oj/version.rb +1 -2
  69. data/lib/oj.rb +2 -0
  70. data/pages/Compatibility.md +1 -1
  71. data/pages/InstallOptions.md +20 -0
  72. data/pages/Options.md +10 -0
  73. data/test/_test_active.rb +8 -9
  74. data/test/_test_active_mimic.rb +7 -8
  75. data/test/_test_mimic_rails.rb +17 -20
  76. data/test/activerecord/result_test.rb +5 -6
  77. data/test/files.rb +15 -15
  78. data/test/foo.rb +9 -72
  79. data/test/helper.rb +11 -8
  80. data/test/isolated/shared.rb +3 -2
  81. data/test/json_gem/json_addition_test.rb +2 -2
  82. data/test/json_gem/json_common_interface_test.rb +8 -6
  83. data/test/json_gem/json_encoding_test.rb +0 -0
  84. data/test/json_gem/json_ext_parser_test.rb +1 -0
  85. data/test/json_gem/json_fixtures_test.rb +3 -2
  86. data/test/json_gem/json_generator_test.rb +53 -37
  87. data/test/json_gem/json_generic_object_test.rb +11 -11
  88. data/test/json_gem/json_parser_test.rb +47 -47
  89. data/test/json_gem/json_string_matching_test.rb +9 -9
  90. data/test/json_gem/test_helper.rb +7 -3
  91. data/test/mem.rb +13 -12
  92. data/test/perf.rb +21 -26
  93. data/test/perf_compat.rb +31 -33
  94. data/test/perf_dump.rb +28 -28
  95. data/test/perf_fast.rb +80 -82
  96. data/test/perf_file.rb +27 -29
  97. data/test/perf_object.rb +65 -69
  98. data/test/perf_once.rb +12 -11
  99. data/test/perf_parser.rb +42 -48
  100. data/test/perf_saj.rb +46 -54
  101. data/test/perf_scp.rb +57 -69
  102. data/test/perf_simple.rb +41 -39
  103. data/test/perf_strict.rb +68 -70
  104. data/test/perf_wab.rb +67 -69
  105. data/test/prec.rb +5 -5
  106. data/test/sample/change.rb +0 -1
  107. data/test/sample/dir.rb +0 -1
  108. data/test/sample/doc.rb +0 -1
  109. data/test/sample/file.rb +0 -1
  110. data/test/sample/group.rb +0 -1
  111. data/test/sample/hasprops.rb +0 -1
  112. data/test/sample/layer.rb +0 -1
  113. data/test/sample/rect.rb +0 -1
  114. data/test/sample/shape.rb +0 -1
  115. data/test/sample/text.rb +0 -1
  116. data/test/sample.rb +16 -16
  117. data/test/sample_json.rb +8 -8
  118. data/test/test_compat.rb +80 -53
  119. data/test/test_custom.rb +73 -51
  120. data/test/test_debian.rb +7 -10
  121. data/test/test_fast.rb +86 -90
  122. data/test/test_file.rb +28 -35
  123. data/test/test_gc.rb +16 -5
  124. data/test/test_generate.rb +5 -5
  125. data/test/test_hash.rb +4 -4
  126. data/test/test_integer_range.rb +9 -9
  127. data/test/test_null.rb +20 -20
  128. data/test/test_object.rb +94 -96
  129. data/test/test_parser.rb +6 -22
  130. data/test/test_parser_debug.rb +27 -0
  131. data/test/test_parser_saj.rb +61 -22
  132. data/test/test_parser_usual.rb +16 -6
  133. data/test/test_rails.rb +2 -2
  134. data/test/test_saj.rb +10 -8
  135. data/test/test_scp.rb +37 -39
  136. data/test/test_strict.rb +40 -32
  137. data/test/test_various.rb +148 -100
  138. data/test/test_wab.rb +48 -44
  139. data/test/test_writer.rb +47 -47
  140. data/test/tests.rb +13 -4
  141. data/test/tests_mimic.rb +12 -3
  142. data/test/tests_mimic_addition.rb +12 -3
  143. metadata +36 -27
  144. data/test/activesupport4/decoding_test.rb +0 -108
  145. data/test/activesupport4/encoding_test.rb +0 -531
  146. data/test/activesupport4/test_helper.rb +0 -41
  147. data/test/activesupport5/abstract_unit.rb +0 -45
  148. data/test/activesupport5/decoding_test.rb +0 -133
  149. data/test/activesupport5/encoding_test.rb +0 -500
  150. data/test/activesupport5/encoding_test_cases.rb +0 -98
  151. data/test/activesupport5/test_helper.rb +0 -72
  152. data/test/activesupport5/time_zone_test_helpers.rb +0 -39
  153. data/test/bar.rb +0 -11
  154. data/test/baz.rb +0 -16
  155. data/test/bug.rb +0 -16
  156. data/test/zoo.rb +0 -13
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bigdecimal"
4
- require "date"
5
- require "time"
6
- require "pathname"
7
- require "uri"
8
-
9
- module JSONTest
10
- class Foo
11
- def initialize(a, b)
12
- @a, @b = a, b
13
- end
14
- end
15
-
16
- class Hashlike
17
- def to_hash
18
- { foo: "hello", bar: "world" }
19
- end
20
- end
21
-
22
- class Custom
23
- def initialize(serialized)
24
- @serialized = serialized
25
- end
26
-
27
- def as_json(options = nil)
28
- @serialized
29
- end
30
- end
31
-
32
- MyStruct = Struct.new(:name, :value) do
33
- def initialize(*)
34
- @unused = "unused instance variable"
35
- super
36
- end
37
- end
38
-
39
- module EncodingTestCases
40
- TrueTests = [[ true, %(true) ]]
41
- FalseTests = [[ false, %(false) ]]
42
- NilTests = [[ nil, %(null) ]]
43
- NumericTests = [[ 1, %(1) ],
44
- [ 2.5, %(2.5) ],
45
- [ 0.0 / 0.0, %(null) ],
46
- [ 1.0 / 0.0, %(null) ],
47
- [ -1.0 / 0.0, %(null) ],
48
- [ BigDecimal("0.0") / BigDecimal("0.0"), %(null) ],
49
- [ BigDecimal("2.5"), %("#{BigDecimal('2.5')}") ]]
50
-
51
- StringTests = [[ "this is the <string>", %("this is the \\u003cstring\\u003e")],
52
- [ 'a "string" with quotes & an ampersand', %("a \\"string\\" with quotes \\u0026 an ampersand") ],
53
- [ "http://test.host/posts/1", %("http://test.host/posts/1")],
54
- [ "Control characters: \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\u2028\u2029",
55
- %("Control characters: \\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f\\u2028\\u2029") ]]
56
-
57
- ArrayTests = [[ ["a", "b", "c"], %([\"a\",\"b\",\"c\"]) ],
58
- [ [1, "a", :b, nil, false], %([1,\"a\",\"b\",null,false]) ]]
59
-
60
- HashTests = [[ { foo: "bar" }, %({\"foo\":\"bar\"}) ],
61
- [ { 1 => 1, 2 => "a", 3 => :b, 4 => nil, 5 => false }, %({\"1\":1,\"2\":\"a\",\"3\":\"b\",\"4\":null,\"5\":false}) ]]
62
-
63
- RangeTests = [[ 1..2, %("1..2")],
64
- [ 1...2, %("1...2")],
65
- [ 1.5..2.5, %("1.5..2.5")]]
66
-
67
- SymbolTests = [[ :a, %("a") ],
68
- [ :this, %("this") ],
69
- [ :"a b", %("a b") ]]
70
-
71
- ObjectTests = [[ Foo.new(1, 2), %({\"a\":1,\"b\":2}) ]]
72
- HashlikeTests = [[ Hashlike.new, %({\"bar\":\"world\",\"foo\":\"hello\"}) ]]
73
- StructTests = [[ MyStruct.new(:foo, "bar"), %({\"name\":\"foo\",\"value\":\"bar\"}) ],
74
- [ MyStruct.new(nil, nil), %({\"name\":null,\"value\":null}) ]]
75
- CustomTests = [[ Custom.new("custom"), '"custom"' ],
76
- [ Custom.new(nil), "null" ],
77
- [ Custom.new(:a), '"a"' ],
78
- [ Custom.new([ :foo, "bar" ]), '["foo","bar"]' ],
79
- [ Custom.new(foo: "hello", bar: "world"), '{"bar":"world","foo":"hello"}' ],
80
- [ Custom.new(Hashlike.new), '{"bar":"world","foo":"hello"}' ],
81
- [ Custom.new(Custom.new(Custom.new(:a))), '"a"' ]]
82
-
83
- RegexpTests = [[ /^a/, '"(?-mix:^a)"' ], [/^\w{1,2}[a-z]+/ix, '"(?ix-m:^\\\\w{1,2}[a-z]+)"']]
84
-
85
- URITests = [[ URI.parse("http://example.com"), %("http://example.com") ]]
86
-
87
- PathnameTests = [[ Pathname.new("lib/index.rb"), %("lib/index.rb") ]]
88
-
89
- DateTests = [[ Date.new(2005, 2, 1), %("2005/02/01") ]]
90
- TimeTests = [[ Time.utc(2005, 2, 1, 15, 15, 10), %("2005/02/01 15:15:10 +0000") ]]
91
- DateTimeTests = [[ DateTime.civil(2005, 2, 1, 15, 15, 10), %("2005/02/01 15:15:10 +0000") ]]
92
-
93
- StandardDateTests = [[ Date.new(2005, 2, 1), %("2005-02-01") ]]
94
- StandardTimeTests = [[ Time.utc(2005, 2, 1, 15, 15, 10), %("2005-02-01T15:15:10.000Z") ]]
95
- StandardDateTimeTests = [[ DateTime.civil(2005, 2, 1, 15, 15, 10), %("2005-02-01T15:15:10.000+00:00") ]]
96
- StandardStringTests = [[ "this is the <string>", %("this is the <string>")]]
97
- end
98
- end
@@ -1,72 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- gem "minitest" # make sure we get the gem, not stdlib
4
- require "minitest"
5
- require "active_support/testing/tagged_logging"
6
- require "active_support/testing/setup_and_teardown"
7
- require "active_support/testing/assertions"
8
- require "active_support/testing/deprecation"
9
- require "active_support/testing/declarative"
10
- require "active_support/testing/isolation"
11
- require "active_support/testing/constant_lookup"
12
- require "active_support/testing/time_helpers"
13
- require "active_support/testing/file_fixtures"
14
-
15
- module ActiveSupport
16
- class TestCase < ::Minitest::Test
17
- Assertion = Minitest::Assertion
18
-
19
- class << self
20
- # Sets the order in which test cases are run.
21
- #
22
- # ActiveSupport::TestCase.test_order = :random # => :random
23
- #
24
- # Valid values are:
25
- # * +:random+ (to run tests in random order)
26
- # * +:parallel+ (to run tests in parallel)
27
- # * +:sorted+ (to run tests alphabetically by method name)
28
- # * +:alpha+ (equivalent to +:sorted+)
29
- def test_order=(new_order)
30
- ActiveSupport.test_order = new_order
31
- end
32
-
33
- # Returns the order in which test cases are run.
34
- #
35
- # ActiveSupport::TestCase.test_order # => :random
36
- #
37
- # Possible values are +:random+, +:parallel+, +:alpha+, +:sorted+.
38
- # Defaults to +:random+.
39
- def test_order
40
- ActiveSupport.test_order ||= :random
41
- end
42
- end
43
-
44
- alias_method :method_name, :name
45
-
46
- include ActiveSupport::Testing::TaggedLogging
47
- prepend ActiveSupport::Testing::SetupAndTeardown
48
- include ActiveSupport::Testing::Assertions
49
- include ActiveSupport::Testing::Deprecation
50
- include ActiveSupport::Testing::TimeHelpers
51
- include ActiveSupport::Testing::FileFixtures
52
- extend ActiveSupport::Testing::Declarative
53
-
54
- # test/unit backwards compatibility methods
55
- alias :assert_raise :assert_raises
56
- alias :assert_not_empty :refute_empty
57
- alias :assert_not_equal :refute_equal
58
- alias :assert_not_in_delta :refute_in_delta
59
- alias :assert_not_in_epsilon :refute_in_epsilon
60
- alias :assert_not_includes :refute_includes
61
- alias :assert_not_instance_of :refute_instance_of
62
- alias :assert_not_kind_of :refute_kind_of
63
- alias :assert_no_match :refute_match
64
- alias :assert_not_nil :refute_nil
65
- alias :assert_not_operator :refute_operator
66
- alias :assert_not_predicate :refute_predicate
67
- alias :assert_not_respond_to :refute_respond_to
68
- alias :assert_not_same :refute_same
69
-
70
- ActiveSupport.run_load_hooks(:active_support_test_case, self)
71
- end
72
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module TimeZoneTestHelpers
4
- def with_tz_default(tz = nil)
5
- old_tz = Time.zone
6
- Time.zone = tz
7
- yield
8
- ensure
9
- Time.zone = old_tz
10
- end
11
-
12
- def with_env_tz(new_tz = "US/Eastern")
13
- old_tz, ENV["TZ"] = ENV["TZ"], new_tz
14
- yield
15
- ensure
16
- old_tz ? ENV["TZ"] = old_tz : ENV.delete("TZ")
17
- end
18
-
19
- def with_preserve_timezone(value)
20
- old_preserve_tz = ActiveSupport.to_time_preserves_timezone
21
- ActiveSupport.to_time_preserves_timezone = value
22
- yield
23
- ensure
24
- ActiveSupport.to_time_preserves_timezone = old_preserve_tz
25
- end
26
-
27
- def with_tz_mappings(mappings)
28
- old_mappings = ActiveSupport::TimeZone::MAPPING.dup
29
- ActiveSupport::TimeZone.clear
30
- ActiveSupport::TimeZone::MAPPING.clear
31
- ActiveSupport::TimeZone::MAPPING.merge!(mappings)
32
-
33
- yield
34
- ensure
35
- ActiveSupport::TimeZone.clear
36
- ActiveSupport::TimeZone::MAPPING.clear
37
- ActiveSupport::TimeZone::MAPPING.merge!(old_mappings)
38
- end
39
- end
data/test/bar.rb DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $: << '.'
4
- $: << File.join(File.dirname(__FILE__), "../lib")
5
- $: << File.join(File.dirname(__FILE__), "../ext")
6
-
7
- require 'oj'
8
-
9
- p = Oj::Parser.validate
10
- # p = Oj::Parser.new(:debug)
11
- p.parse(%|{|)
data/test/baz.rb DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $: << File.dirname(__FILE__)
4
- $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
5
- %w(lib ext).each do |dir|
6
- $: << File.join($oj_dir, dir)
7
- end
8
-
9
- require 'oj'
10
- Oj.mimic_JSON()
11
-
12
- begin
13
- ::JSON.load('name=&email=&subject=&comment=&submit=Send+Message')
14
- rescue ::JSON::ParserError
15
- puts "*** Pass"
16
- end
data/test/bug.rb DELETED
@@ -1,16 +0,0 @@
1
- $: << '.'
2
- $: << File.join(File.dirname(__FILE__), "../lib")
3
- $: << File.join(File.dirname(__FILE__), "../ext")
4
-
5
-
6
- #require 'bundler/setup'
7
- require 'oj'
8
- require 'active_support'
9
- require 'active_support/time_with_zone'
10
- require 'tzinfo'
11
-
12
- puts ActiveSupport::TimeWithZone
13
-
14
- json = File.read('./bug.json')
15
-
16
- Oj.load(json)
data/test/zoo.rb DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #require 'json'
4
-
5
- $: << File.dirname(__FILE__)
6
- require 'helper'
7
- require 'oj'
8
-
9
- Oj.mimic_JSON
10
- puts "\u3074"
11
-
12
- puts JSON.dump(["\u3074"])
13
- puts JSON.generate(["\u3074"])