-
Notifications
You must be signed in to change notification settings - Fork 266
Expand file tree
/
Copy pathrunner.rs
More file actions
127 lines (118 loc) · 3.65 KB
/
runner.rs
File metadata and controls
127 lines (118 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//@ wasmtime-flags = '-Wcomponent-model-fixed-length-lists'
include!(env!("BINDINGS"));
use test::fixed_length_lists::to_test::*;
mod alloc;
struct Guard {
me_before: usize,
remote_before: u32,
}
impl Guard {
fn new() -> Guard {
Guard {
me_before: alloc::get(),
remote_before: allocated_bytes(),
}
}
}
impl Drop for Guard {
fn drop(&mut self) {
assert_eq!(self.me_before, alloc::get());
assert_eq!(self.remote_before, allocated_bytes());
}
}
struct Component;
export!(Component);
impl Guest for Component {
fn run() {
{
let _guard = Guard::new();
list_param([1, 2, 3, 4]);
}
{
let _guard = Guard::new();
list_param2([[1, 2], [3, 4]]);
}
{
let _guard = Guard::new();
list_param3([
-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20,
]);
}
{
let _guard = Guard::new();
let result = list_result();
assert_eq!(result, [b'0', b'1', b'A', b'B', b'a', b'b', 128, 255]);
}
{
let _guard = Guard::new();
let result = list_minmax16([0, 1024, 32768, 65535], [1, 2048, -32767, -2]);
assert_eq!(result, ([0, 1024, 32768, 65535], [1, 2048, -32767, -2]));
}
{
let _guard = Guard::new();
let result = list_minmax_float([2.0, -42.0], [0.25, -0.125]);
assert_eq!(result, ([2.0, -42.0], [0.25, -0.125]));
}
{
let _guard = Guard::new();
let result =
list_roundtrip([b'a', b'b', b'c', b'd', 0, 1, 2, 3, b'A', b'B', b'Y', b'Z']);
assert_eq!(
result,
[b'a', b'b', b'c', b'd', 0, 1, 2, 3, b'A', b'B', b'Y', b'Z']
);
}
{
let _guard = Guard::new();
let result = nested_roundtrip([[1, 5], [42, 1_000_000]], [[-1, 3], [-2_000_000, 4711]]);
assert_eq!(
result,
([[1, 5], [42, 1_000_000]], [[-1, 3], [-2_000_000, 4711]])
);
}
{
let _guard = Guard::new();
let result = large_roundtrip(
[[1, 5], [42, 1_000_000]],
[
[-1, 3, -2, 4],
[-2_000_000, 4711, 99_999, -5],
[-6, 7, 8, -9],
[50, -5, 500, -5000],
],
);
assert_eq!(
result,
(
[[1, 5], [42, 1_000_000]],
[
[-1, 3, -2, 4],
[-2_000_000, 4711, 99_999, -5],
[-6, 7, 8, -9],
[50, -5, 500, -5000]
]
)
);
}
{
let _guard = Guard::new();
let result = nightmare_on_cpp([Nested { l: [1, -1] }, Nested { l: [2, -2] }]);
assert_eq!(result[0].l, [1, -1]);
assert_eq!(result[1].l, [2, -2]);
}
{
let _guard = Guard::new();
string_list_param(["foo".to_owned(), "bar".to_owned(), "baz".to_owned()]);
}
{
let _guard = Guard::new();
let result = string_list_result();
assert_eq!(result, ["foo", "bar", "baz"]);
}
{
let _guard = Guard::new();
let result = string_list_roundtrip(["foo".to_owned(), "bar".to_owned(), "baz".to_owned()]);
assert_eq!(result, ["foo", "bar", "baz"]);
}
}
}