Skip to content

Commit e8d956f

Browse files
committed
Update tests
1 parent 92979cd commit e8d956f

12 files changed

Lines changed: 97 additions & 358 deletions
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
#include <assert.h>
2-
#include <string.h>
2+
#include <stdio.h>
3+
4+
struct Point {
5+
int x;
6+
int y;
7+
};
38

49
static int agg(int n) {
5-
char buf[40];
10+
char buf40[40];
11+
unsigned char buf256[256];
12+
int arr64[64];
13+
long longs[33];
14+
struct Point p;
15+
int *ptr;
16+
int (*fp)(int);
17+
FILE *file;
618
int total = 0;
719
if (n < 0) {
820
goto out;
921
}
10-
memset(buf, 1, sizeof(buf));
11-
for (int i = 0; i < 40; i++) {
12-
total += buf[i];
13-
}
22+
total = 1;
1423
out:
1524
return total;
1625
}
1726

1827
int main(void) {
1928
assert(agg(-1) == 0);
20-
assert(agg(2) == 40);
29+
assert(agg(1) == 1);
2130
return 0;
2231
}

tests/unit/goto_forward_skip.c

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/unit/goto_loop_control.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
#include <assert.h>
22

3-
static int loopctl(int n) {
4-
int total = 0;
5-
for (int i = 0; i < n; i++) {
6-
if (i == 2) {
3+
static int loopctl(void) {
4+
int sum = 0;
5+
for (int i = 0; i < 5; i++) {
6+
if (i == 1) {
77
continue;
88
}
9-
if (i == 5) {
9+
if (i == 4) {
1010
break;
1111
}
12-
if (i % 2 == 0) {
13-
goto even;
14-
}
15-
total += 1;
16-
even:
17-
total += 10;
12+
goto add;
13+
add:
14+
sum += 1;
1815
}
19-
return total;
16+
return sum;
2017
}
2118

2219
int main(void) {
23-
assert(loopctl(10) == 42);
20+
assert(loopctl() == 3);
2421
return 0;
2522
}

tests/unit/goto_switch_exit.c

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/unit/out/refcount/goto_aggregate_default.rs

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,49 @@ use std::io::prelude::*;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
9+
#[derive(Default)]
10+
pub struct Point {
11+
pub x: Value<i32>,
12+
pub y: Value<i32>,
13+
}
14+
impl ByteRepr for Point {
15+
fn to_bytes(&self, buf: &mut [u8]) {
16+
(*self.x.borrow()).to_bytes(&mut buf[0..4]);
17+
(*self.y.borrow()).to_bytes(&mut buf[4..8]);
18+
}
19+
fn from_bytes(buf: &[u8]) -> Self {
20+
Self {
21+
x: Rc::new(RefCell::new(<i32>::from_bytes(&buf[0..4]))),
22+
y: Rc::new(RefCell::new(<i32>::from_bytes(&buf[4..8]))),
23+
}
24+
}
25+
}
926
pub fn agg_0(n: i32) -> i32 {
1027
let n: Value<i32> = Rc::new(RefCell::new(n));
11-
let mut buf: Value<Box<[u8]>> = Rc::new(RefCell::new(
28+
let mut buf40: Value<Box<[u8]>> = Rc::new(RefCell::new(
1229
(0..40).map(|_| <u8>::default()).collect::<Box<[u8]>>(),
1330
));
31+
let mut buf256: Value<Box<[u8]>> = Rc::new(RefCell::new(
32+
(0..256).map(|_| <u8>::default()).collect::<Box<[u8]>>(),
33+
));
34+
let mut arr64: Value<Box<[i32]>> = Rc::new(RefCell::new(
35+
(0..64).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
36+
));
37+
let mut longs: Value<Box<[i64]>> = Rc::new(RefCell::new(
38+
(0..33).map(|_| <i64>::default()).collect::<Box<[i64]>>(),
39+
));
40+
let mut p: Value<Point> = <Value<Point>>::default();
41+
let mut ptr: Value<Ptr<i32>> = Rc::new(RefCell::new(Ptr::<i32>::null()));
42+
let mut fp: Value<FnPtr<fn(i32) -> i32>> = Rc::new(RefCell::new(FnPtr::null()));
43+
let mut file: Value<Ptr<::std::fs::File>> = Rc::new(RefCell::new(Ptr::null()));
1444
let mut total: Value<i32> = <Value<i32>>::default();
1545
goto_block!({
1646
'__entry: {
1747
total = Rc::new(RefCell::new(0));
1848
if ((((*n.borrow()) < 0) as i32) != 0) {
1949
goto!('out);
2050
}
21-
{
22-
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>)
23-
.to_any()
24-
.memset((1) as u8, ::std::mem::size_of::<[u8; 40]>() as u64 as usize);
25-
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any().clone()
26-
};
27-
let i: Value<i32> = Rc::new(RefCell::new(0));
28-
'loop_: while ((((*i.borrow()) < 40) as i32) != 0) {
29-
(*total.borrow_mut()) += ((*buf.borrow())[(*i.borrow()) as usize] as i32);
30-
(*i.borrow_mut()).postfix_inc();
31-
}
51+
(*total.borrow_mut()) = 1;
3252
}
3353
'out: {
3454
return (*total.borrow());
@@ -49,9 +69,9 @@ fn main_0() -> i32 {
4969
);
5070
assert!(
5171
(((({
52-
let _n: i32 = 2;
72+
let _n: i32 = 1;
5373
agg_0(_n)
54-
}) == 40) as i32)
74+
}) == 1) as i32)
5575
!= 0)
5676
);
5777
return 0;

tests/unit/out/refcount/goto_forward_skip.rs

Lines changed: 0 additions & 46 deletions
This file was deleted.

tests/unit/out/refcount/goto_loop_control.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,33 @@ use std::io::prelude::*;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
9-
pub fn loopctl_0(n: i32) -> i32 {
10-
let n: Value<i32> = Rc::new(RefCell::new(n));
11-
let total: Value<i32> = Rc::new(RefCell::new(0));
9+
pub fn loopctl_0() -> i32 {
10+
let sum: Value<i32> = Rc::new(RefCell::new(0));
1211
let i: Value<i32> = Rc::new(RefCell::new(0));
13-
'loop_: while ((((*i.borrow()) < (*n.borrow())) as i32) != 0) {
12+
'loop_: while ((((*i.borrow()) < 5) as i32) != 0) {
1413
goto_block!({
1514
'__entry: {
16-
if ((((*i.borrow()) == 2) as i32) != 0) {
15+
if ((((*i.borrow()) == 1) as i32) != 0) {
1716
(*i.borrow_mut()).postfix_inc();
1817
continue 'loop_;
1918
}
20-
if ((((*i.borrow()) == 5) as i32) != 0) {
19+
if ((((*i.borrow()) == 4) as i32) != 0) {
2120
break;
2221
}
23-
if (((((*i.borrow()) % 2) == 0) as i32) != 0) {
24-
goto!('even);
25-
}
26-
(*total.borrow_mut()) += 1;
22+
goto!('add);
2723
}
28-
'even: {
29-
(*total.borrow_mut()) += 10;
24+
'add: {
25+
(*sum.borrow_mut()) += 1;
3026
}
3127
});
3228
(*i.borrow_mut()).postfix_inc();
3329
}
34-
return (*total.borrow());
30+
return (*sum.borrow());
3531
}
3632
pub fn main() {
3733
std::process::exit(main_0());
3834
}
3935
fn main_0() -> i32 {
40-
assert!(
41-
(((({
42-
let _n: i32 = 10;
43-
loopctl_0(_n)
44-
}) == 42) as i32)
45-
!= 0)
46-
);
36+
assert!((((({ loopctl_0() }) == 3) as i32) != 0));
4737
return 0;
4838
}

tests/unit/out/refcount/goto_switch_exit.rs

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)