diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-29 10:59:39 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-29 10:59:39 +0000 |
commit | 408853c0adf00cc69196c9e34db218dc1f266806 (patch) | |
tree | 354667ccb7db9e0e848c4008aa8dda783f5eda08 /test | |
parent | c2011d3a802d8396b38354d52706aab1cfe33ddc (diff) | |
download | ruby-408853c0adf00cc69196c9e34db218dc1f266806.tar.gz |
parse.y: !-operator warning
* parse.y (cond0): !-operator is a method call, no warning for
literal in condition. [ruby-core:77801] [Bug #12881]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_syntax.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 7c754316ff..ad1f0d8981 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -809,6 +809,46 @@ eom end end + def test_warning_literal_in_condition + assert_warn(/literal in condition/) do + eval('1 if ""') + end + assert_warn(/literal in condition/) do + eval('1 if //') + end + assert_warn(/literal in condition/) do + eval('1 if true..false') + end + assert_warning(/literal in condition/) do + eval('1 if 1') + end + assert_warning(/literal in condition/) do + eval('1 if :foo') + end + assert_warning(/literal in condition/) do + eval('1 if :"#{"foo".upcase}"') + end + + assert_warn('') do + eval('1 if !""') + end + assert_warn('') do + eval('1 if !//') + end + assert_warn('') do + eval('1 if !(true..false)') + end + assert_warning('') do + eval('1 if !1') + end + assert_warning('') do + eval('1 if !:foo') + end + assert_warning('') do + eval('1 if !:"#{"foo".upcase}"') + end + end + def test_alias_symbol bug8851 = '[ruby-dev:47681] [Bug #8851]' formats = ['%s', ":'%s'", ':"%s"', '%%s(%s)'] |