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

ruby-changes:38448

From: nobu <ko1@a...>
Date: Mon, 18 May 2015 18:41:34 +0900 (JST)
Subject: [ruby-changes:38448] nobu:r50529 (trunk): test_autoload.rb: use class_eval

nobu	2015-05-18 18:41:21 +0900 (Mon, 18 May 2015)

  New Revision: 50529

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

  Log:
    test_autoload.rb: use class_eval
    
    * test/ruby/test_autoload.rb (add_autoload): use class_eval
      instead of string eval.
    
    * test/ruby/test_autoload.rb (remove_autoload_constant): ditto.

  Modified files:
    trunk/test/ruby/test_autoload.rb
Index: test/ruby/test_autoload.rb
===================================================================
--- test/ruby/test_autoload.rb	(revision 50528)
+++ test/ruby/test_autoload.rb	(revision 50529)
@@ -214,19 +214,11 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L214
 
   def add_autoload(path)
     (@autoload_paths ||= []) << path
-    eval <<-END
-      class ::Object
-        autoload :AutoloadTest, #{path.dump}
-      end
-    END
+    ::Object.class_eval {autoload(:AutoloadTest, path)}
   end
 
   def remove_autoload_constant
     $".replace($" - @autoload_paths)
-    eval <<-END
-      class ::Object
-        remove_const(:AutoloadTest)
-      end
-    END
+    ::Object.class_eval {remove_const(:AutoloadTest)}
   end
 end

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

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