[前][次][番号順一覧][スレッド一覧]

ruby-changes:35088

From: nobu <ko1@a...>
Date: Wed, 13 Aug 2014 21:18:03 +0900 (JST)
Subject: [ruby-changes:35088] nobu:r47170 (trunk): test_parse.rb: for warnings

nobu	2014-08-13 21:17:57 +0900 (Wed, 13 Aug 2014)

  New Revision: 47170

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47170

  Log:
    test_parse.rb: for warnings
    
    * test/ruby/test_parse.rb (TestParse): add tests for parser warnings.

  Modified files:
    trunk/test/ruby/test_parse.rb
Index: test/ruby/test_parse.rb
===================================================================
--- test/ruby/test_parse.rb	(revision 47169)
+++ test/ruby/test_parse.rb	(revision 47170)
@@ -851,4 +851,18 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L851
     actual = e.backtrace.first[/\A#{Regexp.quote(__FILE__)}:(\d+):/o, 1].to_i
     assert_equal(expected, actual, bug5614)
   end
+
+  def test_shadowing_variable
+    assert_warning(/shadowing outer local variable/) {eval("a=1; tap {|a|}")}
+  end
+
+  def test_unused_variable
+    o = Object.new
+    assert_warning(/assigned but unused variable/) {o.instance_eval("def foo; a=1; nil; end")}
+  end
+
+  def test_named_capture_conflict
+    a = 1
+    assert_warning(/named capture conflict/) {eval("a = 1; /(?<a>)/ =~ ''")}
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]