File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ fn binaryen_optimiser(
118
118
#[ cfg( test) ]
119
119
mod tests {
120
120
use super :: * ;
121
+ use rustc_hex:: FromHex ;
121
122
122
123
#[ test]
123
124
fn smoke_test_o0 ( ) {
@@ -139,4 +140,26 @@ mod tests {
139
140
let serialized = result. to_bytes ( ) . unwrap ( ) ;
140
141
assert_eq ! ( expected, serialized) ;
141
142
}
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
+ }
142
165
}
You can’t perform that action at this time.
0 commit comments