Skip to content

Commit 17fd55f

Browse files
committed
The return value of JSON.load is now the return value of Proc if there is a Proc
1 parent 1095f6a commit 17fd55f

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

stdlib/json/0/json.rbs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,8 @@ module JSON
962962
# #<Admin:0x00000000064c41f8
963963
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
964964
#
965-
def self?.load: (string | _ReadableIO | _Read source, ?Proc proc, ?options options) -> untyped
965+
def self?.load: (string | _ReadableIO | _Read source, ?options options) -> untyped
966+
| [T] (string | _ReadableIO | _Read source, ^(?) -> T, ?options options) -> T
966967

967968
# <!--
968969
# rdoc-file=ext/json/lib/json/common.rb
@@ -1110,11 +1111,6 @@ module JSON
11101111
#
11111112
def self?.pretty_generate: (_ToJson obj, ?options opts) -> untyped
11121113

1113-
# Recursively calls passed *Proc* if the parsed data structure is an *Array* or
1114-
# *Hash*
1115-
#
1116-
def self?.recurse_proc: (untyped result) { (*untyped) -> void } -> void
1117-
11181114
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
11191115
# Sets or Returns the JSON generator state class that is used by JSON.
11201116
#

test/stdlib/json/JSON_test.rb

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def test_load
7979
assert_send_type "(_ToStr) -> 42", JSON, :load, JsonToStr.new("42")
8080
assert_send_type "(JsonToReadableIO) -> 42", JSON, :load, JsonToReadableIO.new
8181
assert_send_type "(JsonRead) -> 42", JSON, :load, JsonRead.new
82-
assert_send_type "(String, Proc) -> 42", JSON, :load, "42", proc { }
83-
assert_send_type "(String, Proc, Hash[untyped, untyped]) -> 42", JSON, :load, "42", proc { }, { alllow_nan: true }
82+
assert_send_type "(String, Proc) -> 42", JSON, :load, "42", proc { |a| a }
83+
assert_send_type "(String, Proc, Hash[untyped, untyped]) -> 42", JSON, :load, "42", proc { |a| a }, { alllow_nan: true }
8484
end
8585

8686
def test_load_file
@@ -128,10 +128,6 @@ def test_pretty_generate
128128
assert_send_type "(ToJson, indent: String) -> String", JSON, :pretty_generate, ToJson.new, { indent: "\t" }
129129
end
130130

131-
def test_recurse_proc
132-
assert_send_type "(Integer) { (Integer) -> void } -> void", JSON, :recurse_proc, 42 do |_i| end
133-
end
134-
135131
def test_state
136132
assert_send_type "() -> singleton(JSON::Ext::Generator::State)", JSON, :state
137133
end
@@ -168,15 +164,6 @@ def test_generate
168164
assert_send_type "(ToJson, indent: String) -> String", MyJSON.new, :generate, ToJson.new, { indent: "\t" }
169165
end
170166

171-
def test_load
172-
assert_send_type "(String) -> 42", MyJSON.new, :load, "42"
173-
assert_send_type "(_ToStr) -> 42", MyJSON.new, :load, JsonToStr.new("42")
174-
assert_send_type "(JsonToReadableIO) -> 42", MyJSON.new, :load, JsonToReadableIO.new
175-
assert_send_type "(JsonRead) -> 42", MyJSON.new, :load, JsonRead.new
176-
assert_send_type "(String, Proc) -> 42", MyJSON.new, :load, "42", proc { }
177-
assert_send_type "(String, Proc, Hash[untyped, untyped]) -> 42", MyJSON.new, :load, "42", proc { }, { alllow_nan: true }
178-
end
179-
180167
def test_parse
181168
assert_send_type "(String) -> 42", MyJSON.new, :parse, "42"
182169
assert_send_type "(_ToStr) -> 42", MyJSON.new, :parse, JsonToStr.new("42")
@@ -194,10 +181,6 @@ def test_pretty_generate
194181
assert_send_type "(ToJson, indent: String) -> String", MyJSON.new, :pretty_generate, ToJson.new, { indent: "\t" }
195182
end
196183

197-
def test_recurse_proc
198-
assert_send_type "(Integer) { (Integer) -> void } -> void", MyJSON.new, :recurse_proc, 42 do |_i| end
199-
end
200-
201184
def test_to_json_with_object
202185
assert_send_type "() -> String", Object.new, :to_json
203186
assert_send_type "(JSON::State) -> String", Object.new, :to_json, JSON::State.new

0 commit comments

Comments
 (0)