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

ruby-changes:30940

From: nobu <ko1@a...>
Date: Mon, 23 Sep 2013 10:42:41 +0900 (JST)
Subject: [ruby-changes:30940] nobu:r43019 (trunk): test_module.rb: toplevel include

nobu	2013-09-23 10:42:34 +0900 (Mon, 23 Sep 2013)

  New Revision: 43019

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

  Log:
    test_module.rb: toplevel include
    
    * test/ruby/test_module.rb (TestModule#test_include_toplevel): test
      for top level main.include.  based on a part of the patch by
      kyrylo at [GH-395].

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_module.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43018)
+++ ChangeLog	(revision 43019)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Sep 23 10:42:30 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* test/ruby/test_module.rb (TestModule#test_include_toplevel): test
+	  for top level main.include.  based on a part of the patch by
+	  kyrylo at [GH-395].
+
 Mon Sep 23 05:07:49 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* include/ruby/intern.h (rb_ary_cat): move from internal.h, since it
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 43018)
+++ test/ruby/test_module.rb	(revision 43019)
@@ -357,6 +357,16 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L357
     end
   end
 
+  def test_include_toplevel
+    assert_separately([], <<-EOS)
+      Mod = Module.new {def foo; :include_foo end}
+      TOPLEVEL_BINDING.eval('include Mod')
+
+      assert_equal(:include_foo, TOPLEVEL_BINDING.eval('foo'))
+      assert_equal([Object, Mod], Object.ancestors.slice(0, 2))
+    EOS
+  end
+
   def test_included_modules
     assert_equal([], Mixin.included_modules)
     assert_equal([Mixin], User.included_modules)

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

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