Skip to content

Commit 74aa11b

Browse files
committed
stdlib: Add types for CSV::Table#each
1 parent c3e8299 commit 74aa11b

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

stdlib/csv/0/csv.rbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,7 +3002,7 @@ end
30023002
# table['Name'] # => ["Foo", "Bar", "Baz"]
30033003
#
30043004
class CSV::Table[out Elem] < Object
3005-
include Enumerable[untyped]
3005+
include Enumerable[Elem]
30063006
extend Forwardable
30073007

30083008
# <!--
@@ -3633,8 +3633,8 @@ class CSV::Table[out Elem] < Object
36333633
# Returns a new Enumerator if no block is given:
36343634
# table.each # => #<Enumerator: #<CSV::Table mode:col row_count:4>:each>
36353635
#
3636-
def each: () -> Enumerator[untyped, self]
3637-
| () { (untyped) -> void } -> self
3636+
def each: () -> Enumerator[Elem, self]
3637+
| () { (Elem) -> void } -> self
36383638
| () { (*untyped) -> void } -> self
36393639

36403640
def empty?: (*untyped args) { (*untyped) -> untyped } -> untyped

test/stdlib/CSV_Table_test.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "test_helper"
4+
require "csv"
5+
6+
class CSV::TableInstanceTest < Test::Unit::TestCase
7+
include TestHelper
8+
9+
library 'csv'
10+
testing "CSV::Table[CSV::Row]"
11+
12+
def test_each
13+
table = CSV::Table.new([
14+
CSV::Row.new([], []),
15+
CSV::Row.new([], []),
16+
CSV::Row.new([], [])
17+
])
18+
19+
assert_send_type "() -> Enumerator[CSV::Row, void]",
20+
table, :each
21+
assert_send_type "() { (CSV::Row) -> void } -> CSV::Table",
22+
table, :each do end
23+
end
24+
end

0 commit comments

Comments
 (0)