diff options
author | Hiroshi SHIBATA <[email protected]> | 2022-12-09 08:46:14 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2022-12-09 16:36:22 +0900 |
commit | 643918ecfe9c980f251247de6acd3be6280da24c (patch) | |
tree | a5b4011c13ee3af5b110e377a839e79045266dcd /test/csv/test_patterns.rb | |
parent | 260a00d80e4dcc930b040313a99da29e4b1e6678 (diff) |
Merge csv-3.2.6
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6890
Diffstat (limited to 'test/csv/test_patterns.rb')
-rw-r--r-- | test/csv/test_patterns.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/csv/test_patterns.rb b/test/csv/test_patterns.rb new file mode 100644 index 0000000000..881f03a3a4 --- /dev/null +++ b/test/csv/test_patterns.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require_relative "helper" + +class TestCSVPatternMatching < Test::Unit::TestCase + + def test_hash + case CSV::Row.new(%i{A B C}, [1, 2, 3]) + in B: b, C: c + assert_equal([2, 3], [b, c]) + end + end + + def test_hash_rest + case CSV::Row.new(%i{A B C}, [1, 2, 3]) + in B: b, **rest + assert_equal([2, { A: 1, C: 3 }], [b, rest]) + end + end + + def test_array + case CSV::Row.new(%i{A B C}, [1, 2, 3]) + in *, matched + assert_equal(3, matched) + end + end +end |