Skip to content

Commit

Permalink
Revert "Remove warnings of flip-flop deprecation from tests and specs"
Browse files Browse the repository at this point in the history
This reverts commit bf7a32d22079cc44eb19794e41d82b886d5d17b3.

flip-flop is no longer deprecated.

[Feature #5400]
  • Loading branch information
nobu authored and eregon committed Sep 29, 2019
1 parent c1eab60 commit 574b5c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion command_line/dash_e_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

describe "with -n and a Fixnum range" do
before :each do
@script = "-W0 -ne 'print if %s' #{fixture(__FILE__, "conditional_range.txt")}"
@script = "-ne 'print if %s' #{fixture(__FILE__, "conditional_range.txt")}"
end

it "mimics an awk conditional by comparing an inclusive-end range with $." do
Expand Down
17 changes: 7 additions & 10 deletions language/if_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,22 +233,19 @@
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
eval "10.times { |i| ScratchPad << i if (i == 4)..(i == 4) }"
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
eval "10.times { |i| ScratchPad << i if (i == 4)..(i == 7) }"
10.times { |i| ScratchPad << i if (i == 4)..(i == 7) }
ScratchPad.recorded.should == [4, 5, 6, 7]
end

Expand All @@ -258,12 +255,12 @@
end

it "mimics a sed conditional with a many-element exclusive-end range" do
eval "10.times { |i| ScratchPad << i if (i == 4)...(i == 5) }"
10.times { |i| ScratchPad << i if (i == 4)...(i == 5) }
ScratchPad.recorded.should == [4, 5]
end

it "allows combining two flip-flops" do
eval "10.times { |i| ScratchPad << i if (i == 4)...(i == 5) or (i == 7)...(i == 8) }"
10.times { |i| ScratchPad << i if (i == 4)...(i == 5) or (i == 7)...(i == 8) }
ScratchPad.recorded.should == [4, 5, 7, 8]
end

Expand All @@ -281,18 +278,18 @@

it "evaluates the second conditions lazily with inclusive-end range" do
collector = proc { |i| ScratchPad << i }
eval "10.times { |i| i if (i == 4)...collector[i] }"
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 }
eval "10.times { |i| i if (i == 4)..collector[i] }"
10.times { |i| i if (i == 4)..collector[i] }
ScratchPad.recorded.should == [4]
end

it "scopes state by flip-flop" do
store_me = eval("proc { |i| ScratchPad << i if (i == 4)..(i == 7) }")
store_me = proc { |i| ScratchPad << i if (i == 4)..(i == 7) }
store_me[1]
store_me[4]
proc { store_me[1] }.call
Expand Down
6 changes: 2 additions & 4 deletions language/precedence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,8 @@ class FalseClass; undef_method :=~; end
from = 1
to = 2
# These are Range instances, not flip-flop
suppress_warning do
(eval("from..to") ? 3 : 4).should == 3
(eval("from...to") ? 3 : 4).should == 3
end
(from..to ? 3 : 4).should == 3
(from...to ? 3 : 4).should == 3
end

it "? : is right-associative" do
Expand Down

0 comments on commit 574b5c0

Please sign in to comment.