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 @@ -118,6 +118,7 @@ fn binaryen_optimiser(
118118#[ cfg( test) ]
119119mod tests {
120120 use super :: * ;
121+ use rustc_hex:: FromHex ;
121122
122123 #[ test]
123124 fn smoke_test_o0 ( ) {
@@ -139,4 +140,26 @@ mod tests {
139140 let serialized = result. to_bytes ( ) . unwrap ( ) ;
140141 assert_eq ! ( expected, serialized) ;
141142 }
143+
144+ #[ test]
145+ fn test_keep_names_section ( ) {
146+ let input = FromHex :: from_hex (
147+ "0061736d010000000104016000000303020000070801046d61696e00010a
148+ 0a020300010b040010000b0014046e616d65010d0200047465737401046d
149+ 61696e" ,
150+ )
151+ . unwrap ( ) ;
152+ let module = Module :: from_bytes ( & input)
153+ . unwrap ( )
154+ . parse_names ( )
155+ . expect ( "parsing the names section failed" ) ;
156+ assert_eq ! ( module. has_names_section( ) , true ) ;
157+
158+ let translator = BinaryenOptimiser :: with_preset ( "O0" ) . unwrap ( ) ;
159+ let result = translator. translate ( & module) . unwrap ( ) . unwrap ( ) ;
160+ assert_eq ! ( result. has_names_section( ) , true ) ;
161+
162+ let output = result. to_bytes ( ) . unwrap ( ) ;
163+ assert_eq ! ( input, output) ;
164+ }
142165}
You can’t perform that action at this time.
0 commit comments