summaryrefslogtreecommitdiff
path: root/spec/ruby/language/if_spec.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-15 08:53:16 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-15 08:53:16 +0000
commitbf7a32d22079cc44eb19794e41d82b886d5d17b3 (patch)
tree1d560bdb900b7f0ea89d6beb19c10845ed730876 /spec/ruby/language/if_spec.rb
parentbae638ad5b782c44c80efe33834cb9039279af46 (diff)
Remove warnings of flip-flop deprecation from tests and specs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/language/if_spec.rb')
-rw-r--r--spec/ruby/language/if_spec.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/spec/ruby/language/if_spec.rb b/spec/ruby/language/if_spec.rb
index 7f1ce8056d..fe207e77d5 100644
--- a/spec/ruby/language/if_spec.rb
+++ b/spec/ruby/language/if_spec.rb
@@ -235,19 +235,22 @@ describe "The if expression" do
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
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
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