diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-12-06 23:14:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-07 07:14:59 +0000 |
commit | ae76c8a11e707176a53c84016256646308f36207 (patch) | |
tree | 12595d3e93268a839ce82b5f1ce2c3eec1fb0aca /test | |
parent | 41c00bc97ebf237fd04ce740d0dfd0681f4a28c7 (diff) | |
download | ruby-ae76c8a11e707176a53c84016256646308f36207.tar.gz |
Warn `it` (#9152)
https://bugs.ruby-lang.org/issues/18980
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_syntax.rb | 11 |
1 files changed, 11 insertions, 0 deletions
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) |