summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2024-04-03 16:38:52 +0900
committerGitHub <[email protected]>2024-04-03 07:38:52 +0000
commitce395d7e90529ddf970bf36106e636831c9f1650 (patch)
tree2c4db711e2ec98588038c84e532d0c5b35f02b42
parent56ecd8038ac406a62b3a77b59b2a95ac3f9bd9b8 (diff)
Reset `$.` before matching
This is a global variable and may happen to be set to 4 elsewhere. http://ci.rvm.jp/logfiles/brlog.trunk.20240403-054356#L1707 ``` The if expression with a boolean range ('flip-flop' operator) warns when Integer literals are used instead of predicates FAILED Expected [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] == [] to be truthy but was false ```
-rw-r--r--spec/ruby/language/if_spec.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/spec/ruby/language/if_spec.rb b/spec/ruby/language/if_spec.rb
index 70c847d830..2d1a89f081 100644
--- a/spec/ruby/language/if_spec.rb
+++ b/spec/ruby/language/if_spec.rb
@@ -309,6 +309,7 @@ describe "The if expression" do
it "warns when Integer literals are used instead of predicates" do
-> {
eval <<~RUBY
+ $. = 0
10.times { |i| ScratchPad << i if 4..5 }
RUBY
}.should complain(/warning: integer literal in flip-flop/, verbose: true)