diff options
author | rm155 <86454369+rm155@users.noreply.github.com> | 2021-10-10 22:21:42 -0400 |
---|---|---|
committer | Sutou Kouhei <kou@cozmixng.org> | 2021-10-24 05:57:33 +0900 |
commit | ee948fc1b4cb1ad382beee709008bb93b8f6ba75 (patch) | |
tree | 323e979f3c67259699d838228d28a0ea4fb3ac92 /test/csv/interface/test_read.rb | |
parent | 274882be62e5996d804e87103586feaeec381820 (diff) |
[ruby/csv] Add support for Ractor (https://github.com/ruby/csv/pull/218)
https://github.com/ruby/csv/commit/a802690e11
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5010
Diffstat (limited to 'test/csv/interface/test_read.rb')
-rw-r--r-- | test/csv/interface/test_read.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/csv/interface/test_read.rb b/test/csv/interface/test_read.rb index b86c54fc9f..d73622d554 100644 --- a/test/csv/interface/test_read.rb +++ b/test/csv/interface/test_read.rb @@ -32,6 +32,24 @@ class TestCSVInterfaceRead < Test::Unit::TestCase assert_equal(@rows, rows) end + if respond_to?(:ractor) + ractor + def test_foreach_in_ractor + ractor = Ractor.new(@input.path) do |path| + rows = [] + CSV.foreach(path, col_sep: "\t", row_sep: "\r\n").each do |row| + rows << row + end + rows + end + rows = [ + ["1", "2", "3"], + ["4", "5"], + ] + assert_equal(rows, ractor.take) + end + end + def test_foreach_mode rows = [] CSV.foreach(@input.path, "r", col_sep: "\t", row_sep: "\r\n").each do |row| @@ -240,6 +258,20 @@ class TestCSVInterfaceRead < Test::Unit::TestCase CSV.read(@input.path, col_sep: "\t", row_sep: "\r\n")) end + if respond_to?(:ractor) + ractor + def test_read_in_ractor + ractor = Ractor.new(@input.path) do |path| + CSV.read(path, col_sep: "\t", row_sep: "\r\n") + end + rows = [ + ["1", "2", "3"], + ["4", "5"], + ] + assert_equal(rows, ractor.take) + end + end + def test_readlines assert_equal(@rows, CSV.readlines(@input.path, col_sep: "\t", row_sep: "\r\n")) |