Skip to content

Commit edba359

Browse files
committed
Update tests
1 parent b4476f9 commit edba359

11 files changed

Lines changed: 48 additions & 60 deletions

‎tests/unit/out/refcount/10_struct.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl ByteRepr for Graph {
6666
}
6767
}
6868
}
69-
#[derive(Default)]
69+
#[derive()]
7070
pub struct Partial {
7171
pub p: Value<Ptr<i32>>,
7272
}
@@ -89,6 +89,13 @@ impl Clone for Partial {
8989
Rc::try_unwrap(__this).ok().unwrap().into_inner()
9090
}
9191
}
92+
impl Default for Partial {
93+
fn default() -> Self {
94+
Partial {
95+
p: Rc::new(RefCell::new(Ptr::<i32>::null())),
96+
}
97+
}
98+
}
9299
impl ByteRepr for Partial {
93100
fn byte_size() -> usize {
94101
8

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ impl Clone for Explicit {
6868
impl Default for Explicit {
6969
fn default() -> Self {
7070
Explicit {
71-
v: <Value<i32>>::default(),
71+
v: Rc::new(RefCell::new(0_i32)),
7272
inner: <Value<Inner>>::default(),
73-
arr: Rc::new(RefCell::new(
74-
(0..2).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
75-
)),
73+
arr: Rc::new(RefCell::new((0..2).map(|_| 0_i32).collect::<Box<[i32]>>())),
7674
}
7775
}
7876
}
@@ -115,11 +113,9 @@ impl Clone for Implicit {
115113
impl Default for Implicit {
116114
fn default() -> Self {
117115
Implicit {
118-
v: <Value<i32>>::default(),
116+
v: Rc::new(RefCell::new(0_i32)),
119117
inner: <Value<Inner>>::default(),
120-
arr: Rc::new(RefCell::new(
121-
(0..2).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
122-
)),
118+
arr: Rc::new(RefCell::new((0..2).map(|_| 0_i32).collect::<Box<[i32]>>())),
123119
}
124120
}
125121
}
@@ -283,10 +279,8 @@ impl Default for Buffer {
283279
Buffer {
284280
data: Rc::new(RefCell::new(Default::default())),
285281
rows: Rc::new(RefCell::new(Vec::new())),
286-
n: <Value<i32>>::default(),
287-
arr: Rc::new(RefCell::new(
288-
(0..2).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
289-
)),
282+
n: Rc::new(RefCell::new(0_i32)),
283+
arr: Rc::new(RefCell::new((0..2).map(|_| 0_i32).collect::<Box<[i32]>>())),
290284
}
291285
}
292286
}
@@ -340,10 +334,8 @@ impl Default for Owner {
340334
fn default() -> Self {
341335
Owner {
342336
data: Rc::new(RefCell::new(Default::default())),
343-
n: <Value<i32>>::default(),
344-
arr: Rc::new(RefCell::new(
345-
(0..2).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
346-
)),
337+
n: Rc::new(RefCell::new(0_i32)),
338+
arr: Rc::new(RefCell::new((0..2).map(|_| 0_i32).collect::<Box<[i32]>>())),
347339
p: Rc::new(RefCell::new(None)),
348340
}
349341
}

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ fn main_0() -> i32 {
6565
},
6666
));
6767
assert!(!((*stream.borrow()).is_null()));
68-
let buf: Value<Box<[u8]>> = Rc::new(RefCell::new(
69-
(0..16).map(|_| <u8>::default()).collect::<Box<[u8]>>(),
70-
));
68+
let buf: Value<Box<[u8]>> =
69+
Rc::new(RefCell::new((0..16).map(|_| 0_u8).collect::<Box<[u8]>>()));
7170
{
7271
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any().memset(
7372
(('X' as u8) as i32) as u8,
@@ -112,9 +111,8 @@ fn main_0() -> i32 {
112111
},
113112
));
114113
assert!(!((*stream.borrow()).is_null()));
115-
let buf: Value<Box<[u8]>> = Rc::new(RefCell::new(
116-
(0..16).map(|_| <u8>::default()).collect::<Box<[u8]>>(),
117-
));
114+
let buf: Value<Box<[u8]>> =
115+
Rc::new(RefCell::new((0..16).map(|_| 0_u8).collect::<Box<[u8]>>()));
118116
{
119117
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any().memset(
120118
(('X' as u8) as i32) as u8,
@@ -188,9 +186,8 @@ fn main_0() -> i32 {
188186
},
189187
));
190188
assert!(!((*stream.borrow()).is_null()));
191-
let buf: Value<Box<[u8]>> = Rc::new(RefCell::new(
192-
(0..10).map(|_| <u8>::default()).collect::<Box<[u8]>>(),
193-
));
189+
let buf: Value<Box<[u8]>> =
190+
Rc::new(RefCell::new((0..10).map(|_| 0_u8).collect::<Box<[u8]>>()));
194191
{
195192
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any().memset(
196193
(('Y' as u8) as i32) as u8,
@@ -225,9 +222,8 @@ fn main_0() -> i32 {
225222
},
226223
));
227224
assert!(!((*stream.borrow()).is_null()));
228-
let buf: Value<Box<[u8]>> = Rc::new(RefCell::new(
229-
(0..10).map(|_| <u8>::default()).collect::<Box<[u8]>>(),
230-
));
225+
let buf: Value<Box<[u8]>> =
226+
Rc::new(RefCell::new((0..10).map(|_| 0_u8).collect::<Box<[u8]>>()));
231227
{
232228
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any().memset(
233229
(('Y' as u8) as i32) as u8,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Clone for Handler {
2424
impl Default for Handler {
2525
fn default() -> Self {
2626
Handler {
27-
tag: <Value<i32>>::default(),
27+
tag: Rc::new(RefCell::new(0_i32)),
2828
cb: Rc::new(RefCell::new(FnPtr::<fn(i32) -> i32>::null())),
2929
}
3030
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl ByteRepr for Vtable {
5454
}
5555
}
5656
thread_local!(
57-
pub static storage_0: Value<i32> = <Value<i32>>::default();
57+
pub static storage_0: Value<i32> = Rc::new(RefCell::new(0_i32));
5858
);
5959
pub fn int_create_1(val: i32) -> AnyPtr {
6060
let val: Value<i32> = Rc::new(RefCell::new(val));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub struct Boxed_int_ {
101101
pub tag: Value<i32>,
102102
}
103103
impl Boxed_int_ {
104-
pub fn Boxed_int_(x: i32, t: i32) -> Self {
104+
pub fn new(x: i32, t: i32) -> Self {
105105
let x: Value<i32> = Rc::new(RefCell::new(x));
106106
let t: Value<i32> = Rc::new(RefCell::new(t));
107107
let __this: Value<Boxed_int_> = Rc::new(RefCell::new(Self {
@@ -157,7 +157,7 @@ fn main_0() -> i32 {
157157
assert!(((*(*(*s.borrow()).c.borrow()).y.borrow()) == 4));
158158
assert!(((*(*(*s.borrow()).d.borrow()).x.borrow()) == 3));
159159
assert!(((*(*(*s.borrow()).d.borrow()).y.borrow()) == 4));
160-
let boxed: Value<Boxed_int_> = Rc::new(RefCell::new(Boxed_int_::Boxed_int_({ 5 }, { 9 })));
160+
let boxed: Value<Boxed_int_> = Rc::new(RefCell::new(Boxed_int_::new({ 5 }, { 9 })));
161161
assert!(((*(*boxed.borrow()).v.borrow()) == 5));
162162
assert!(((*(*boxed.borrow()).tag.borrow()) == 9));
163163
return 0;

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ impl Buffer {
2424
pub fn new(size: i32) -> Self {
2525
let size: Value<i32> = Rc::new(RefCell::new(size));
2626
let __this: Value<Buffer> = Rc::new(RefCell::new(Self {
27-
data: Rc::new(RefCell::new(
28-
(0..4).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
29-
)),
27+
data: Rc::new(RefCell::new((0..4).map(|_| 0_i32).collect::<Box<[i32]>>())),
3028
size: Rc::new(RefCell::new((*size.borrow()))),
3129
}));
3230
let this: Ptr<Buffer> = __this.as_pointer();
@@ -45,9 +43,7 @@ impl Buffer {
4543
}
4644
pub fn Buffer_pconstBuffer(o: Ptr<Buffer>) -> Self {
4745
let __this: Value<Buffer> = Rc::new(RefCell::new(Self {
48-
data: Rc::new(RefCell::new(
49-
(0..4).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
50-
)),
46+
data: Rc::new(RefCell::new((0..4).map(|_| 0_i32).collect::<Box<[i32]>>())),
5147
size: Rc::new(RefCell::new((*(*o.upgrade().deref()).size.borrow()))),
5248
}));
5349
let this: Ptr<Buffer> = __this.as_pointer();
@@ -63,9 +59,7 @@ impl Buffer {
6359
}
6460
pub fn Buffer_pmutBuffer_rv(o: Ptr<Buffer>) -> Self {
6561
let __this: Value<Buffer> = Rc::new(RefCell::new(Self {
66-
data: Rc::new(RefCell::new(
67-
(0..4).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
68-
)),
62+
data: Rc::new(RefCell::new((0..4).map(|_| 0_i32).collect::<Box<[i32]>>())),
6963
size: Rc::new(RefCell::new((*(*o.upgrade().deref()).size.borrow()))),
7064
}));
7165
let this: Ptr<Buffer> = __this.as_pointer();
@@ -94,10 +88,8 @@ impl Clone for Buffer {
9488
impl Default for Buffer {
9589
fn default() -> Self {
9690
Buffer {
97-
data: Rc::new(RefCell::new(
98-
(0..4).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
99-
)),
100-
size: <Value<i32>>::default(),
91+
data: Rc::new(RefCell::new((0..4).map(|_| 0_i32).collect::<Box<[i32]>>())),
92+
size: Rc::new(RefCell::new(0_i32)),
10193
}
10294
}
10395
}

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ impl Buffer {
2121
pub fn new(size: i32) -> Self {
2222
let size: Value<i32> = Rc::new(RefCell::new(size));
2323
let __this: Value<Buffer> = Rc::new(RefCell::new(Self {
24-
data: Rc::new(RefCell::new(
25-
(0..4).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
26-
)),
24+
data: Rc::new(RefCell::new((0..4).map(|_| 0_i32).collect::<Box<[i32]>>())),
2725
size: Rc::new(RefCell::new((*size.borrow()))),
2826
}));
2927
let this: Ptr<Buffer> = __this.as_pointer();
@@ -42,9 +40,7 @@ impl Buffer {
4240
}
4341
pub fn Buffer_pconstBuffer(o: Ptr<Buffer>) -> Self {
4442
let __this: Value<Buffer> = Rc::new(RefCell::new(Self {
45-
data: Rc::new(RefCell::new(
46-
(0..4).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
47-
)),
43+
data: Rc::new(RefCell::new((0..4).map(|_| 0_i32).collect::<Box<[i32]>>())),
4844
size: Rc::new(RefCell::new((*(*o.upgrade().deref()).size.borrow()))),
4945
}));
5046
let this: Ptr<Buffer> = __this.as_pointer();
@@ -71,10 +67,8 @@ impl Clone for Buffer {
7167
impl Default for Buffer {
7268
fn default() -> Self {
7369
Buffer {
74-
data: Rc::new(RefCell::new(
75-
(0..4).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
76-
)),
77-
size: <Value<i32>>::default(),
70+
data: Rc::new(RefCell::new((0..4).map(|_| 0_i32).collect::<Box<[i32]>>())),
71+
size: Rc::new(RefCell::new(0_i32)),
7872
}
7973
}
8074
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Default for label {
2626
label {
2727
name: Rc::new(RefCell::new(Ptr::<u8>::null())),
2828
probe: Rc::new(RefCell::new(FnPtr::<fn() -> i32>::null())),
29-
mask: <Value<i32>>::default(),
29+
mask: Rc::new(RefCell::new(0_i32)),
3030
}
3131
}
3232
}

‎tests/unit/out/unsafe/10_struct.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl Graph {
3131
}
3232
}
3333
#[repr(C)]
34-
#[derive(Copy, Clone, Default)]
34+
#[derive(Copy, Clone)]
3535
pub struct Partial {
3636
pub p: *mut i32,
3737
}
@@ -41,6 +41,13 @@ impl Partial {
4141
this
4242
}
4343
}
44+
impl Default for Partial {
45+
fn default() -> Self {
46+
Partial {
47+
p: std::ptr::null_mut(),
48+
}
49+
}
50+
}
4451
#[repr(C)]
4552
#[derive(Copy, Clone, Default)]
4653
pub struct Declared {}

0 commit comments

Comments
 (0)