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

ruby-changes:40378

From: normal <ko1@a...>
Date: Fri, 6 Nov 2015 07:05:34 +0900 (JST)
Subject: [ruby-changes:40378] normal:r52459 (trunk): test/ruby/test_autoload: hoist out ruby_impl_require

normal	2015-11-06 07:05:06 +0900 (Fri, 06 Nov 2015)

  New Revision: 52459

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

  Log:
    test/ruby/test_autoload: hoist out ruby_impl_require
    
    Having "require" implemented in Ruby is the common case nowadays
    with RubyGems, so ensure it is easy-to-reuse the same logic for
    future tests.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_autoload.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52458)
+++ ChangeLog	(revision 52459)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Nov  6 06:59:37 2015  Eric Wong  <e@8...>
+
+	* test/ruby/test_autoload: hoist out ruby_impl_require
+
 Thu Nov  5 13:03:58 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* defs/id.def (token_ops): gather associations between IDs,
Index: test/ruby/test_autoload.rb
===================================================================
--- test/ruby/test_autoload.rb	(revision 52458)
+++ test/ruby/test_autoload.rb	(revision 52459)
@@ -187,31 +187,34 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L187
     }
   end
 
-  def test_require_implemented_in_ruby_is_called
+  def ruby_impl_require
     Kernel.module_eval do; alias :old_require :require; end
-
     called_with = []
     Kernel.send :define_method, :require do |path|
       called_with << path
       old_require path
     end
-
-    Tempfile.create(['autoload', '.rb']) {|file|
-      file.puts 'class AutoloadTest; end'
-      file.close
-      add_autoload(file.path)
-      begin
-        assert(Object::AutoloadTest)
-      ensure
-        remove_autoload_constant
-      end
-      assert_equal [file.path], called_with
-    }
-
+    yield called_with
   ensure
     Kernel.module_eval do; alias :require :old_require; undef :old_require; end
   end
 
+  def test_require_implemented_in_ruby_is_called
+    ruby_impl_require do |called_with|
+      Tempfile.create(['autoload', '.rb']) {|file|
+        file.puts 'class AutoloadTest; end'
+        file.close
+        add_autoload(file.path)
+        begin
+          assert(Object::AutoloadTest)
+        ensure
+          remove_autoload_constant
+        end
+        assert_equal [file.path], called_with
+      }
+    end
+  end
+
   def add_autoload(path)
     (@autoload_paths ||= []) << path
     ::Object.class_eval {autoload(:AutoloadTest, path)}

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

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