[前][次][番号順一覧][スレッド一覧]

ruby-changes:63539

From: Kazuki <ko1@a...>
Date: Sat, 7 Nov 2020 22:13:07 +0900 (JST)
Subject: [ruby-changes:63539] 640fd94eff (master): Fix and remove spec testing undefined behavior

https://git.ruby-lang.org/ruby.git/commit/?id=640fd94eff

From 640fd94effab28fa3d90ecb838d9702e1dea9b9c Mon Sep 17 00:00:00 2001
From: Kazuki Tsujimoto <kazuki@c...>
Date: Sat, 7 Nov 2020 22:05:20 +0900
Subject: Fix and remove spec testing undefined behavior


diff --git a/spec/ruby/language/pattern_matching_spec.rb b/spec/ruby/language/pattern_matching_spec.rb
index e82b0f5..e34ff2d 100644
--- a/spec/ruby/language/pattern_matching_spec.rb
+++ b/spec/ruby/language/pattern_matching_spec.rb
@@ -316,26 +316,26 @@ ruby_version_is "2.7" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/pattern_matching_spec.rb#L316
       end
 
       it "supports using _ in a pattern several times" do
-        eval(<<~RUBY).should == 2
+        eval(<<~RUBY).should == true
           case [0, 1, 2]
             in [0, _, _]
-              _
+              true
           end
         RUBY
       end
 
       it "supports using any name with _ at the beginning in a pattern several times" do
-        eval(<<~RUBY).should == 2
+        eval(<<~RUBY).should == true
           case [0, 1, 2]
             in [0, _x, _x]
-              _x
+              true
           end
         RUBY
 
-        eval(<<~RUBY).should == 2
+        eval(<<~RUBY).should == true
           case {a: 0, b: 1, c: 2}
             in {a: 0, b: _x, c: _x}
-              _x
+              true
           end
         RUBY
       end
@@ -569,19 +569,6 @@ ruby_version_is "2.7" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/pattern_matching_spec.rb#L569
         RUBY
       end
 
-      it "binds variable even if patter matches only partially" do
-        a = nil
-
-        eval(<<~RUBY).should == 0
-          case [0, 1, 2]
-            in [a, 1, 3]
-          else
-          end
-
-          a
-        RUBY
-      end
-
       it "supports splat operator *rest" do
         eval(<<~RUBY).should == [1, 2]
           case [0, 1, 2]
@@ -870,7 +857,7 @@ ruby_version_is "2.7" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/pattern_matching_spec.rb#L857
           end
         RUBY
 
-        ScratchPad.recorded.should == [[[:a, :b, :c]]]
+        ScratchPad.recorded.sort.should == [[[:a, :b, :c]]]
       end
 
       it "passes keys specified in pattern to #deconstruct_keys method if pattern contains double splat operator **" do
@@ -887,7 +874,7 @@ ruby_version_is "2.7" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/pattern_matching_spec.rb#L874
           end
         RUBY
 
-        ScratchPad.recorded.should == [[[:a, :b]]]
+        ScratchPad.recorded.sort.should == [[[:a, :b]]]
       end
 
       it "passes nil to #deconstruct_keys method if pattern contains double splat operator **rest" do
@@ -916,19 +903,6 @@ ruby_version_is "2.7" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/pattern_matching_spec.rb#L903
         RUBY
       end
 
-      it "binds variable even if pattern matches only partially" do
-        x = nil
-
-        eval(<<~RUBY).should == 0
-          case {a: 0, b: 1}
-            in {a: x, b: 2}
-          else
-          end
-
-          x
-        RUBY
-      end
-
       it "supports double splat operator **rest" do
         eval(<<~RUBY).should == {b: 1, c: 2}
           case {a: 0, b: 1, c: 2}
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]