Skip to content

Commit e45ba88

Browse files
committed
Update tests
1 parent 9cde176 commit e45ba88

6 files changed

Lines changed: 113 additions & 0 deletions

File tree

tests/unit/anonymous-struct.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,16 @@ int main() {
5959
assert(o.inner_named.j == 10);
6060
assert(o.k == 11);
6161

62+
struct {
63+
int x;
64+
int z;
65+
} s;
66+
67+
s.x = 1;
68+
s.z = 2;
69+
70+
assert(s.x = 1);
71+
assert(s.z = 2);
72+
6273
return 0;
6374
}

tests/unit/anonymous-struct_c.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,16 @@ int main(void) {
5959
assert(o.inner_named.j == 10);
6060
assert(o.k == 11);
6161

62+
struct {
63+
int x;
64+
int z;
65+
} s;
66+
67+
s.x = 1;
68+
s.z = 2;
69+
70+
assert(s.x = 1);
71+
assert(s.z = 2);
72+
6273
return 0;
6374
}

tests/unit/out/refcount/anonymous-struct.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,35 @@ fn main_0() -> i32 {
197197
.borrow())
198198
== 11)
199199
);
200+
#[derive(Default)]
201+
pub struct anon_0 {
202+
pub x: Value<i32>,
203+
pub z: Value<i32>,
204+
}
205+
impl Clone for anon_0 {
206+
fn clone(&self) -> Self {
207+
let mut this = Self {
208+
x: Rc::new(RefCell::new((*self.x.borrow()))),
209+
z: Rc::new(RefCell::new((*self.z.borrow()))),
210+
};
211+
this
212+
}
213+
}
214+
impl ByteRepr for anon_0 {};
215+
let s: Value<anon_0> = Rc::new(RefCell::new(<anon_0>::default()));
216+
(*(*s.borrow()).x.borrow_mut()) = 1;
217+
(*(*s.borrow()).z.borrow_mut()) = 2;
218+
assert!(
219+
({
220+
(*(*s.borrow()).x.borrow_mut()) = 1;
221+
(*(*s.borrow()).x.borrow())
222+
} != 0)
223+
);
224+
assert!(
225+
({
226+
(*(*s.borrow()).z.borrow_mut()) = 2;
227+
(*(*s.borrow()).z.borrow())
228+
} != 0)
229+
);
200230
return 0;
201231
}

tests/unit/out/refcount/anonymous-struct_c.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,26 @@ fn main_0() -> i32 {
106106
.borrow())
107107
== 11)
108108
);
109+
#[derive(Default)]
110+
pub struct anon_0 {
111+
pub x: Value<i32>,
112+
pub z: Value<i32>,
113+
}
114+
impl ByteRepr for anon_0 {};
115+
let s: Value<anon_0> = <Value<anon_0>>::default();
116+
(*(*s.borrow()).x.borrow_mut()) = 1;
117+
(*(*s.borrow()).z.borrow_mut()) = 2;
118+
assert!(
119+
({
120+
(*(*s.borrow()).x.borrow_mut()) = 1;
121+
(*(*s.borrow()).x.borrow())
122+
} != 0)
123+
);
124+
assert!(
125+
({
126+
(*(*s.borrow()).z.borrow_mut()) = 2;
127+
(*(*s.borrow()).z.borrow())
128+
} != 0)
129+
);
109130
return 0;
110131
}

tests/unit/out/unsafe/anonymous-struct.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,25 @@ unsafe fn main_0() -> i32 {
8787
assert!(((o.anon_3.i) == (9)));
8888
assert!(((o.anon_3.inner_named.j) == (10)));
8989
assert!(((o.anon_3.anon_1.k) == (11)));
90+
#[derive(Copy, Clone, Default)]
91+
pub struct anon_0 {
92+
pub x: i32,
93+
pub z: i32,
94+
};
95+
let mut s: anon_0 = <anon_0>::default();
96+
s.x = 1;
97+
s.z = 2;
98+
assert!(
99+
({
100+
s.x = 1;
101+
s.x
102+
} != 0)
103+
);
104+
assert!(
105+
({
106+
s.z = 2;
107+
s.z
108+
} != 0)
109+
);
90110
return 0;
91111
}

tests/unit/out/unsafe/anonymous-struct_c.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,25 @@ unsafe fn main_0() -> i32 {
8383
assert!(((o.anon_3.i) == (9)));
8484
assert!(((o.anon_3.inner_named.j) == (10)));
8585
assert!(((o.anon_3.anon_1.k) == (11)));
86+
#[derive(Copy, Clone, Default)]
87+
pub struct anon_0 {
88+
pub x: i32,
89+
pub z: i32,
90+
};
91+
let mut s: anon_0 = <anon_0>::default();
92+
s.x = 1;
93+
s.z = 2;
94+
assert!(
95+
({
96+
s.x = 1;
97+
s.x
98+
} != 0)
99+
);
100+
assert!(
101+
({
102+
s.z = 2;
103+
s.z
104+
} != 0)
105+
);
86106
return 0;
87107
}

0 commit comments

Comments
 (0)