Skip to content

Commit 453a7c4

Browse files
committed
Update tests
1 parent 898c2df commit 453a7c4

43 files changed

Lines changed: 202 additions & 232 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/ub/out/refcount/ub4.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
99
pub fn smaller_0(x1: Ptr<i32>, x2: Ptr<i32>) -> Ptr<i32> {
10-
return if (({
10+
return if ({
1111
let _lhs = (x1.read());
1212
_lhs < (x2.read())
13-
}) as bool)
14-
{
13+
}) {
1514
(x1).clone()
1615
} else {
1716
(x2).clone()

tests/ub/out/unsafe/ub4.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
99
pub unsafe fn smaller_0(x1: *mut i32, x2: *mut i32) -> *mut i32 {
10-
return if (((*x1) < (*x2)) as bool) {
11-
(x1)
12-
} else {
13-
(x2)
14-
};
10+
return if ((*x1) < (*x2)) { (x1) } else { (x2) };
1511
}
1612
pub fn main() {
1713
unsafe {

tests/unit/bool_condition_logical.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,35 @@ int main() {
4545
}
4646
assert(side_effect == 0);
4747

48-
int chunk_count = 5;
49-
int max_chunks = 3;
50-
unsigned opts = 0x2u;
51-
if ((chunk_count > max_chunks) || (opts & 0x1u)) {
48+
int x = 5;
49+
int y = 3;
50+
unsigned flags = 0x2u;
51+
if ((x > y) || (flags & 0x1u)) {
5252
assert(true);
5353
}
54-
if ((chunk_count < max_chunks) || (opts & 0x1u)) {
54+
if ((x < y) || (flags & 0x1u)) {
5555
assert(false);
5656
}
5757

58-
unsigned a_id = 1u;
59-
unsigned b_id = 2u;
60-
unsigned other_id = 3u;
61-
if (((a_id != other_id)) && ((b_id != other_id))) {
58+
unsigned a = 1u;
59+
unsigned b = 2u;
60+
unsigned c = 3u;
61+
if (((a != c)) && ((b != c))) {
6262
assert(true);
6363
}
6464

65-
int reply_ms = -1;
66-
if ((p != nullptr) && (reply_ms < 0)) {
65+
int s = -1;
66+
if ((p != nullptr) && (s < 0)) {
6767
assert(true);
6868
}
6969

70-
unsigned baller_count = 2u;
71-
bool ballers_complete = false;
72-
if ((baller_count > 1u) || !ballers_complete) {
70+
unsigned k = 2u;
71+
bool done = false;
72+
if ((k > 1u) || !done) {
7373
assert(true);
7474
}
7575

76-
if (((chunk_count > max_chunks)) || ((opts & 0x4u))) {
76+
if (((x > y)) || ((flags & 0x4u))) {
7777
assert(true);
7878
}
7979

tests/unit/bool_condition_logical_c.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,35 @@ int main() {
4646
}
4747
assert(side_effect == 0);
4848

49-
int chunk_count = 5;
50-
int max_chunks = 3;
51-
unsigned opts = 0x2u;
52-
if ((chunk_count > max_chunks) || (opts & 0x1u)) {
49+
int x = 5;
50+
int y = 3;
51+
unsigned flags = 0x2u;
52+
if ((x > y) || (flags & 0x1u)) {
5353
assert(true);
5454
}
55-
if ((chunk_count < max_chunks) || (opts & 0x1u)) {
55+
if ((x < y) || (flags & 0x1u)) {
5656
assert(false);
5757
}
5858

59-
unsigned a_id = 1u;
60-
unsigned b_id = 2u;
61-
unsigned other_id = 3u;
62-
if (((a_id != other_id)) && ((b_id != other_id))) {
59+
unsigned a = 1u;
60+
unsigned b = 2u;
61+
unsigned c = 3u;
62+
if (((a != c)) && ((b != c))) {
6363
assert(true);
6464
}
6565

66-
int reply_ms = -1;
67-
if ((p != NULL) && (reply_ms < 0)) {
66+
int s = -1;
67+
if ((p != NULL) && (s < 0)) {
6868
assert(true);
6969
}
7070

71-
unsigned baller_count = 2u;
72-
bool ballers_complete = false;
73-
if ((baller_count > 1u) || !ballers_complete) {
71+
unsigned k = 2u;
72+
bool done = false;
73+
if ((k > 1u) || !done) {
7474
assert(true);
7575
}
7676

77-
if (((chunk_count > max_chunks)) || ((opts & 0x4u))) {
77+
if (((x > y)) || ((flags & 0x4u))) {
7878
assert(true);
7979
}
8080

tests/unit/out/refcount/bool_condition_logical.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,34 +94,34 @@ fn main_0() -> i32 {
9494
assert!(true);
9595
}
9696
assert!(((*side_effect.with(Value::clone).borrow()) == 0));
97-
let chunk_count: Value<i32> = Rc::new(RefCell::new(5));
98-
let max_chunks: Value<i32> = Rc::new(RefCell::new(3));
99-
let opts: Value<u32> = Rc::new(RefCell::new(2_u32));
100-
if (((*chunk_count.borrow()) > (*max_chunks.borrow())) || (((*opts.borrow()) & 1_u32) != 0)) {
97+
let x: Value<i32> = Rc::new(RefCell::new(5));
98+
let y: Value<i32> = Rc::new(RefCell::new(3));
99+
let flags: Value<u32> = Rc::new(RefCell::new(2_u32));
100+
if (((*x.borrow()) > (*y.borrow())) || (((*flags.borrow()) & 1_u32) != 0)) {
101101
assert!(true);
102102
}
103-
if (((*chunk_count.borrow()) < (*max_chunks.borrow())) || (((*opts.borrow()) & 1_u32) != 0)) {
103+
if (((*x.borrow()) < (*y.borrow())) || (((*flags.borrow()) & 1_u32) != 0)) {
104104
assert!(false);
105105
}
106-
let a_id: Value<u32> = Rc::new(RefCell::new(1_u32));
107-
let b_id: Value<u32> = Rc::new(RefCell::new(2_u32));
108-
let other_id: Value<u32> = Rc::new(RefCell::new(3_u32));
109-
if (((*a_id.borrow()) != (*other_id.borrow())) && ((*b_id.borrow()) != (*other_id.borrow()))) {
106+
let a: Value<u32> = Rc::new(RefCell::new(1_u32));
107+
let b: Value<u32> = Rc::new(RefCell::new(2_u32));
108+
let c: Value<u32> = Rc::new(RefCell::new(3_u32));
109+
if (((*a.borrow()) != (*c.borrow())) && ((*b.borrow()) != (*c.borrow()))) {
110110
assert!(true);
111111
}
112-
let reply_ms: Value<i32> = Rc::new(RefCell::new(-1_i32));
112+
let s: Value<i32> = Rc::new(RefCell::new(-1_i32));
113113
if {
114114
let _lhs = (!((*p.borrow()).is_null())).clone();
115-
_lhs && ((*reply_ms.borrow()) < 0)
115+
_lhs && ((*s.borrow()) < 0)
116116
} {
117117
assert!(true);
118118
}
119-
let baller_count: Value<u32> = Rc::new(RefCell::new(2_u32));
120-
let ballers_complete: Value<bool> = Rc::new(RefCell::new(false));
121-
if (((*baller_count.borrow()) > 1_u32) || !(*ballers_complete.borrow())) {
119+
let k: Value<u32> = Rc::new(RefCell::new(2_u32));
120+
let done: Value<bool> = Rc::new(RefCell::new(false));
121+
if (((*k.borrow()) > 1_u32) || !(*done.borrow())) {
122122
assert!(true);
123123
}
124-
if (((*chunk_count.borrow()) > (*max_chunks.borrow())) || (((*opts.borrow()) & 4_u32) != 0)) {
124+
if (((*x.borrow()) > (*y.borrow())) || (((*flags.borrow()) & 4_u32) != 0)) {
125125
assert!(true);
126126
}
127127
return 0;

tests/unit/out/refcount/bool_condition_logical_c.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,31 @@ fn main_0() -> i32 {
7878
assert!((1 != 0));
7979
}
8080
assert!(((*side_effect.with(Value::clone).borrow()) == 0));
81-
let chunk_count: Value<i32> = Rc::new(RefCell::new(5));
82-
let max_chunks: Value<i32> = Rc::new(RefCell::new(3));
83-
let opts: Value<u32> = Rc::new(RefCell::new(2_u32));
84-
if ((*chunk_count.borrow()) > (*max_chunks.borrow())) || (((*opts.borrow()) & 1_u32) != 0) {
81+
let x: Value<i32> = Rc::new(RefCell::new(5));
82+
let y: Value<i32> = Rc::new(RefCell::new(3));
83+
let flags: Value<u32> = Rc::new(RefCell::new(2_u32));
84+
if ((*x.borrow()) > (*y.borrow())) || (((*flags.borrow()) & 1_u32) != 0) {
8585
assert!((1 != 0));
8686
}
87-
if ((*chunk_count.borrow()) < (*max_chunks.borrow())) || (((*opts.borrow()) & 1_u32) != 0) {
87+
if ((*x.borrow()) < (*y.borrow())) || (((*flags.borrow()) & 1_u32) != 0) {
8888
assert!((0 != 0));
8989
}
90-
let a_id: Value<u32> = Rc::new(RefCell::new(1_u32));
91-
let b_id: Value<u32> = Rc::new(RefCell::new(2_u32));
92-
let other_id: Value<u32> = Rc::new(RefCell::new(3_u32));
93-
if ((*a_id.borrow()) != (*other_id.borrow())) && ((*b_id.borrow()) != (*other_id.borrow())) {
90+
let a: Value<u32> = Rc::new(RefCell::new(1_u32));
91+
let b: Value<u32> = Rc::new(RefCell::new(2_u32));
92+
let c: Value<u32> = Rc::new(RefCell::new(3_u32));
93+
if ((*a.borrow()) != (*c.borrow())) && ((*b.borrow()) != (*c.borrow())) {
9494
assert!((1 != 0));
9595
}
96-
let reply_ms: Value<i32> = Rc::new(RefCell::new(-1_i32));
97-
if ((*p.borrow()) != (Default::default())) && ((*reply_ms.borrow()) < 0) {
96+
let s: Value<i32> = Rc::new(RefCell::new(-1_i32));
97+
if ((*p.borrow()) != (Default::default())) && ((*s.borrow()) < 0) {
9898
assert!((1 != 0));
9999
}
100-
let baller_count: Value<u32> = Rc::new(RefCell::new(2_u32));
101-
let ballers_complete: Value<bool> = Rc::new(RefCell::new((0 != 0)));
102-
if ((*baller_count.borrow()) > 1_u32) || (!(*ballers_complete.borrow())) {
100+
let k: Value<u32> = Rc::new(RefCell::new(2_u32));
101+
let done: Value<bool> = Rc::new(RefCell::new((0 != 0)));
102+
if ((*k.borrow()) > 1_u32) || (!(*done.borrow())) {
103103
assert!((1 != 0));
104104
}
105-
if ((*chunk_count.borrow()) > (*max_chunks.borrow())) || (((*opts.borrow()) & 4_u32) != 0) {
105+
if ((*x.borrow()) > (*y.borrow())) || (((*flags.borrow()) & 4_u32) != 0) {
106106
assert!((1 != 0));
107107
}
108108
return 0;

tests/unit/out/refcount/continue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ fn main_0() -> i32 {
3535
'loop_: while ((*k2.borrow()) < 5) {
3636
let k3: Value<i32> = Rc::new(RefCell::new(0));
3737
'loop_: while ((*k3.borrow()) < 5) {
38-
if ((((((*k1.borrow()) + (*k2.borrow())) + (*k3.borrow())) as i32) % 2) == 0) {
38+
if (((((*k1.borrow()) + (*k2.borrow())) + (*k3.borrow())) % 2) == 0) {
3939
(*k3.borrow_mut()).postfix_inc();
4040
continue 'loop_;
4141
}
4242
(*out.borrow_mut()).prefix_inc();
4343
(*k3.borrow_mut()).postfix_inc();
4444
}
45-
if (((((*k1.borrow()) + (*k2.borrow())) as i32) % 2) == 0) {
45+
if ((((*k1.borrow()) + (*k2.borrow())) % 2) == 0) {
4646
(*k2.borrow_mut()).postfix_inc();
4747
continue 'loop_;
4848
}

tests/unit/out/refcount/enum_int_interop.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ fn main_0() -> i32 {
131131
make_color_2(_n)
132132
});
133133
assert!((((*c.borrow()) as i32) == (Color::GREEN as i32)));
134-
let cmp: Value<Color> = Rc::new(RefCell::new(Color::from(
135-
((((*c.borrow()) as i32) + 1) as i32),
136-
)));
134+
let cmp: Value<Color> = Rc::new(RefCell::new(Color::from((((*c.borrow()) as i32) + 1))));
137135
assert!((((*cmp.borrow()) as i32) == (Color::BLUE as i32)));
138136
let o: Value<Option> = Rc::new(RefCell::new(Option::OPT_A));
139137
assert!((((*o.borrow()) as i32) == (Option::OPT_A as i32)));

tests/unit/out/refcount/enum_int_interop_c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn main_0() -> i32 {
134134
});
135135
assert!((((*c.borrow()) as u32) == ((Color::GREEN as i32) as u32)));
136136
let cmp: Value<Color> = Rc::new(RefCell::new(Color::from(
137-
((((*c.borrow()) as u32).wrapping_add(1_u32)) as u32) as i32,
137+
(((*c.borrow()) as u32).wrapping_add(1_u32)) as i32,
138138
)));
139139
assert!((((*cmp.borrow()) as u32) == ((Color::BLUE as i32) as u32)));
140140
let o: Value<Option> = Rc::new(RefCell::new(Option::from((Option::OPT_A as i32))));

tests/unit/out/refcount/expr_as_bool_c.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,31 @@ fn main_0() -> i32 {
1717
(*b.borrow())
1818
} != 0)
1919
{}
20-
'loop_: while ((({
20+
'loop_: while (({
2121
(*b.borrow_mut()) = (*a.borrow());
2222
(*b.borrow())
23-
}) as i32)
24-
!= 0)
23+
}) != 0)
2524
{}
2625
if ((*a.borrow()) != 0) {}
2726
if ((*a.borrow()) == (*b.borrow())) {}
2827
if ((*a.borrow()) < (*b.borrow())) {}
2928
assert!(((*a.borrow()) == (*b.borrow())));
3029
assert!(
31-
((!((({
30+
((!(({
3231
(*a.borrow_mut()) = (*b.borrow());
3332
(*a.borrow())
34-
}) as i32)
35-
!= 0) as i32)
33+
}) != 0) as i32)
3634
!= 0)
3735
);
3836
let c: Value<bool> = <Value<bool>>::default();
3937
(*c.borrow_mut()) = ({
4038
(*a.borrow_mut()) = (*b.borrow());
4139
(*a.borrow())
4240
} != 0);
43-
(*c.borrow_mut()) = ((({
41+
(*c.borrow_mut()) = (({
4442
(*b.borrow_mut()) = (*a.borrow());
4543
(*b.borrow())
46-
}) as i32)
47-
!= 0);
44+
}) != 0);
4845
(*c.borrow_mut()) = ((*a.borrow()) != 0);
4946
(*c.borrow_mut()) = ((*a.borrow()) == (*b.borrow()));
5047
(*c.borrow_mut()) = ((*a.borrow()) < (*b.borrow()));

0 commit comments

Comments
 (0)