Skip to content

Commit

Permalink
Update Enumerable#each_cons and Enumerable#each_slice
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Feb 1, 2022
1 parent 7bb18e6 commit 530cf57
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/enumerable.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
#
# With no block given, returns an Enumerator.
#
def each_cons: (Integer n) { (::Array[Elem] arg0) -> untyped } -> NilClass
| (Integer n) -> ::Enumerator[::Array[Elem], NilClass]
def each_cons: (Integer n) { (::Array[Elem]) -> void } -> self
| (Integer n) -> ::Enumerator[::Array[Elem], self]

# <!--
# rdoc-file=enum.c
Expand Down Expand Up @@ -1501,8 +1501,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
#
# With no block given, returns an Enumerator.
#
def each_slice: (Integer n) { (::Array[Elem]) -> untyped } -> NilClass
| (Integer n) -> ::Enumerator[::Array[Elem], NilClass]
def each_slice: (Integer n) { (::Array[Elem]) -> void } -> self
| (Integer n) -> ::Enumerator[::Array[Elem], self]

interface _NotFound[T]
def call: () -> T
Expand Down
14 changes: 14 additions & 0 deletions test/stdlib/Enumerable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ def test_each_with_object
TestEnumerable.new, :each_with_object, 0 do end
end

def test_each_cons
assert_send_type(
"(Integer) { (Array[String]) -> void } -> EnumerableTest2::TestEnumerable",
TestEnumerable.new, :each_cons, 2
) do end
end

def test_each_slice
assert_send_type(
"(Integer) { (Array[String]) -> void } -> EnumerableTest2::TestEnumerable",
TestEnumerable.new, :each_slice, 2
) do end
end

def test_find_index
assert_send_type "() -> ::Enumerator[String, Integer?]", TestEnumerable.new,
:find_index
Expand Down

0 comments on commit 530cf57

Please sign in to comment.