File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,16 @@ def to_proc
8181 end
8282 end
8383
84+ class RawToProc
85+ def initialize ( to_proc )
86+ @to_proc = to_proc
87+ end
88+
89+ def to_proc
90+ @to_proc
91+ end
92+ end
93+
8494 class ToAry
8595 def initialize ( obj )
8696 @obj = obj
Original file line number Diff line number Diff line change 106106 specs . yield_now ( &o ) . should == :from_to_proc
107107 end
108108
109+ ruby_version_is "3.5" do
110+ it "raises TypeError if 'to_proc' doesn't return a Proc" do
111+ o = LangSendSpecs ::RawToProc . new ( 42 )
112+
113+ -> {
114+ specs . makeproc ( &o )
115+ } . should raise_error ( TypeError , "can't convert LangSendSpecs::RawToProc to Proc (LangSendSpecs::RawToProc#to_proc gives Integer)" )
116+ end
117+
118+ it "raises TypeError if block object isn't a Proc and doesn't respond to `to_proc`" do
119+ o = Object . new
120+
121+ -> {
122+ specs . makeproc ( &o )
123+ } . should raise_error ( TypeError , "no implicit conversion of Object into Proc" )
124+ end
125+ end
126+
109127 it "raises a SyntaxError with both a literal block and an object as block" do
110128 -> {
111129 eval "specs.oneb(10, &l){ 42 }"
You can’t perform that action at this time.
0 commit comments