Skip to content

Commit ce395d7

Browse files
authored
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 ```
1 parent 56ecd80 commit ce395d7

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

spec/ruby/language/if_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@
309309
it "warns when Integer literals are used instead of predicates" do
310310
-> {
311311
eval <<~RUBY
312+
$. = 0
312313
10.times { |i| ScratchPad << i if 4..5 }
313314
RUBY
314315
}.should complain(/warning: integer literal in flip-flop/, verbose: true)

0 commit comments

Comments
 (0)