Skip to content

Commit ba3fd40

Browse files
committed
Update tests
1 parent 658b9ed commit ba3fd40

7 files changed

Lines changed: 16 additions & 17 deletions

File tree

tests/unit/out/refcount/fn_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
99
pub fn my_foo_0(p: AnyPtr) -> i32 {
1010
let p: Value<AnyPtr> = Rc::new(RefCell::new(p));
11-
return ((*p.borrow()).cast::<i32>().expect("ub:wrong type").read());
11+
return ((*p.borrow()).reinterpret_cast::<i32>().read());
1212
}
1313
pub fn foo_1(fn_: FnPtr<fn(AnyPtr) -> i32>, pi: Ptr<i32>) -> i32 {
1414
let fn_: Value<FnPtr<fn(AnyPtr) -> i32>> = Rc::new(RefCell::new(fn_));

tests/unit/out/refcount/fn_ptr_cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn add_offset_4(base: Ptr<i32>, offset: i32) -> i32 {
7676
pub fn test_call_through_cast_5() {
7777
let gfn: Value<FnPtr<fn(AnyPtr, i32) -> i32>> = Rc::new(RefCell::new(
7878
FnPtr::<fn(Ptr<i32>, i32) -> i32>::new(add_offset_4).cast::<fn(AnyPtr, i32) -> i32>(Some(
79-
(|a0: AnyPtr, a1: i32| -> i32 { add_offset_4(a0.cast::<i32>().unwrap(), a1) })
79+
(|a0: AnyPtr, a1: i32| -> i32 { add_offset_4(a0.reinterpret_cast::<i32>(), a1) })
8080
as fn(AnyPtr, i32) -> i32,
8181
)),
8282
));

tests/unit/out/refcount/fn_ptr_stdlib_compare.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ fn main_0() -> i32 {
4141
)
4242
.cast::<fn(Ptr<u8>, usize, usize, AnyPtr) -> usize>(Some(
4343
(|a0: Ptr<u8>, a1: usize, a2: usize, a3: AnyPtr| -> usize {
44-
libcc2rs::fread_refcount(a0.to_any(), a1, a2, a3.cast::<::std::fs::File>().unwrap())
44+
libcc2rs::fread_refcount(
45+
a0.to_any(),
46+
a1,
47+
a2,
48+
a3.reinterpret_cast::<::std::fs::File>(),
49+
)
4550
}) as fn(Ptr<u8>, usize, usize, AnyPtr) -> usize,
4651
)),
4752
));
@@ -56,7 +61,7 @@ fn main_0() -> i32 {
5661
FnPtr::<fn(Ptr<u8>, usize, usize, AnyPtr) -> usize>::new(my_alternative_fread_0)
5762
.cast::<fn(AnyPtr, usize, usize, Ptr<::std::fs::File>) -> usize>(Some(
5863
(|a0: AnyPtr, a1: usize, a2: usize, a3: Ptr<::std::fs::File>| -> usize {
59-
my_alternative_fread_0(a0.cast::<u8>().unwrap(), a1, a2, a3.to_any())
64+
my_alternative_fread_0(a0.reinterpret_cast::<u8>(), a1, a2, a3.to_any())
6065
}) as fn(AnyPtr, usize, usize, Ptr<::std::fs::File>) -> usize,
6166
)),
6267
));
@@ -195,7 +200,7 @@ fn main_0() -> i32 {
195200
a0.to_any(),
196201
a1,
197202
a2,
198-
a3.cast::<::std::fs::File>().unwrap(),
203+
a3.reinterpret_cast::<::std::fs::File>(),
199204
)
200205
}) as fn(Ptr<u8>, usize, usize, AnyPtr) -> usize,
201206
)),
@@ -211,7 +216,7 @@ fn main_0() -> i32 {
211216
FnPtr::<fn(Ptr<u8>, usize, usize, AnyPtr) -> usize>::new(my_alternative_fwrite_1)
212217
.cast::<fn(AnyPtr, usize, usize, Ptr<::std::fs::File>) -> usize>(Some(
213218
(|a0: AnyPtr, a1: usize, a2: usize, a3: Ptr<::std::fs::File>| -> usize {
214-
my_alternative_fwrite_1(a0.cast::<u8>().unwrap(), a1, a2, a3.to_any())
219+
my_alternative_fwrite_1(a0.reinterpret_cast::<u8>(), a1, a2, a3.to_any())
215220
}) as fn(AnyPtr, usize, usize, Ptr<::std::fs::File>) -> usize,
216221
)),
217222
));

tests/unit/out/refcount/fn_ptr_vtable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ pub fn int_create_1(val: i32) -> AnyPtr {
4242
}
4343
pub fn int_get_2(p: AnyPtr) -> i32 {
4444
let p: Value<AnyPtr> = Rc::new(RefCell::new(p));
45-
return ((*p.borrow()).cast::<i32>().expect("ub:wrong type").read());
45+
return ((*p.borrow()).reinterpret_cast::<i32>().read());
4646
}
4747
pub fn int_destroy_3(p: AnyPtr) {
4848
let p: Value<AnyPtr> = Rc::new(RefCell::new(p));
49-
(*p.borrow()).cast::<i32>().expect("ub:wrong type").write(0);
49+
(*p.borrow()).reinterpret_cast::<i32>().write(0);
5050
}
5151
pub fn main() {
5252
std::process::exit(main_0());

tests/unit/out/refcount/ptr_to_incomplete_struct.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ fn main_0() -> i32 {
1313
let fp: Value<Ptr<::std::fs::File>> = Rc::new(RefCell::new((libcc2rs::cout()).clone()));
1414
let p: Value<AnyPtr> = Rc::new(RefCell::new((*fp.borrow()).clone().to_any()));
1515
let fp2: Value<Ptr<::std::fs::File>> = Rc::new(RefCell::new(
16-
((*p.borrow())
17-
.cast::<::std::fs::File>()
18-
.expect("ub:wrong type"))
19-
.clone(),
16+
((*p.borrow()).reinterpret_cast::<::std::fs::File>()).clone(),
2017
));
2118
assert!(
2219
((({

tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ fn main_0() -> i32 {
102102
(((({
103103
dispatch_0(
104104
(opt::OPT_FILE as i32),
105-
&[((AnyPtr::default())
106-
.cast::<::std::fs::File>()
107-
.expect("ub:wrong type"))
108-
.into()],
105+
&[((AnyPtr::default()).reinterpret_cast::<::std::fs::File>()).into()],
109106
)
110107
}) == 0) as i32)
111108
!= 0)

tests/unit/out/refcount/z_bit_cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn main_0() -> i32 {
3030
_lhs == ((a1.as_pointer() as Ptr<u32>) as Ptr<u32>).to_any()
3131
});
3232
assert!({
33-
let _lhs = (((*ptr.borrow()).cast::<u32>().expect("ub:wrong type"))
33+
let _lhs = (((*ptr.borrow()).reinterpret_cast::<u32>())
3434
.offset((0) as isize)
3535
.read());
3636
_lhs == (*a1.borrow())[(0) as usize]

0 commit comments

Comments
 (0)