From ae76c8a11e707176a53c84016256646308f36207 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Wed, 6 Dec 2023 23:14:59 -0800 Subject: Warn `it` (#9152) https://bugs.ruby-lang.org/issues/18980 --- test/ruby/test_syntax.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index e78d30148c..fe0785a754 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1719,6 +1719,17 @@ eom assert_valid_syntax("p { [_1 **2] }") end + def test_it + assert_no_warning(/`it`/) {eval('if false; it; end')} + assert_no_warning(/`it`/) {eval('def foo; it; end')} + assert_warn(/`it`/) {eval('0.times { it }')} + assert_no_warning(/`it`/) {eval('0.times { || it }')} + assert_no_warning(/`it`/) {eval('0.times { |_n| it }')} + assert_warn(/`it`/) {eval('0.times { it; it = 1; it }')} + assert_no_warning(/`it`/) {eval('0.times { it = 1; it }')} + assert_no_warning(/`it`/) {eval('it = 1; 0.times { it }')} + end + def test_value_expr_in_condition mesg = /void value expression/ assert_syntax_error("tap {a = (true ? next : break)}", mesg) -- cgit v1.2.3