1
1
#![ allow( clippy:: missing_safety_doc) ]
2
2
3
3
use byondapi:: { byond_string, map:: * , prelude:: * } ;
4
+ use eyre:: Result ;
4
5
5
6
#[ test]
6
7
fn generate_binds ( ) {
@@ -18,20 +19,20 @@ fn setup_panic_handler() {
18
19
}
19
20
20
21
#[ byondapi:: bind]
21
- fn test_connection ( ) {
22
+ fn test_connection ( ) -> Result < ByondValue > {
22
23
setup_panic_handler ( ) ;
23
24
Ok ( ByondValue :: new_num ( 69.0 ) )
24
25
}
25
26
26
27
#[ byondapi:: bind_raw_args]
27
- fn test_args ( ) {
28
+ fn test_args ( ) -> Result < ByondValue > {
28
29
setup_panic_handler ( ) ;
29
30
assert_eq ! ( args. len( ) , 2 ) ;
30
31
Ok ( args[ 1 ] )
31
32
}
32
33
33
34
#[ byondapi:: bind]
34
- fn test_ptr ( ptr : ByondValue ) {
35
+ fn test_ptr ( ptr : ByondValue ) -> Result < ByondValue > {
35
36
setup_panic_handler ( ) ;
36
37
let pointer = ByondValuePointer :: new ( ptr) ?;
37
38
@@ -44,20 +45,20 @@ fn test_ptr(ptr: ByondValue) {
44
45
}
45
46
46
47
#[ byondapi:: bind]
47
- fn test_proc_call ( object : ByondValue ) {
48
+ fn test_proc_call ( object : ByondValue ) -> Result < ByondValue > {
48
49
Ok ( object. call ( "get_name" , & [ ] ) ?)
49
50
}
50
51
51
52
#[ byondapi:: bind]
52
- fn test_readwrite_var ( object : ByondValue ) {
53
+ fn test_readwrite_var ( object : ByondValue ) -> Result < ByondValue > {
53
54
setup_panic_handler ( ) ;
54
55
55
56
object. read_var_id ( byond_string ! ( "name" ) ) ?. get_string ( ) ?;
56
57
57
58
Ok ( object. read_string ( "name" ) ?. try_into ( ) ?)
58
59
}
59
60
#[ byondapi:: bind]
60
- fn test_list_push ( mut list : ByondValue ) {
61
+ fn test_list_push ( mut list : ByondValue ) -> Result < ByondValue > {
61
62
setup_panic_handler ( ) ;
62
63
63
64
list. push_list ( ByondValue :: new_num ( 8.0 ) ) ?;
@@ -66,7 +67,7 @@ fn test_list_push(mut list: ByondValue) {
66
67
}
67
68
68
69
#[ byondapi:: bind]
69
- fn test_list_double ( list : ByondValue ) {
70
+ fn test_list_double ( list : ByondValue ) -> Result < ByondValue > {
70
71
setup_panic_handler ( ) ;
71
72
72
73
let collection = list
@@ -78,14 +79,14 @@ fn test_list_double(list: ByondValue) {
78
79
}
79
80
80
81
#[ byondapi:: bind]
81
- fn test_list_index ( list : ByondValue ) {
82
+ fn test_list_index ( list : ByondValue ) -> Result < ByondValue > {
82
83
setup_panic_handler ( ) ;
83
84
84
85
Ok ( list. read_list_index ( 3.0 ) ?)
85
86
}
86
87
87
88
#[ byondapi:: bind]
88
- fn test_list_pop ( mut list : ByondValue ) {
89
+ fn test_list_pop ( mut list : ByondValue ) -> Result < ByondValue > {
89
90
setup_panic_handler ( ) ;
90
91
91
92
let element = list. pop_list ( ) ?;
@@ -98,13 +99,13 @@ fn test_list_pop(mut list: ByondValue) {
98
99
}
99
100
100
101
#[ byondapi:: bind]
101
- fn test_length_with_list ( list : ByondValue ) {
102
+ fn test_length_with_list ( list : ByondValue ) -> Result < ByondValue > {
102
103
setup_panic_handler ( ) ;
103
104
Ok ( list. builtin_length ( ) ?)
104
105
}
105
106
106
107
#[ byondapi:: bind]
107
- fn test_block ( ) {
108
+ fn test_block ( ) -> Result < ByondValue > {
108
109
setup_panic_handler ( ) ;
109
110
110
111
let block = byond_block (
@@ -123,13 +124,13 @@ fn test_block() {
123
124
}
124
125
125
126
#[ byondapi:: bind]
126
- fn test_length_with_str ( object : ByondValue ) {
127
+ fn test_length_with_str ( object : ByondValue ) -> Result < ByondValue > {
127
128
setup_panic_handler ( ) ;
128
129
129
130
Ok ( object. builtin_length ( ) ?)
130
131
}
131
132
#[ byondapi:: bind]
132
- fn test_list_key_lookup ( mut list : ByondValue ) {
133
+ fn test_list_key_lookup ( mut list : ByondValue ) -> Result < ByondValue > {
133
134
setup_panic_handler ( ) ;
134
135
135
136
let num: f32 = list. read_list_index ( "cat" ) ?. try_into ( ) ?;
@@ -165,7 +166,7 @@ fn test_list_key_lookup(mut list: ByondValue) {
165
166
}
166
167
167
168
#[ byondapi:: bind]
168
- fn test_ref ( turf : ByondValue ) {
169
+ fn test_ref ( turf : ByondValue ) -> Result < ByondValue > {
169
170
setup_panic_handler ( ) ;
170
171
171
172
let turf_type = turf. get_type ( ) ;
@@ -177,7 +178,7 @@ fn test_ref(turf: ByondValue) {
177
178
}
178
179
179
180
#[ byondapi:: bind]
180
- fn test_non_assoc_list ( list : ByondValue ) {
181
+ fn test_non_assoc_list ( list : ByondValue ) -> Result < ByondValue > {
181
182
setup_panic_handler ( ) ;
182
183
183
184
let map = list
@@ -199,7 +200,7 @@ fn test_non_assoc_list(list: ByondValue) {
199
200
}
200
201
201
202
#[ byondapi:: bind]
202
- fn test_list_read ( list : ByondValue ) {
203
+ fn test_list_read ( list : ByondValue ) -> Result < ByondValue > {
203
204
setup_panic_handler ( ) ;
204
205
205
206
let map = list. get_list_values ( ) ?;
@@ -217,7 +218,7 @@ fn test_list_read(list: ByondValue) {
217
218
}
218
219
219
220
#[ byondapi:: bind]
220
- fn test_new_obj ( ) {
221
+ fn test_new_obj ( ) -> Result < ByondValue > {
221
222
Ok ( ByondValue :: builtin_new (
222
223
ByondValue :: try_from ( "/datum/testobject" ) ?,
223
224
& [ ] ,
0 commit comments