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

ruby-changes:41886

From: nobu <ko1@a...>
Date: Sun, 28 Feb 2016 10:38:45 +0900 (JST)
Subject: [ruby-changes:41886] nobu:r53960 (trunk): test_exception.rb: split test_name_error_info

nobu	2016-02-28 10:39:30 +0900 (Sun, 28 Feb 2016)

  New Revision: 53960

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

  Log:
    test_exception.rb: split test_name_error_info

  Modified files:
    trunk/test/ruby/test_exception.rb
Index: test/ruby/test_exception.rb
===================================================================
--- test/ruby/test_exception.rb	(revision 53959)
+++ test/ruby/test_exception.rb	(revision 53960)
@@ -725,42 +725,60 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L725
     assert_in_out_err([], "raise Class.new(RuntimeError), 'foo'", [], /foo\n/)
   end
 
-  def test_name_error_info
-    obj = BasicObject.new
-    class << obj
+  PrettyObject =
+    Class.new(BasicObject) do
       alias object_id __id__
       def pretty_inspect; "`obj'"; end
+      alias inspect pretty_inspect
     end
+
+  def test_name_error_info_const
+    obj = PrettyObject.new
+
     e = assert_raise(NameError) {
       obj.instance_eval("Object")
     }
     assert_equal(:Object, e.name)
+
     e = assert_raise(NameError) {
       BasicObject::X
     }
     assert_same(BasicObject, e.receiver)
+    assert_equal(:X, e.name)
+  end
+
+  def test_name_error_info_method
+    obj = PrettyObject.new
+
     e = assert_raise(NameError) {
       obj.instance_eval {foo}
     }
     assert_equal(:foo, e.name)
     assert_same(obj, e.receiver)
+
     e = assert_raise(NoMethodError) {
       obj.foo(1, 2)
     }
     assert_equal(:foo, e.name)
     assert_equal([1, 2], e.args)
     assert_same(obj, e.receiver)
+
     e = assert_raise(NoMethodError) {
       obj.instance_eval {foo(1, 2)}
     }
     assert_equal(:foo, e.name)
     assert_equal([1, 2], e.args)
     assert_same(obj, e.receiver)
+  end
+
+  def test_name_error_info_local_variables
+    obj = PrettyObject.new
     def obj.test(a, b=nil, *c, &d)
       e = a
       1.times {|f| g = foo; g}
       e
     end
+
     e = assert_raise(NameError) {
       obj.test(3)
     }

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

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