Skip to content

Commit 93b2e11

Browse files
committed
Move declare_class! test
1 parent 5e705a7 commit 93b2e11

File tree

2 files changed

+56
-47
lines changed

2 files changed

+56
-47
lines changed

crates/objc2/src/declare/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@
115115
//! assert_eq!(n, 12);
116116
//! ```
117117
118-
#[cfg(test)]
119-
mod declare_class_tests;
120118
mod ivar;
121119
mod ivar_bool;
122120
mod ivar_drop;

crates/objc2/src/declare/declare_class_tests.rs renamed to crates/objc2/tests/declare_class.rs

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#![deny(deprecated, unreachable_code)]
22
use core::ptr;
33

4-
use crate::declare::IvarEncode;
5-
use crate::mutability::{Immutable, Mutable};
6-
use crate::rc::Id;
7-
use crate::runtime::NSObject;
8-
use crate::{declare_class, extern_methods, sel, ClassType};
4+
use objc2::declare::IvarEncode;
5+
use objc2::mutability::{Immutable, Mutable};
6+
use objc2::rc::Id;
7+
use objc2::runtime::NSObject;
8+
use objc2::{declare_class, extern_methods, sel, ClassType};
99

1010
// Test that adding the `deprecated` attribute does not mean that warnings
1111
// when using the method internally are output.
@@ -478,52 +478,63 @@ declare_class!(
478478
}
479479
);
480480

481-
#[cfg(all(target_pointer_width = "64", not(feature = "catch-all")))]
482-
mod out_param {
483-
use super::*;
484-
485-
extern_methods!(
486-
unsafe impl OutParam {
487-
#[method_id(new)]
488-
fn new() -> Id<Self>;
489-
490-
#[method(unsupported1:)]
491-
fn unsupported1(_param: &mut Id<Self>);
481+
extern_methods!(
482+
unsafe impl OutParam {
483+
#[method_id(new)]
484+
fn new() -> Id<Self>;
492485

493-
#[method(unsupported2:)]
494-
fn unsupported2(_param: Option<&mut Id<Self>>);
486+
#[method(unsupported1:)]
487+
fn unsupported1(_param: &mut Id<Self>);
495488

496-
#[method(unsupported3:)]
497-
fn unsupported3(_param: &mut Option<Id<Self>>);
489+
#[method(unsupported2:)]
490+
fn unsupported2(_param: Option<&mut Id<Self>>);
498491

499-
#[method(unsupported4:)]
500-
fn unsupported4(_param: Option<&mut Option<Id<Self>>>);
501-
}
502-
);
492+
#[method(unsupported3:)]
493+
fn unsupported3(_param: &mut Option<Id<Self>>);
503494

504-
#[test]
505-
#[should_panic = "`&mut Id<_>` is not supported in `declare_class!` yet"]
506-
fn out_param1() {
507-
let mut param = OutParam::new();
508-
OutParam::unsupported1(&mut param);
495+
#[method(unsupported4:)]
496+
fn unsupported4(_param: Option<&mut Option<Id<Self>>>);
509497
}
498+
);
510499

511-
#[test]
512-
#[should_panic = "`Option<&mut Id<_>>` is not supported in `declare_class!` yet"]
513-
fn out_param2() {
514-
OutParam::unsupported2(None);
515-
}
500+
#[test]
501+
#[should_panic = "`&mut Id<_>` is not supported in `declare_class!` yet"]
502+
#[cfg_attr(
503+
not(all(target_pointer_width = "64", not(feature = "catch-all"))),
504+
ignore = "unwinds through FFI boundary"
505+
)]
506+
fn out_param1() {
507+
let mut param = OutParam::new();
508+
OutParam::unsupported1(&mut param);
509+
}
516510

517-
#[test]
518-
#[should_panic = "`&mut Option<Id<_>>` is not supported in `declare_class!` yet"]
519-
fn out_param3() {
520-
let mut param = Some(OutParam::new());
521-
OutParam::unsupported3(&mut param);
522-
}
511+
#[test]
512+
#[should_panic = "`Option<&mut Id<_>>` is not supported in `declare_class!` yet"]
513+
#[cfg_attr(
514+
not(all(target_pointer_width = "64", not(feature = "catch-all"))),
515+
ignore = "unwinds through FFI boundary"
516+
)]
517+
fn out_param2() {
518+
OutParam::unsupported2(None);
519+
}
523520

524-
#[test]
525-
#[should_panic = "`Option<&mut Option<Id<_>>>` is not supported in `declare_class!` yet"]
526-
fn out_param4() {
527-
OutParam::unsupported4(None);
528-
}
521+
#[test]
522+
#[should_panic = "`&mut Option<Id<_>>` is not supported in `declare_class!` yet"]
523+
#[cfg_attr(
524+
not(all(target_pointer_width = "64", not(feature = "catch-all"))),
525+
ignore = "unwinds through FFI boundary"
526+
)]
527+
fn out_param3() {
528+
let mut param = Some(OutParam::new());
529+
OutParam::unsupported3(&mut param);
530+
}
531+
532+
#[test]
533+
#[should_panic = "`Option<&mut Option<Id<_>>>` is not supported in `declare_class!` yet"]
534+
#[cfg_attr(
535+
not(all(target_pointer_width = "64", not(feature = "catch-all"))),
536+
ignore = "unwinds through FFI boundary"
537+
)]
538+
fn out_param4() {
539+
OutParam::unsupported4(None);
529540
}

0 commit comments

Comments
 (0)