File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -298,8 +298,10 @@ pub unsafe fn catch<R>(
298
298
mod tests {
299
299
use alloc:: format;
300
300
use alloc:: string:: ToString ;
301
+ use core:: panic:: AssertUnwindSafe ;
301
302
302
303
use super :: * ;
304
+ use crate :: msg_send_id;
303
305
use crate :: runtime:: NSObject ;
304
306
305
307
#[ test]
@@ -332,6 +334,27 @@ mod tests {
332
334
assert ! ( result. unwrap_err( ) . is_none( ) ) ;
333
335
}
334
336
337
+ #[ test]
338
+ #[ cfg_attr(
339
+ feature = "catch-all" ,
340
+ ignore = "Panics inside `catch` when catch-all is enabled"
341
+ ) ]
342
+ fn test_catch_unknown_selector ( ) {
343
+ let obj = AssertUnwindSafe ( NSObject :: new ( ) ) ;
344
+ let ptr = Id :: as_ptr ( & obj) ;
345
+ let result = unsafe {
346
+ catch ( || {
347
+ let _: Id < NSObject > = msg_send_id ! [ & * obj, copy] ;
348
+ } )
349
+ } ;
350
+ let err = result. unwrap_err ( ) . unwrap ( ) ;
351
+
352
+ assert_eq ! (
353
+ format!( "{err}" ) ,
354
+ format!( "-[NSObject copyWithZone:]: unrecognized selector sent to instance {ptr:?}" ) ,
355
+ ) ;
356
+ }
357
+
335
358
#[ test]
336
359
fn test_throw_catch_object ( ) {
337
360
let obj = NSObject :: new ( ) ;
You can’t perform that action at this time.
0 commit comments