@@ -2,64 +2,71 @@ include!(env!("BINDINGS"));
22
33use test:: fixed_size_lists:: to_test:: * ;
44
5- fn main ( ) {
6- list_param ( [ 1 , 2 , 3 , 4 ] ) ;
7- list_param2 ( [ [ 1 , 2 ] , [ 3 , 4 ] ] ) ;
8- list_param3 ( [
9- -1 , 2 , -3 , 4 , -5 , 6 , -7 , 8 , -9 , 10 , -11 , 12 , -13 , 14 , -15 , 16 , -17 , 18 , -19 , 20 ,
10- ] ) ;
11- {
12- let result = list_result ( ) ;
13- assert_eq ! ( result, [ b'0' , b'1' , b'A' , b'B' , b'a' , b'b' , 128 , 255 ] ) ;
14- }
15- {
16- let result = list_minmax16 ( [ 0 , 1024 , 32768 , 65535 ] , [ 1 , 2048 , -32767 , -2 ] ) ;
17- assert_eq ! ( result, ( [ 0 , 1024 , 32768 , 65535 ] , [ 1 , 2048 , -32767 , -2 ] ) ) ;
18- }
19- {
20- let result = list_minmax_float ( [ 2.0 , -42.0 ] , [ 0.25 , -0.125 ] ) ;
21- assert_eq ! ( result, ( [ 2.0 , -42.0 ] , [ 0.25 , -0.125 ] ) ) ;
22- }
23- {
24- let result = list_roundtrip ( [ b'a' , b'b' , b'c' , b'd' , 0 , 1 , 2 , 3 , b'A' , b'B' , b'Y' , b'Z' ] ) ;
25- assert_eq ! (
26- result,
27- [ b'a' , b'b' , b'c' , b'd' , 0 , 1 , 2 , 3 , b'A' , b'B' , b'Y' , b'Z' ]
28- ) ;
29- }
30- {
31- let result = nested_roundtrip ( [ [ 1 , 5 ] , [ 42 , 1_000_000 ] ] , [ [ -1 , 3 ] , [ -2_000_000 , 4711 ] ] ) ;
32- assert_eq ! (
33- result,
34- ( [ [ 1 , 5 ] , [ 42 , 1_000_000 ] ] , [ [ -1 , 3 ] , [ -2_000_000 , 4711 ] ] )
35- ) ;
36- }
37- {
38- let result = large_roundtrip (
39- [ [ 1 , 5 ] , [ 42 , 1_000_000 ] ] ,
40- [
41- [ -1 , 3 , -2 , 4 ] ,
42- [ -2_000_000 , 4711 , 99_999 , -5 ] ,
43- [ -6 , 7 , 8 , -9 ] ,
44- [ 50 , -5 , 500 , -5000 ] ,
45- ] ,
46- ) ;
47- assert_eq ! (
48- result,
49- (
5+ struct Component ;
6+
7+ export ! ( Component ) ;
8+
9+ impl Guest for Component {
10+ fn run ( ) {
11+ list_param ( [ 1 , 2 , 3 , 4 ] ) ;
12+ list_param2 ( [ [ 1 , 2 ] , [ 3 , 4 ] ] ) ;
13+ list_param3 ( [
14+ -1 , 2 , -3 , 4 , -5 , 6 , -7 , 8 , -9 , 10 , -11 , 12 , -13 , 14 , -15 , 16 , -17 , 18 , -19 , 20 ,
15+ ] ) ;
16+ {
17+ let result = list_result ( ) ;
18+ assert_eq ! ( result, [ b'0' , b'1' , b'A' , b'B' , b'a' , b'b' , 128 , 255 ] ) ;
19+ }
20+ {
21+ let result = list_minmax16 ( [ 0 , 1024 , 32768 , 65535 ] , [ 1 , 2048 , -32767 , -2 ] ) ;
22+ assert_eq ! ( result, ( [ 0 , 1024 , 32768 , 65535 ] , [ 1 , 2048 , -32767 , -2 ] ) ) ;
23+ }
24+ {
25+ let result = list_minmax_float ( [ 2.0 , -42.0 ] , [ 0.25 , -0.125 ] ) ;
26+ assert_eq ! ( result, ( [ 2.0 , -42.0 ] , [ 0.25 , -0.125 ] ) ) ;
27+ }
28+ {
29+ let result =
30+ list_roundtrip ( [ b'a' , b'b' , b'c' , b'd' , 0 , 1 , 2 , 3 , b'A' , b'B' , b'Y' , b'Z' ] ) ;
31+ assert_eq ! (
32+ result,
33+ [ b'a' , b'b' , b'c' , b'd' , 0 , 1 , 2 , 3 , b'A' , b'B' , b'Y' , b'Z' ]
34+ ) ;
35+ }
36+ {
37+ let result = nested_roundtrip ( [ [ 1 , 5 ] , [ 42 , 1_000_000 ] ] , [ [ -1 , 3 ] , [ -2_000_000 , 4711 ] ] ) ;
38+ assert_eq ! (
39+ result,
40+ ( [ [ 1 , 5 ] , [ 42 , 1_000_000 ] ] , [ [ -1 , 3 ] , [ -2_000_000 , 4711 ] ] )
41+ ) ;
42+ }
43+ {
44+ let result = large_roundtrip (
5045 [ [ 1 , 5 ] , [ 42 , 1_000_000 ] ] ,
5146 [
5247 [ -1 , 3 , -2 , 4 ] ,
5348 [ -2_000_000 , 4711 , 99_999 , -5 ] ,
5449 [ -6 , 7 , 8 , -9 ] ,
55- [ 50 , -5 , 500 , -5000 ]
56- ]
57- )
58- ) ;
59- }
60- {
61- let result = nightmare_on_cpp ( [ Nested { l : [ 1 , -1 ] } , Nested { l : [ 2 , -2 ] } ] ) ;
62- assert_eq ! ( result[ 0 ] . l, [ 1 , -1 ] ) ;
63- assert_eq ! ( result[ 1 ] . l, [ 2 , -2 ] ) ;
50+ [ 50 , -5 , 500 , -5000 ] ,
51+ ] ,
52+ ) ;
53+ assert_eq ! (
54+ result,
55+ (
56+ [ [ 1 , 5 ] , [ 42 , 1_000_000 ] ] ,
57+ [
58+ [ -1 , 3 , -2 , 4 ] ,
59+ [ -2_000_000 , 4711 , 99_999 , -5 ] ,
60+ [ -6 , 7 , 8 , -9 ] ,
61+ [ 50 , -5 , 500 , -5000 ]
62+ ]
63+ )
64+ ) ;
65+ }
66+ {
67+ let result = nightmare_on_cpp ( [ Nested { l : [ 1 , -1 ] } , Nested { l : [ 2 , -2 ] } ] ) ;
68+ assert_eq ! ( result[ 0 ] . l, [ 1 , -1 ] ) ;
69+ assert_eq ! ( result[ 1 ] . l, [ 2 , -2 ] ) ;
70+ }
6471 }
6572}
0 commit comments