@@ -16,6 +16,10 @@ use wast::{QuoteWat, core::AbstractHeapType};
1616
1717const TEST_TIME_SLICE : Duration = Duration :: from_millis ( 20 ) ;
1818const TEST_MAX_SUSPENSIONS : u32 = 1000 ;
19+ // Older suites classify encodings that wasmparser accepts with the latest feature set as malformed.
20+ const ACCEPTED_MALFORMED_MESSAGES : & [ & str ] =
21+ & [ "integer representation too long" , "zero byte expected" , "zero flag expected" ] ;
22+ const ACCEPTED_INVALID_MESSAGES : & [ & str ] = & [ "multiple memories" ] ;
1923
2024#[ derive( Default ) ]
2125struct ModuleRegistry {
@@ -307,32 +311,22 @@ impl WastRunner {
307311 & format ! ( "AssertMalformed({i})" ) ,
308312 span. linecol_in ( wast_raw) ,
309313 match res {
310- Ok ( _) => {
311- if message == "zero byte expected"
312- || message == "integer representation too long"
313- || message == "zero flag expected"
314- {
315- continue ;
316- }
317- Err ( anyhow ! ( "expected module to be malformed: {message}" ) )
318- }
314+ Ok ( _) if ACCEPTED_MALFORMED_MESSAGES . contains ( & message) => Ok ( ( ) ) ,
315+ Ok ( _) => Err ( anyhow ! ( "expected module to be malformed: {message}" ) ) ,
319316 Err ( _) => Ok ( ( ) ) ,
320317 } ,
321318 ) ;
322319 }
323320 AssertInvalid { span, mut module, message } => {
324- if [ "multiple memories" , "type mismatch" ] . contains ( & message) {
325- test_group. add_result ( & format ! ( "AssertInvalid({i})" ) , span. linecol_in ( wast_raw) , Ok ( ( ) ) ) ;
326- continue ;
327- }
328321 let res = catch_unwind_silent ( move || parse_module_bytes ( & module. encode ( ) . unwrap ( ) ) )
329322 . map_err ( |e| anyhow ! ( "failed to parse module (invalid): {}" , try_downcast_panic( e) ) )
330323 . and_then ( |res| res) ;
331324 test_group. add_result (
332325 & format ! ( "AssertInvalid({i})" ) ,
333326 span. linecol_in ( wast_raw) ,
334327 match res {
335- Ok ( _) => Err ( anyhow ! ( "expected module to be invalid" ) ) ,
328+ Ok ( _) if ACCEPTED_INVALID_MESSAGES . contains ( & message) => Ok ( ( ) ) ,
329+ Ok ( _) => Err ( anyhow ! ( "expected module to be invalid: {message}" ) ) ,
336330 Err ( _) => Ok ( ( ) ) ,
337331 } ,
338332 ) ;
0 commit comments