summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-23 08:08:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-23 08:08:32 +0000
commit2e7bc702835a4ff6134c6f4dc0d8cfc75c7d4309 (patch)
tree276bb486f41ea76e663ca92b61aa76531174345e /test
parentce1eaf543e1afdd9bd8aa04d52d0050948925e69 (diff)
downloadruby-2e7bc702835a4ff6134c6f4dc0d8cfc75c7d4309.tar.gz
ruby-2e7bc702835a4ff6134c6f4dc0d8cfc75c7d4309.tar.xz
ruby-2e7bc702835a4ff6134c6f4dc0d8cfc75c7d4309.zip
* parse.y (assign_in_cond): also should warn assignment to dvar in
conditional. [ruby-dev:39363] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_rubyoptions.rb24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 14352052c..87d2200ad 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -281,13 +281,33 @@ class TestRubyOptions < Test::Unit::TestCase
/invalid name for global variable - -# \(NameError\)/)
end
+ def test_assignment_in_conditional
+ t = Tempfile.new(["test_ruby_test_rubyoption", ".rb"])
+ t.puts "if a = 1"
+ t.puts "end"
+ t.puts "0.times do"
+ t.puts " if b = 2"
+ 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/
+ bug2136 = '[ruby-dev:39363]'
+ assert_in_out_err(["-w", t.path], "", [], err, bug2136)
+ assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err, bug2136)
+ ensure
+ t.close(true) if t
+ end
+
def test_indentation_check
t = Tempfile.new(["test_ruby_test_rubyoption", ".rb"])
t.puts "begin"
t.puts " end"
t.close
- assert_in_out_err(["-w", t.path], "", [], /:2: warning: mismatched indentations at 'end' with 'begin' at 1/)
- assert_in_out_err(["-wr", t.path, "-e", ""], "", [], /:2: warning: mismatched indentations at 'end' with 'begin' at 1/)
+ err = ["#{t.path}:2: warning: mismatched indentations at 'end' with 'begin' at 1"]
+ assert_in_out_err(["-w", t.path], "", [], err)
+ assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err)
ensure
t.close(true) if t
end