From b790c413f3fca858ac972e95e7d6252e43fa7781 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 22 Jun 2017 03:26:26 +0900 Subject: [PATCH] Add MatchData#values_at specs for the new named captures --- core/matchdata/values_at_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/matchdata/values_at_spec.rb b/core/matchdata/values_at_spec.rb index 8d786246f9..0b2727e001 100644 --- a/core/matchdata/values_at_spec.rb +++ b/core/matchdata/values_at_spec.rb @@ -10,4 +10,14 @@ /(.)(.)(\d+)(\d)/.match("THX1138: The Movie").values_at(2..4, 0..1).should == ["X", "113", "8", "HX1138", "H"] end end + + ruby_version_is '2.4' do + it 'slices captures with the given names' do + /(?.)(?.)(?.)/.match('012').values_at(:c, :a).should == ['2', '0'] + end + + it 'takes names and indices' do + /\A(?.)(?.)\z/.match('01').values_at(0, 1, 2, :a, :b).should == ['01', '0', '1', '0', '1'] + end + end end