Skip to content

Commit 5eab6ba

Browse files
eregonandrykonchin
authored andcommitted
Add pattern matching specs for in {} and in {**nil}
1 parent 3406d1d commit 5eab6ba

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

spec/ruby/language/pattern_matching_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,37 @@ def obj.deconstruct_keys(*args)
12561256
RUBY
12571257
end
12581258

1259+
it "in {} only matches empty hashes" do
1260+
eval(<<~RUBY).should == false
1261+
case {a: 1}
1262+
in {}
1263+
true
1264+
else
1265+
false
1266+
end
1267+
RUBY
1268+
end
1269+
1270+
it "in {**nil} only matches empty hashes" do
1271+
eval(<<~RUBY).should == true
1272+
case {}
1273+
in {**nil}
1274+
true
1275+
else
1276+
false
1277+
end
1278+
RUBY
1279+
1280+
eval(<<~RUBY).should == false
1281+
case {a: 1}
1282+
in {**nil}
1283+
true
1284+
else
1285+
false
1286+
end
1287+
RUBY
1288+
end
1289+
12591290
it "matches anything with **" do
12601291
eval(<<~RUBY).should == true
12611292
case {a: 1}

0 commit comments

Comments
 (0)