Skip to content

Commit 417eb40

Browse files
committed
Update tests
1 parent e1e9b75 commit 417eb40

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

‎tests/unit/out/refcount/class_template_lazy_member.rs‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ pub struct Box_Point_ {
2525
#[byte_size(4)]
2626
pub val: Point,
2727
}
28+
#[derive(Clone, Record, ByteRepr, VaArg, FnPtrArg, Default)]
29+
#[byte_size(4)]
30+
pub struct Deduced_int_ {
31+
#[offset(0)]
32+
pub val: i32,
33+
}
34+
#[derive(Clone, Record, ByteRepr, VaArg, FnPtrArg, Default)]
35+
#[byte_size(4)]
36+
pub struct Deduced_Point_ {
37+
#[offset(0)]
38+
#[byte_size(4)]
39+
pub val: Point,
40+
}
2841
pub fn main() {
2942
__cpp2rust_init_globals();
3043
std::process::exit(main_0());
@@ -36,6 +49,12 @@ fn main_0() -> i32 {
3649
val: Point { x: 4 },
3750
}));
3851
assert!(({ ({ Box_Point_Impl::get(&p.as_pointer(),) }).x } == 4));
52+
let d: Value<Deduced_int_> = Rc::new(RefCell::new(Deduced_int_ { val: 5 }));
53+
assert!((({ Deduced_int_Impl::twice(&d.as_pointer(),) }) == 10));
54+
let dp: Value<Deduced_Point_> = Rc::new(RefCell::new(Deduced_Point_ {
55+
val: Point { x: 6 },
56+
}));
57+
assert!(({ ({ Deduced_Point_Impl::get(&dp.as_pointer(),) }).x } == 6));
3958
return 0;
4059
}
4160
pub trait Box_Point_Impl {
@@ -60,4 +79,20 @@ impl Box_int_Impl for Ptr<Box_int_> {
6079
return ((*self).with(|__s| __s.val) + (*self).with(|__s| __s.val));
6180
}
6281
}
82+
pub trait Deduced_Point_Impl {
83+
fn get(&self) -> Point;
84+
}
85+
impl Deduced_Point_Impl for Ptr<Deduced_Point_> {
86+
fn get(&self) -> Point {
87+
return (*self).with(|__s| __s.val.clone());
88+
}
89+
}
90+
pub trait Deduced_int_Impl {
91+
fn twice(&self) -> i32;
92+
}
93+
impl Deduced_int_Impl for Ptr<Deduced_int_> {
94+
fn twice(&self) -> i32 {
95+
return ((*self).with(|__s| __s.val) + (*self).with(|__s| __s.val));
96+
}
97+
}
6398
pub fn __cpp2rust_init_globals() {}

‎tests/unit/out/unsafe/class_template_lazy_member.rs‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ impl Box_Point_ {
3131
return self.val;
3232
}
3333
}
34+
#[repr(C)]
35+
#[derive(Copy, Clone, VaArg, FnPtrArg, Default)]
36+
pub struct Deduced_int_ {
37+
pub val: i32,
38+
}
39+
impl Deduced_int_ {
40+
pub unsafe fn twice(&mut self) -> i32 {
41+
return ((self.val) + (self.val));
42+
}
43+
}
44+
#[repr(C)]
45+
#[derive(Copy, Clone, VaArg, FnPtrArg, Default)]
46+
pub struct Deduced_Point_ {
47+
pub val: Point,
48+
}
49+
impl Deduced_Point_ {
50+
pub unsafe fn get(&mut self) -> Point {
51+
return self.val;
52+
}
53+
}
3454
pub fn main() {
3555
unsafe {
3656
__cpp2rust_init_globals();
@@ -44,6 +64,12 @@ unsafe fn main_0() -> i32 {
4464
val: Point { x: 4 },
4565
};
4666
assert!((((unsafe { Box_Point_::get(&mut p,) }).x) == (4)));
67+
let mut d: Deduced_int_ = Deduced_int_ { val: 5 };
68+
assert!(((unsafe { Deduced_int_::twice(&mut d,) }) == (10)));
69+
let mut dp: Deduced_Point_ = Deduced_Point_ {
70+
val: Point { x: 6 },
71+
};
72+
assert!((((unsafe { Deduced_Point_::get(&mut dp,) }).x) == (6)));
4773
return 0;
4874
}
4975
pub unsafe fn __cpp2rust_init_globals() {}

0 commit comments

Comments
 (0)