@@ -165,6 +165,10 @@ fn calling_host_functions_with_negative_values_works() -> Result<()> {
165
165
(import "host" "host_func2" (func (param i32)))
166
166
(import "host" "host_func3" (func (param i64)))
167
167
(import "host" "host_func4" (func (param i32)))
168
+ (import "host" "host_func5" (func (param i32)))
169
+ (import "host" "host_func6" (func (param i32)))
170
+ (import "host" "host_func7" (func (param i32)))
171
+ (import "host" "host_func8" (func (param i32)))
168
172
169
173
(func (export "call_host_func1")
170
174
(call 0 (i64.const -1)))
@@ -174,6 +178,14 @@ fn calling_host_functions_with_negative_values_works() -> Result<()> {
174
178
(call 2 (i64.const -1)))
175
179
(func (export "call_host_func4")
176
180
(call 3 (i32.const -1)))
181
+ (func (export "call_host_func5")
182
+ (call 4 (i32.const -1)))
183
+ (func (export "call_host_func6")
184
+ (call 5 (i32.const -1)))
185
+ (func (export "call_host_func7")
186
+ (call 6 (i32.const -1)))
187
+ (func (export "call_host_func8")
188
+ (call 7 (i32.const -1)))
177
189
)"# ;
178
190
let module = Module :: new ( & store, wat) ?;
179
191
let imports = imports ! {
@@ -194,6 +206,22 @@ fn calling_host_functions_with_negative_values_works() -> Result<()> {
194
206
println!( "host_func4: Found number {}" , p) ;
195
207
assert_eq!( p, -1 ) ;
196
208
} ) ,
209
+ "host_func5" => Function :: new_native( & store, |p: i16 | {
210
+ println!( "host_func5: Found number {}" , p) ;
211
+ assert_eq!( p, -1 ) ;
212
+ } ) ,
213
+ "host_func6" => Function :: new_native( & store, |p: u16 | {
214
+ println!( "host_func6: Found number {}" , p) ;
215
+ assert_eq!( p, u16 :: max_value( ) ) ;
216
+ } ) ,
217
+ "host_func7" => Function :: new_native( & store, |p: i8 | {
218
+ println!( "host_func7: Found number {}" , p) ;
219
+ assert_eq!( p, -1 ) ;
220
+ } ) ,
221
+ "host_func8" => Function :: new_native( & store, |p: u8 | {
222
+ println!( "host_func8: Found number {}" , p) ;
223
+ assert_eq!( p, u8 :: max_value( ) ) ;
224
+ } ) ,
197
225
}
198
226
} ;
199
227
let instance = Instance :: new ( & module, & imports) ?;
@@ -202,11 +230,19 @@ fn calling_host_functions_with_negative_values_works() -> Result<()> {
202
230
let f2: NativeFunc < ( ) , ( ) > = instance. exports . get_native_function ( "call_host_func2" ) ?;
203
231
let f3: NativeFunc < ( ) , ( ) > = instance. exports . get_native_function ( "call_host_func3" ) ?;
204
232
let f4: NativeFunc < ( ) , ( ) > = instance. exports . get_native_function ( "call_host_func4" ) ?;
233
+ let f5: NativeFunc < ( ) , ( ) > = instance. exports . get_native_function ( "call_host_func5" ) ?;
234
+ let f6: NativeFunc < ( ) , ( ) > = instance. exports . get_native_function ( "call_host_func6" ) ?;
235
+ let f7: NativeFunc < ( ) , ( ) > = instance. exports . get_native_function ( "call_host_func7" ) ?;
236
+ let f8: NativeFunc < ( ) , ( ) > = instance. exports . get_native_function ( "call_host_func8" ) ?;
205
237
206
238
f1. call ( ) ?;
207
239
f2. call ( ) ?;
208
240
f3. call ( ) ?;
209
241
f4. call ( ) ?;
242
+ f5. call ( ) ?;
243
+ f6. call ( ) ?;
244
+ f7. call ( ) ?;
245
+ f8. call ( ) ?;
210
246
211
247
Ok ( ( ) )
212
248
}
0 commit comments