Skip to content

Commit e820147

Browse files
committed
Update tests
1 parent 0e672dc commit e820147

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,31 @@ impl Owner {
142142
}
143143
}
144144
}
145+
#[derive(Record, ByteRepr, VaArg, FnPtrArg, Default)]
146+
#[byte_size(4)]
147+
pub struct OutOfLine {
148+
#[offset(0)]
149+
pub v: i32,
150+
}
151+
impl OutOfLine {
152+
pub fn new(mut v: i32) -> Self {
153+
Self { v: v }
154+
}
155+
pub fn copy_from(o: Ptr<OutOfLine>) -> Self {
156+
let __this: OutOfLine = Self {
157+
v: (o.with(|__s| __s.v) + 100),
158+
};
159+
(*copies_0.with(Value::clone).borrow_mut()).prefix_inc();
160+
__this
161+
}
162+
}
163+
impl Clone for OutOfLine {
164+
fn clone(&self) -> Self {
165+
let __src: Value<OutOfLine> = Rc::new(RefCell::new(OutOfLine { v: self.v.clone() }));
166+
OutOfLine::copy_from(__src.as_pointer())
167+
}
168+
}
169+
impl OutOfLine {}
145170
pub fn by_value_1(mut c: Counted) -> i32 {
146171
return c.v;
147172
}
@@ -212,6 +237,10 @@ fn main_0() -> i32 {
212237
}));
213238
let mut o2: Owner = Owner::move_from({ o.as_pointer() });
214239
assert!((o2.box_.val == 3));
240+
let ol1: Value<OutOfLine> = Rc::new(RefCell::new(OutOfLine::new({ 5 })));
241+
let mut ol2: OutOfLine = OutOfLine::copy_from({ ol1.as_pointer() });
242+
assert!((ol2.v == 105));
243+
assert!((copies_0.with(|rc| *rc.borrow()) == 12));
215244
let n: Value<NonConst> = Rc::new(RefCell::new(NonConst::new()));
216245
let mut n1: NonConst = NonConst::new_1({ n.as_pointer() });
217246
let cn: Value<NonConst> = Rc::new(RefCell::new(NonConst::new()));

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,30 @@ impl Owner {
116116
this
117117
}
118118
}
119+
#[repr(C)]
120+
#[derive(VaArg, FnPtrArg, Default)]
121+
pub struct OutOfLine {
122+
pub v: i32,
123+
}
124+
impl OutOfLine {
125+
pub unsafe fn new(mut v: i32) -> Self {
126+
let mut this = Self { v: v };
127+
this
128+
}
129+
pub unsafe fn copy_from(o: *const OutOfLine) -> Self {
130+
let mut this = Self {
131+
v: (((*o).v) + (100)),
132+
};
133+
(*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc();
134+
this
135+
}
136+
}
137+
impl Clone for OutOfLine {
138+
fn clone(&self) -> Self {
139+
unsafe { OutOfLine::copy_from(self as *const OutOfLine) }
140+
}
141+
}
142+
impl OutOfLine {}
119143
pub unsafe fn by_value_1(mut c: Counted) -> i32 {
120144
return c.v;
121145
}
@@ -174,6 +198,10 @@ unsafe fn main_0() -> i32 {
174198
};
175199
let mut o2: Owner = Owner::move_from({ &mut o });
176200
assert!(((o2.box_.val) == (3)));
201+
let mut ol1: OutOfLine = OutOfLine::new({ 5 });
202+
let mut ol2: OutOfLine = OutOfLine::copy_from({ &ol1 });
203+
assert!(((ol2.v) == (105)));
204+
assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (12)));
177205
let mut n: NonConst = NonConst::new();
178206
let mut n1: NonConst = NonConst::new_1({ &mut n });
179207
let cn: NonConst = NonConst::new();

0 commit comments

Comments
 (0)