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

ruby-changes:16278

From: shyouhei <ko1@a...>
Date: Thu, 10 Jun 2010 13:39:11 +0900 (JST)
Subject: [ruby-changes:16278] Ruby:r28246 (ruby_1_8_7): merge revision(s) 26159:

shyouhei	2010-06-10 13:38:43 +0900 (Thu, 10 Jun 2010)

  New Revision: 28246

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

  Log:
    merge revision(s) 26159:
    * eval.c (rb_load): initialize orig_func.   [ruby-core:27296]

  Added files:
    branches/ruby_1_8_7/test/ruby/bug2519.rb
  Modified files:
    branches/ruby_1_8_7/ChangeLog
    branches/ruby_1_8_7/eval.c
    branches/ruby_1_8_7/test/ruby/test_method.rb
    branches/ruby_1_8_7/version.h

Index: ruby_1_8_7/ChangeLog
===================================================================
--- ruby_1_8_7/ChangeLog	(revision 28245)
+++ ruby_1_8_7/ChangeLog	(revision 28246)
@@ -1,3 +1,7 @@
+Thu Jun 10 13:37:35 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* eval.c (rb_load): initialize orig_func.   [ruby-core:27296]
+
 Tue Jun  8 18:57:48 2010  NAKAMURA Usaku  <usa@r...>
 
 	* win32/Makefile.sub (config.status): no need to embbed manifest if not exist.
Index: ruby_1_8_7/version.h
===================================================================
--- ruby_1_8_7/version.h	(revision 28245)
+++ ruby_1_8_7/version.h	(revision 28246)
@@ -1,15 +1,15 @@
 #define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2010-06-08"
+#define RUBY_RELEASE_DATE "2010-06-10"
 #define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20100608
-#define RUBY_PATCHLEVEL 291
+#define RUBY_RELEASE_CODE 20100610
+#define RUBY_PATCHLEVEL 292
 
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 8
 #define RUBY_VERSION_TEENY 7
 #define RUBY_RELEASE_YEAR 2010
 #define RUBY_RELEASE_MONTH 6
-#define RUBY_RELEASE_DAY 8
+#define RUBY_RELEASE_DAY 10
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: ruby_1_8_7/test/ruby/test_method.rb
===================================================================
--- ruby_1_8_7/test/ruby/test_method.rb	(revision 28245)
+++ ruby_1_8_7/test/ruby/test_method.rb	(revision 28246)
@@ -1,6 +1,16 @@
 require 'test/unit'
+require File.expand_path('../envutil', __FILE__)
 
 class TestMethod < Test::Unit::TestCase
+  def setup
+    @verbose = $VERBOSE
+    $VERBOSE = nil
+  end
+
+  def teardown
+    $VERBOSE = @verbose
+  end
+
   def m0() end
   def m1(a) end
   def m2(a, b) end
@@ -15,6 +25,15 @@
   class Derived < Base
     def foo() :derived end
   end
+  class T
+    def initialize; end
+    def normal_method; end
+  end
+  module M
+    def func; end
+    module_function :func
+    def meth; end
+  end
 
   def test_arity
     assert_equal(0, method(:m0).arity)
@@ -26,6 +45,10 @@
     assert_equal(-2, method(:mo4).arity)
   end
 
+  def test_arity_special
+    assert_equal(-1, method(:__send__).arity)
+  end
+
   def test_unbind
     assert_equal(:derived, Derived.new.foo)
     um = Derived.new.method(:foo).unbind
@@ -40,6 +63,47 @@
     end
   end
 
+  def test_callee
+    assert_equal(:test_callee, __method__)
+    assert_equal(:m, Class.new {def m; __method__; end}.new.m)
+    assert_equal(:m, Class.new {def m; tap{return __method__}; end}.new.m)
+    assert_equal(:m, Class.new {define_method(:m) {__method__}}.new.m)
+    assert_nothing_raised('[ruby-core:27296]') {load File.expand_path('../bug2519.rb', __FILE__)}
+  end
+
+  def test_new
+    c1 = Class.new
+    c1.class_eval { def foo; :foo; end }
+    c2 = Class.new(c1)
+    c2.class_eval { private :foo }
+    o = c2.new
+    o.extend(Module.new)
+    assert_raise(NameError) { o.method(:bar) }
+    assert_equal(:foo, o.method(:foo).call)
+  end
+
+  def test_eq
+    o = Object.new
+    class << o
+      def foo; end
+      alias bar foo
+      def baz; end
+    end
+    assert_not_equal(o.method(:foo), nil)
+    m = o.method(:foo)
+    def m.foo; end
+    assert_not_equal(o.method(:foo), m)
+    assert_equal(o.method(:foo), o.method(:foo))
+    assert_equal(o.method(:foo), o.method(:bar))
+    assert_not_equal(o.method(:foo), o.method(:baz))
+  end
+
+  def test_hash
+    o = Object.new
+    def o.foo; end
+    assert_kind_of(Integer, o.method(:foo).hash)
+  end
+
   def test_receiver_name_owner
     o = Object.new
     def o.foo; end
@@ -50,4 +114,104 @@
     assert_equal("foo", m.unbind.name)
     assert_equal(class << o; self; end, m.unbind.owner)
   end
+
+  def test_instance_method
+    c = Class.new
+    c.class_eval do
+      def foo; :foo; end
+      private :foo
+    end
+    o = c.new
+    o.method(:foo).unbind
+    assert_raise(NoMethodError) { o.foo }
+    c.instance_method(:foo).bind(o)
+    assert_equal(:foo, o.instance_eval { foo })
+    def o.bar; end
+    m = o.method(:bar).unbind
+    assert_raise(TypeError) { m.bind(Object.new) }
+  end
+
+  def test_define_method
+    c = Class.new
+    c.class_eval { def foo; :foo; end }
+    o = c.new
+    def o.bar; :bar; end
+    assert_raise(TypeError) do
+      c.class_eval { define_method(:foo, :foo) }
+    end
+    assert_raise(ArgumentError) do
+      c.class_eval { define_method }
+    end
+    c2 = Class.new(c)
+    c2.class_eval { define_method(:baz, o.method(:foo)) }
+    assert_equal(:foo, c2.new.baz)
+
+    o = Object.new
+    def o.foo(c)
+      c.class_eval { define_method(:foo) }
+    end
+    c = Class.new
+    o.foo(c) { :foo }
+    assert_equal(:foo, c.new.foo)
+  end
+
+  def test_clone
+    o = Object.new
+    def o.foo; :foo; end
+    m = o.method(:foo)
+    def m.bar; :bar; end
+    assert_equal(:foo, m.clone.call)
+    assert_equal(:bar, m.clone.bar)
+  end
+
+  def test_call
+    o = Object.new
+    def o.foo; p 1; end
+    def o.bar(x); x; end
+    m = o.method(:foo)
+    m.taint
+    assert_raise(SecurityError) { m.call }
+  end
+
+  def test_inspect
+    o = Object.new
+    def o.foo; end
+    m = o.method(:foo)
+    assert_equal("#<Method: #{ o.inspect }.foo>", m.inspect)
+    m = o.method(:foo)
+    assert_equal("#<UnboundMethod: #{ class << o; self; end.inspect }#foo>", m.unbind.inspect)
+
+    c = Class.new
+    c.class_eval { def foo; end; }
+    m = c.new.method(:foo)
+    assert_equal("#<Method: #{ c.inspect }#foo>", m.inspect)
+    m = c.instance_method(:foo)
+    assert_equal("#<UnboundMethod: #{ c.inspect }#foo>", m.inspect)
+
+    c2 = Class.new(c)
+    c2.class_eval { private :foo }
+    m2 = c2.new.method(:foo)
+    assert_equal("#<Method: #{ c2.inspect }(#{ c.inspect })#foo>", m2.inspect)
+  end
+
+  def test_caller_negative_level
+    assert_raise(ArgumentError) { caller(-1) }
+  end
+
+  def test_attrset_ivar
+    c = Class.new
+    c.class_eval { attr_accessor :foo }
+    o = c.new
+    o.method(:foo=).call(42)
+    assert_equal(42, o.foo)
+    assert_raise(ArgumentError) { o.method(:foo=).call(1, 2, 3) }
+    assert_raise(ArgumentError) { o.method(:foo).call(1) }
+  end
+
+  def test_default_accessibility
+    assert T.public_instance_methods.include?("normal_method"), 'normal methods are public by default'
+    assert !T.public_instance_methods.include?("initialize"), '#initialize is private'
+    assert !M.public_instance_methods.include?("func"), 'module methods are private by default'
+    assert M.public_instance_methods.include?("meth"), 'normal methods are public by default'
+  end
 end
Index: ruby_1_8_7/test/ruby/bug2519.rb
===================================================================
--- ruby_1_8_7/test/ruby/bug2519.rb	(revision 0)
+++ ruby_1_8_7/test/ruby/bug2519.rb	(revision 28246)
@@ -0,0 +1 @@
+__method__.to_s

Property changes on: ruby_1_8_7/test/ruby/bug2519.rb
___________________________________________________________________
Name: svn:eol-style
   + LF

Index: ruby_1_8_7/eval.c
===================================================================
--- ruby_1_8_7/eval.c	(revision 28245)
+++ ruby_1_8_7/eval.c	(revision 28246)
@@ -7035,6 +7035,7 @@
     PUSH_ITER(ITER_NOT);
     PUSH_FRAME();
     ruby_frame->last_func = 0;
+    ruby_frame->orig_func = 0;
     ruby_frame->last_class = 0;
     ruby_frame->self = self;
     PUSH_SCOPE();

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

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