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
```
This commit is contained in:
Nobuyoshi Nakada 2024-04-03 16:38:52 +09:00 committed by GitHub
parent 56ecd8038a
commit ce395d7e90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)