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

ruby-changes:51457

From: mame <ko1@a...>
Date: Fri, 15 Jun 2018 17:53:24 +0900 (JST)
Subject: [ruby-changes:51457] mame:r63668 (trunk): Remove warnings of flip-flop deprecation from tests and specs

mame	2018-06-15 17:53:16 +0900 (Fri, 15 Jun 2018)

  New Revision: 63668

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63668

  Log:
    Remove warnings of flip-flop deprecation from tests and specs

  Modified files:
    trunk/spec/ruby/command_line/dash_e_spec.rb
    trunk/spec/ruby/language/if_spec.rb
    trunk/spec/ruby/language/precedence_spec.rb
    trunk/test/ruby/test_flip.rb
    trunk/test/ruby/test_jit.rb
Index: spec/ruby/language/precedence_spec.rb
===================================================================
--- spec/ruby/language/precedence_spec.rb	(revision 63667)
+++ spec/ruby/language/precedence_spec.rb	(revision 63668)
@@ -301,8 +301,14 @@ describe "Operators" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/precedence_spec.rb#L301
    from = 1
    to = 2
    # These are Range instances, not flip-flop
-   (from..to ? 3 : 4).should == 3
-   (from...to ? 3 : 4).should == 3
+   @verbose = $VERBOSE
+   $VERBOSE = nil
+   begin
+     (eval("from..to") ? 3 : 4).should == 3
+     (eval("from...to") ? 3 : 4).should == 3
+   ensure
+     $VERBOSE = @verbose
+   end
  end
 
   it "? : is right-associative" do
Index: spec/ruby/language/if_spec.rb
===================================================================
--- spec/ruby/language/if_spec.rb	(revision 63667)
+++ spec/ruby/language/if_spec.rb	(revision 63668)
@@ -235,19 +235,22 @@ describe "The if expression" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/if_spec.rb#L235
   describe "with a boolean range ('flip-flop' operator)" do
     before :each do
       ScratchPad.record []
+      @verbose = $VERBOSE
+      $VERBOSE = nil
     end
 
     after :each do
       ScratchPad.clear
+      $VERBOSE = @verbose
     end
 
     it "mimics an awk conditional with a single-element inclusive-end range" do
-      10.times { |i| ScratchPad << i if (i == 4)..(i == 4) }
+      eval "10.times { |i| ScratchPad << i if (i == 4)..(i == 4) }"
       ScratchPad.recorded.should == [4]
     end
 
     it "mimics an awk conditional with a many-element inclusive-end range" do
-      10.times { |i| ScratchPad << i if (i == 4)..(i == 7) }
+      eval "10.times { |i| ScratchPad << i if (i == 4)..(i == 7) }"
       ScratchPad.recorded.should == [4, 5, 6, 7]
     end
 
@@ -257,12 +260,12 @@ describe "The if expression" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/if_spec.rb#L260
     end
 
     it "mimics a sed conditional with a many-element exclusive-end range" do
-      10.times { |i| ScratchPad << i if (i == 4)...(i == 5) }
+      eval "10.times { |i| ScratchPad << i if (i == 4)...(i == 5) }"
       ScratchPad.recorded.should == [4, 5]
     end
 
     it "allows combining two flip-flops" do
-      10.times { |i| ScratchPad << i if (i == 4)...(i == 5) or (i == 7)...(i == 8) }
+      eval "10.times { |i| ScratchPad << i if (i == 4)...(i == 5) or (i == 7)...(i == 8) }"
       ScratchPad.recorded.should == [4, 5, 7, 8]
     end
 
@@ -280,18 +283,18 @@ describe "The if expression" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/if_spec.rb#L283
 
     it "evaluates the second conditions lazily with inclusive-end range" do
       collector = proc { |i| ScratchPad << i }
-      10.times { |i| i if (i == 4)...collector[i] }
+      eval "10.times { |i| i if (i == 4)...collector[i] }"
       ScratchPad.recorded.should == [5]
     end
 
     it "evaluates the second conditions lazily with exclusive-end range" do
       collector = proc { |i| ScratchPad << i }
-      10.times { |i| i if (i == 4)..collector[i] }
+      eval "10.times { |i| i if (i == 4)..collector[i] }"
       ScratchPad.recorded.should == [4]
     end
 
     it "scopes state by flip-flop" do
-      store_me = proc { |i| ScratchPad << i if (i == 4)..(i == 7) }
+      store_me = eval("proc { |i| ScratchPad << i if (i == 4)..(i == 7) }")
       store_me[1]
       store_me[4]
       proc { store_me[1] }.call
Index: spec/ruby/command_line/dash_e_spec.rb
===================================================================
--- spec/ruby/command_line/dash_e_spec.rb	(revision 63667)
+++ spec/ruby/command_line/dash_e_spec.rb	(revision 63668)
@@ -25,7 +25,7 @@ describe "The -e command line option" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/dash_e_spec.rb#L25
 
   describe "with -n and a Fixnum range" do
     before :each do
-      @script = "-ne 'print if %s' #{fixture(__FILE__, "conditional_range.txt")}"
+      @script = "-W0 -ne 'print if %s' #{fixture(__FILE__, "conditional_range.txt")}"
     end
 
     it "mimics an awk conditional by comparing an inclusive-end range with $." do
Index: test/ruby/test_flip.rb
===================================================================
--- test/ruby/test_flip.rb	(revision 63667)
+++ test/ruby/test_flip.rb	(revision 63668)
@@ -2,7 +2,16 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_flip.rb#L2
 require 'test/unit'
 
 class TestFlip < Test::Unit::TestCase
+  def setup
+    @verbose_bak, $VERBOSE = $VERBOSE, nil
+  end
+
+  def teardown
+    $VERBOSE = @verbose_bak
+  end
+
   def test_flip_flop
+    eval <<-END
     assert_equal [4,5], (1..9).select {|n| true if (n==4)..(n==5)}
     assert_equal [4,5], (1..9).select {|n| true if (n==4)...(n==5)}
     assert_equal [2], (1..9).select {|n| true if (n==2)..(n%2).zero?}
@@ -10,6 +19,7 @@ class TestFlip < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_flip.rb#L19
     assert_equal [4,5,7,8], (1..9).select {|n| true if (n==4)...(n==5) or (n==7)...(n==8)}
     assert_equal [nil, 2, 3, 4, nil], (1..5).map {|x| x if (x==2..x==4)}
     assert_equal [1, nil, nil, nil, 5], (1..5).map {|x| x if !(x==2..x==4)}
+    END
   end
 
   def test_hidden_key
@@ -25,13 +35,13 @@ class TestFlip < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_flip.rb#L35
   def test_shared_eval
     bug7671 = '[ruby-core:51296]'
     vs = (1..9).to_a
-    vs.select {|n| if n==2..n==16 then 1 end}
+    eval("vs.select {|n| if n==2..n==16 then 1 end}")
     v = eval("vs.select {|n| if n==3..n==6 then 1 end}")
     assert_equal([*3..6], v, bug7671)
   end
 
   def test_shared_thread
-    ff = proc {|n| true if n==3..n==5}
+    ff = eval("proc {|n| true if n==3..n==5}")
     v = 1..9
     a = true
     th = Thread.new {
Index: test/ruby/test_jit.rb
===================================================================
--- test/ruby/test_jit.rb	(revision 63667)
+++ test/ruby/test_jit.rb	(revision 63668)
@@ -94,10 +94,13 @@ class TestJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L94
   end
 
   def test_compile_insn_setspecial
+    verbose_bak, $VERBOSE = $VERBOSE, nil
     assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: 'true', insns: %i[setspecial])
     begin;
       true if nil.nil?..nil.nil?
     end;
+  ensure
+    $VERBOSE = verbose_bak
   end
 
   def test_compile_insn_instancevariable

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

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