File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ fn binaryen_optimiser(
116116#[ cfg( test) ]
117117mod tests {
118118 use super :: * ;
119+ use rustc_hex:: FromHex ;
119120
120121 #[ test]
121122 fn smoke_test_o0 ( ) {
@@ -137,4 +138,26 @@ mod tests {
137138 let serialized = result. to_bytes ( ) . unwrap ( ) ;
138139 assert_eq ! ( expected, serialized) ;
139140 }
141+
142+ #[ test]
143+ fn test_keep_names_section ( ) {
144+ let input = FromHex :: from_hex (
145+ "0061736d010000000104016000000303020000070801046d61696e00010a
146+ 0a020300010b040010000b0014046e616d65010d0200047465737401046d
147+ 61696e" ,
148+ )
149+ . unwrap ( ) ;
150+ let module = Module :: from_bytes ( & input)
151+ . unwrap ( )
152+ . parse_names ( )
153+ . expect ( "parsing the names section failed" ) ;
154+ assert_eq ! ( module. has_names_section( ) , true ) ;
155+
156+ let translator = BinaryenOptimiser :: with_preset ( "O0" ) . unwrap ( ) ;
157+ let result = translator. translate ( & module) . unwrap ( ) . unwrap ( ) ;
158+ assert_eq ! ( result. has_names_section( ) , true ) ;
159+
160+ let output = result. to_bytes ( ) . unwrap ( ) ;
161+ assert_eq ! ( input, output) ;
162+ }
140163}
You can’t perform that action at this time.
0 commit comments