Skip to content

Commit 0663a25

Browse files
committed
Suppress warning for redefine basic methods
1 parent 80af7c2 commit 0663a25

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

lib/rbs/unit_test/convertibles.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module UnitTest
55
module Convertibles
66
class BlankSlate < BasicObject
77
instance_methods.each do |im|
8+
next if im == :__id__
89
next if im == :__send__
910
undef_method im
1011
end

test/stdlib/BasicObject_test.rb

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,20 @@ def test_eq
2929
end
3030

3131
def test___id__
32-
assert_send_type '() -> Integer',
33-
BOBJ, :__id__
32+
suppress_warning do
33+
assert_send_type '() -> Integer',
34+
BOBJ, :__id__
35+
end
3436
end
3537

3638
def test___send__
37-
with_interned :__send__ do |name|
38-
assert_send_type '(interned, *untyped, **untyped) -> untyped',
39-
BOBJ, :__send__, name, :__id__
40-
assert_send_type '(interned, *untyped, **untyped) { (*untyped, **untyped) -> untyped} -> untyped',
41-
BOBJ, :__send__, name, :instance_exec do _1 end
39+
suppress_warning do
40+
with_interned :__send__ do |name|
41+
assert_send_type '(interned, *untyped, **untyped) -> untyped',
42+
BOBJ, :__send__, name, :__id__
43+
assert_send_type '(interned, *untyped, **untyped) { (*untyped, **untyped) -> untyped} -> untyped',
44+
BOBJ, :__send__, name, :instance_exec do _1 end
45+
end
4246
end
4347
end
4448

@@ -70,4 +74,14 @@ def test_instance_exec
7074
assert_send_type '(*String) { (*String) [self: BasicObject] -> Integer } -> Integer',
7175
BOBJ, :instance_exec, '1', '2' do |*x| x.join.to_i end
7276
end
77+
78+
def suppress_warning
79+
origstderr = $stderr
80+
begin
81+
$stderr = StringIO.new
82+
yield
83+
ensure
84+
$stderr = origstderr
85+
end
86+
end
7387
end

0 commit comments

Comments
 (0)