Skip to content

Commit cd3ac04

Browse files
committed
Update tests
1 parent 864405b commit cd3ac04

2 files changed

Lines changed: 74 additions & 60 deletions

File tree

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

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ pub struct X {
1515
impl std::cmp::Ord for X {
1616
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
1717
{
18-
if operator_lt_0(self.clone(), other.clone()) {
18+
if ((operator_lt_0(self.clone(), other.clone())) != 0) {
1919
std::cmp::Ordering::Less
20-
} else if operator_lt_0(other.clone(), self.clone()) {
20+
} else if ((operator_lt_0(other.clone(), self.clone())) != 0) {
2121
std::cmp::Ordering::Greater
2222
} else {
2323
std::cmp::Ordering::Equal
@@ -32,7 +32,7 @@ impl std::cmp::PartialOrd for X {
3232
}
3333
impl std::cmp::PartialEq for X {
3434
fn eq(&self, other: &Self) -> bool {
35-
{ operator_eq_1(self.clone(), other.clone()) }
35+
{ ((operator_eq_1(self.clone(), other.clone())) != 0) }
3636
}
3737
}
3838
impl std::cmp::Eq for X {}
@@ -66,32 +66,6 @@ pub struct Custom {
6666
#[offset(0)]
6767
pub v: i32,
6868
}
69-
impl std::cmp::Ord for Custom {
70-
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
71-
{
72-
CustomImpl::operator_cmp(
73-
&Rc::new(RefCell::new(Custom { v: self.v.clone() })).as_pointer(),
74-
Rc::new(RefCell::new(Custom { v: other.v.clone() })).as_pointer(),
75-
)
76-
}
77-
}
78-
}
79-
impl std::cmp::PartialOrd for Custom {
80-
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
81-
Some(self.cmp(other))
82-
}
83-
}
84-
impl std::cmp::PartialEq for Custom {
85-
fn eq(&self, other: &Self) -> bool {
86-
{
87-
CustomImpl::operator_cmp(
88-
&Rc::new(RefCell::new(Custom { v: self.v.clone() })).as_pointer(),
89-
Rc::new(RefCell::new(Custom { v: other.v.clone() })).as_pointer(),
90-
) == std::cmp::Ordering::Equal
91-
}
92-
}
93-
}
94-
impl std::cmp::Eq for Custom {}
9569
#[derive(Clone, Record, ByteRepr, VaArg, FnPtrArg, Default)]
9670
#[byte_size(4)]
9771
pub struct Mixed {
@@ -101,10 +75,21 @@ pub struct Mixed {
10175
impl std::cmp::Ord for Mixed {
10276
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
10377
{
104-
MixedImpl::operator_cmp(
78+
if ((MixedImpl::operator_lt(
10579
&Rc::new(RefCell::new(Mixed { v: self.v.clone() })).as_pointer(),
10680
Rc::new(RefCell::new(Mixed { v: other.v.clone() })).as_pointer(),
107-
)
81+
)) != 0)
82+
{
83+
std::cmp::Ordering::Less
84+
} else if ((MixedImpl::operator_lt(
85+
&Rc::new(RefCell::new(Mixed { v: other.v.clone() })).as_pointer(),
86+
Rc::new(RefCell::new(Mixed { v: self.v.clone() })).as_pointer(),
87+
)) != 0)
88+
{
89+
std::cmp::Ordering::Greater
90+
} else {
91+
std::cmp::Ordering::Equal
92+
}
10893
}
10994
}
11095
}
@@ -116,10 +101,10 @@ impl std::cmp::PartialOrd for Mixed {
116101
impl std::cmp::PartialEq for Mixed {
117102
fn eq(&self, other: &Self) -> bool {
118103
{
119-
MixedImpl::operator_eq(
104+
((MixedImpl::operator_eq(
120105
&Rc::new(RefCell::new(Mixed { v: self.v.clone() })).as_pointer(),
121106
Rc::new(RefCell::new(Mixed { v: other.v.clone() })).as_pointer(),
122-
)
107+
)) != 0)
123108
}
124109
}
125110
}
@@ -144,9 +129,25 @@ pub struct Boolish {
144129
impl std::cmp::Ord for Boolish {
145130
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
146131
{
147-
if operator_lt_6(self.clone(), other.clone()) {
132+
if {
133+
let __cmp = &operator_lt_6(self.clone(), other.clone());
134+
MyBoolImpl::to_bool(
135+
&Rc::new(RefCell::new(MyBool {
136+
value: __cmp.value.clone(),
137+
}))
138+
.as_pointer(),
139+
)
140+
} {
148141
std::cmp::Ordering::Less
149-
} else if operator_lt_6(other.clone(), self.clone()) {
142+
} else if {
143+
let __cmp = &operator_lt_6(other.clone(), self.clone());
144+
MyBoolImpl::to_bool(
145+
&Rc::new(RefCell::new(MyBool {
146+
value: __cmp.value.clone(),
147+
}))
148+
.as_pointer(),
149+
)
150+
} {
150151
std::cmp::Ordering::Greater
151152
} else {
152153
std::cmp::Ordering::Equal
@@ -161,7 +162,17 @@ impl std::cmp::PartialOrd for Boolish {
161162
}
162163
impl std::cmp::PartialEq for Boolish {
163164
fn eq(&self, other: &Self) -> bool {
164-
{ operator_eq_7(self.clone(), other.clone()) }
165+
{
166+
{
167+
let __cmp = &operator_eq_7(self.clone(), other.clone());
168+
MyBoolImpl::to_bool(
169+
&Rc::new(RefCell::new(MyBool {
170+
value: __cmp.value.clone(),
171+
}))
172+
.as_pointer(),
173+
)
174+
}
175+
}
165176
}
166177
}
167178
impl std::cmp::Eq for Boolish {}

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

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ pub struct X {
1414
impl std::cmp::Ord for X {
1515
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
1616
unsafe {
17-
if operator_lt_0(self.clone(), other.clone()) {
17+
if ((operator_lt_0(self.clone(), other.clone())) != 0) {
1818
std::cmp::Ordering::Less
19-
} else if operator_lt_0(other.clone(), self.clone()) {
19+
} else if ((operator_lt_0(other.clone(), self.clone())) != 0) {
2020
std::cmp::Ordering::Greater
2121
} else {
2222
std::cmp::Ordering::Equal
@@ -31,7 +31,7 @@ impl std::cmp::PartialOrd for X {
3131
}
3232
impl std::cmp::PartialEq for X {
3333
fn eq(&self, other: &Self) -> bool {
34-
unsafe { operator_eq_1(self.clone(), other.clone()) }
34+
unsafe { ((operator_eq_1(self.clone(), other.clone())) != 0) }
3535
}
3636
}
3737
impl std::cmp::Eq for X {}
@@ -70,22 +70,6 @@ impl Custom {
7070
};
7171
}
7272
}
73-
impl std::cmp::Ord for Custom {
74-
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
75-
unsafe { Custom::operator_cmp(self, other as *const Custom) }
76-
}
77-
}
78-
impl std::cmp::PartialOrd for Custom {
79-
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
80-
Some(self.cmp(other))
81-
}
82-
}
83-
impl std::cmp::PartialEq for Custom {
84-
fn eq(&self, other: &Self) -> bool {
85-
unsafe { Custom::operator_cmp(self, other as *const Custom) == std::cmp::Ordering::Equal }
86-
}
87-
}
88-
impl std::cmp::Eq for Custom {}
8973
#[repr(C)]
9074
#[derive(Copy, Clone, VaArg, FnPtrArg, Default)]
9175
pub struct Mixed {
@@ -106,7 +90,15 @@ impl Mixed {
10690
}
10791
impl std::cmp::Ord for Mixed {
10892
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
109-
unsafe { Mixed::operator_cmp(self, other as *const Mixed) }
93+
unsafe {
94+
if ((Mixed::operator_lt(self, other as *const Mixed)) != 0) {
95+
std::cmp::Ordering::Less
96+
} else if ((Mixed::operator_lt(other, self as *const Mixed)) != 0) {
97+
std::cmp::Ordering::Greater
98+
} else {
99+
std::cmp::Ordering::Equal
100+
}
101+
}
110102
}
111103
}
112104
impl std::cmp::PartialOrd for Mixed {
@@ -116,7 +108,7 @@ impl std::cmp::PartialOrd for Mixed {
116108
}
117109
impl std::cmp::PartialEq for Mixed {
118110
fn eq(&self, other: &Self) -> bool {
119-
unsafe { Mixed::operator_eq(self, other as *const Mixed) }
111+
unsafe { ((Mixed::operator_eq(self, other as *const Mixed)) != 0) }
120112
}
121113
}
122114
impl std::cmp::Eq for Mixed {}
@@ -142,9 +134,15 @@ pub struct Boolish {
142134
impl std::cmp::Ord for Boolish {
143135
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
144136
unsafe {
145-
if operator_lt_6(self.clone(), other.clone()) {
137+
if {
138+
let __cmp = &operator_lt_6(self.clone(), other.clone());
139+
MyBool::to_bool(__cmp)
140+
} {
146141
std::cmp::Ordering::Less
147-
} else if operator_lt_6(other.clone(), self.clone()) {
142+
} else if {
143+
let __cmp = &operator_lt_6(other.clone(), self.clone());
144+
MyBool::to_bool(__cmp)
145+
} {
148146
std::cmp::Ordering::Greater
149147
} else {
150148
std::cmp::Ordering::Equal
@@ -159,7 +157,12 @@ impl std::cmp::PartialOrd for Boolish {
159157
}
160158
impl std::cmp::PartialEq for Boolish {
161159
fn eq(&self, other: &Self) -> bool {
162-
unsafe { operator_eq_7(self.clone(), other.clone()) }
160+
unsafe {
161+
{
162+
let __cmp = &operator_eq_7(self.clone(), other.clone());
163+
MyBool::to_bool(__cmp)
164+
}
165+
}
163166
}
164167
}
165168
impl std::cmp::Eq for Boolish {}

0 commit comments

Comments
 (0)