From d4da74ea786da7906fdb85e593593a9c6c11fe96 Mon Sep 17 00:00:00 2001 From: Kazuki Tsujimoto Date: Fri, 8 Nov 2019 11:37:07 +0900 Subject: Define Struct#deconstruct_keys --- test/ruby/test_pattern_matching.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/ruby/test_pattern_matching.rb') diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb index 0338f90a91..9af091a5e5 100644 --- a/test/ruby/test_pattern_matching.rb +++ b/test/ruby/test_pattern_matching.rb @@ -1230,6 +1230,30 @@ END true end end + + s = Struct.new(:a, :b, keyword_init: true) + assert_block do + case s[a: 0, b: 1] + in **r + r == {a: 0, b: 1} + end + end + assert_block do + s = Struct.new(:a, :b, keyword_init: true) + case s[a: 0, b: 1] + in a:, b: + a == 0 && b == 1 + end + end + assert_block do + s = Struct.new(:a, :b, keyword_init: true) + case s[a: 0, b: 1] + in a:, c: + flunk + in b: + b == 1 + end + end end ################################################################ -- cgit v1.2.3