Skip to content

Commit 14f5689

Browse files
committed
Update tests
1 parent dc08fe1 commit 14f5689

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ pub fn by_global_ref_7(b: Option<Ptr<Bar>>) -> i32 {
5757
let b: Ptr<Bar> = b.unwrap_or_else(|| global_bar_6.with(|v| v.as_pointer()));
5858
return b.with(|__s| __s.v);
5959
}
60+
pub fn shifted_8(mut x: i32, y: Option<i32>) -> i32 {
61+
let mut y: i32 = y.unwrap_or_else(|| -1_i32);
62+
return (x + y);
63+
}
64+
pub fn first_9(r: Ptr<i32>) -> i32 {
65+
return (elem!((r), 0).read());
66+
}
6067
#[derive(Clone, Record, ByteRepr, VaArg, FnPtrArg, Default)]
6168
#[byte_size(4)]
6269
pub struct Holder_int_ {
@@ -111,6 +118,14 @@ fn main_0() -> i32 {
111118
);
112119
let mut h: Holder_int_ = Holder_int_::new({ 4 });
113120
assert!((h.v == 4));
121+
assert!((({ shifted_8(3, None,) }) == 2));
122+
assert!((({ shifted_8(3, Some(4),) }) == 7));
123+
assert!(
124+
(({
125+
let _r: Value<Box<[i32]>> = Rc::new(RefCell::new(Box::new([4, 5, 6])));
126+
first_9(_r.as_pointer())
127+
}) == 4)
128+
);
114129
return 0;
115130
}
116131
pub fn __cpp2rust_init_globals() {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ pub unsafe fn by_global_ref_7(b: Option<*const Bar>) -> i32 {
5353
});
5454
return (*b).v;
5555
}
56+
pub unsafe fn shifted_8(mut x: i32, mut y: Option<i32>) -> i32 {
57+
let mut y: i32 = y.unwrap_or_else(|| unsafe { -1_i32 });
58+
return ((x) + (y));
59+
}
60+
pub unsafe fn first_9(r: *mut [i32; 3]) -> i32 {
61+
return (*r)[(0) as usize];
62+
}
5663
#[repr(C)]
5764
#[derive(Copy, Clone, VaArg, FnPtrArg, Default)]
5865
pub struct Holder_int_ {
@@ -109,6 +116,14 @@ unsafe fn main_0() -> i32 {
109116
);
110117
let mut h: Holder_int_ = Holder_int_::new({ 4 });
111118
assert!(((h.v) == (4)));
119+
assert!(((unsafe { shifted_8(3, None,) }) == (2)));
120+
assert!(((unsafe { shifted_8(3, Some(4),) }) == (7)));
121+
assert!(
122+
((unsafe {
123+
let mut _r: [i32; 3] = [4, 5, 6];
124+
first_9(&mut _r)
125+
}) == (4))
126+
);
112127
return 0;
113128
}
114129
pub unsafe fn __cpp2rust_init_globals() {

0 commit comments

Comments
 (0)