summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-27 15:49:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-27 15:49:09 +0000
commite672994d146eeb85fc3670cbd97b484f6101d373 (patch)
treef487f8442544a9ea907830bebba14f9460dae3ea /test
parent1fe5783104b248be54f21d147722ca2ebc7d149a (diff)
parse.y: warn static content assign in cond
* parse.y (assign_in_cond): warn for static content object asignments in conditional statements. [ruby-dev:43083] [Feature #4299] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_rubyoptions.rb27
1 files changed, 24 insertions, 3 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index c39a45afe8..47baa691c9 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -331,12 +331,33 @@ class TestRubyOptions < Test::Unit::TestCase
t.puts " end"
t.puts "end"
t.close
- err = ["#{t.path}:1: warning: found = in conditional, should be ==",
- "#{t.path}:4: warning: found = in conditional, should be =="]
- err = /\A(#{Regexp.quote(t.path)}):1(: warning: found = in conditional, should be ==)\n\1:4\2\Z/
+ warning = ' warning: found = in conditional, should be =='
+ err = ["#{t.path}:1:#{warning}",
+ "#{t.path}:4:#{warning}",
+ ]
bug2136 = '[ruby-dev:39363]'
assert_in_out_err(["-w", t.path], "", [], err, bug2136)
assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err, bug2136)
+
+ t.open
+ t.truncate(0)
+ t.puts "if a = ''; end"
+ t.puts "if a = []; end"
+ t.puts "if a = [1]; end"
+ t.puts "if a = [a]; end"
+ t.puts "if a = {}; end"
+ t.puts "if a = {1=>2}; end"
+ t.puts "if a = {3=>a}; end"
+ t.close
+ err = ["#{t.path}:1:#{warning}",
+ "#{t.path}:2:#{warning}",
+ "#{t.path}:3:#{warning}",
+ "#{t.path}:5:#{warning}",
+ "#{t.path}:6:#{warning}",
+ ]
+ feature4299 = '[ruby-dev:43083]'
+ assert_in_out_err(["-w", t.path], "", [], err, feature4299)
+ assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err, feature4299)
ensure
t.close(true) if t
end