Skip to content

Commit 7933cae

Browse files
committed
merge revision(s) 44630,44631: [Backport ruby#9403]
* lib/delegate.rb (Delegator): keep source information methods which start and end with '__'. [ruby-core:58572] [Bug ruby#9155] which start and end with '__'. [ruby-core:59718] [Bug ruby#9403] git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 21942cd commit 7933cae

4 files changed

Lines changed: 66 additions & 4 deletions

File tree

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Sun Feb 2 22:39:28 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* lib/delegate.rb (Delegator): keep source information methods
4+
which start and end with '__'. [ruby-core:59718] [Bug #9403]
5+
16
Fri Jan 31 12:10:16 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
27

38
* proc.c (mnew_from_me): keep iclass as-is, to make inheritance

lib/delegate.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Delegator < BasicObject
4848
undef_method m
4949
end
5050
private_instance_methods.each do |m|
51-
if /\Ablock_given\?\z|iterator\?\z|\A__raise__\z/ =~ m
51+
if /\Ablock_given\?\z|iterator\?\z|\A__.*__\z/ =~ m
5252
next
5353
end
5454
undef_method m

test/test_delegate.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,61 @@ def test_global_method_if_no_target
180180
x = assert_nothing_raised(ArgumentError, bug9155) {break Bug9155.new(1)}
181181
assert_equal(1, x.to_i, bug9155)
182182
end
183+
184+
class Bug9403
185+
Name = '[ruby-core:59718] [Bug #9403]'
186+
SD = SimpleDelegator.new(new)
187+
class << SD
188+
def method_name
189+
__method__
190+
end
191+
def callee_name
192+
__callee__
193+
end
194+
alias aliased_name callee_name
195+
def dir_name
196+
__dir__
197+
end
198+
end
199+
dc = DelegateClass(self)
200+
dc.class_eval do
201+
def method_name
202+
__method__
203+
end
204+
def callee_name
205+
__callee__
206+
end
207+
alias aliased_name callee_name
208+
def dir_name
209+
__dir__
210+
end
211+
end
212+
DC = dc.new(new)
213+
end
214+
215+
def test_method_in_simple_delegator
216+
assert_equal(:method_name, Bug9403::SD.method_name, Bug9403::Name)
217+
end
218+
219+
def test_callee_in_simple_delegator
220+
assert_equal(:callee_name, Bug9403::SD.callee_name, Bug9403::Name)
221+
assert_equal(:aliased_name, Bug9403::SD.aliased_name, Bug9403::Name)
222+
end
223+
224+
def test_dir_in_simple_delegator
225+
assert_equal(__dir__, Bug9403::SD.dir_name, Bug9403::Name)
226+
end
227+
228+
def test_method_in_delegator_class
229+
assert_equal(:method_name, Bug9403::DC.method_name, Bug9403::Name)
230+
end
231+
232+
def test_callee_in_delegator_class
233+
assert_equal(:callee_name, Bug9403::DC.callee_name, Bug9403::Name)
234+
assert_equal(:aliased_name, Bug9403::DC.aliased_name, Bug9403::Name)
235+
end
236+
237+
def test_dir_in_delegator_class
238+
assert_equal(__dir__, Bug9403::DC.dir_name, Bug9403::Name)
239+
end
183240
end

version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#define RUBY_VERSION "2.1.1"
2-
#define RUBY_RELEASE_DATE "2014-02-01"
3-
#define RUBY_PATCHLEVEL 14
2+
#define RUBY_RELEASE_DATE "2014-02-02"
3+
#define RUBY_PATCHLEVEL 15
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 2
7-
#define RUBY_RELEASE_DAY 1
7+
#define RUBY_RELEASE_DAY 2
88

99
#include "ruby/version.h"
1010

0 commit comments

Comments
 (0)