@@ -269,6 +269,7 @@ mod tests {
269269 use crate :: eval:: runtime:: profile:: mode:: ProfileMode ;
270270 use crate :: syntax:: AstModule ;
271271 use crate :: syntax:: Dialect ;
272+ use crate :: values:: Heap ;
272273 use crate :: values:: Value ;
273274
274275 #[ test]
286287 & Dialect :: AllOptionsInternal ,
287288 ) ?;
288289 let globals = Globals :: standard ( ) ;
289- Module :: with_temp_heap ( |module | {
290- Module :: with_temp_heap ( |module2| {
291- Module :: with_temp_heap ( |module3| {
292- let mut eval = Evaluator :: new ( & module ) ;
293- eval . enable_profile ( & ProfileMode :: HeapSummaryAllocated )
294- . unwrap ( ) ;
295- let f = eval. eval_module ( ast , & globals ) ? ;
296-
297- // first check module profiling works
298- HeapProfile :: write_summarized_heap_profile ( module . heap ( ) ) ;
299- HeapProfile :: write_flame_heap_profile ( module . heap ( ) ) ;
300-
301- // second check function profiling works
302- let mut eval = Evaluator :: new ( & module2 ) ;
303- eval . enable_profile ( & ProfileMode :: HeapSummaryAllocated )
304- . unwrap ( ) ;
305- eval. eval_function ( f , & [ Value :: testing_new_int ( 100 ) ] , & [ ] ) ? ;
306-
307- HeapProfile :: write_summarized_heap_profile ( module2 . heap ( ) ) ;
308- HeapProfile :: write_flame_heap_profile ( module2 . heap ( ) ) ;
309-
310- // finally, check a user can add values into the heap before/after
311- let mut eval = Evaluator :: new ( & module3 ) ;
312- module3 . heap ( ) . alloc ( "Thing that goes before" ) ;
313- eval . enable_profile ( & ProfileMode :: HeapSummaryAllocated )
314- . unwrap ( ) ;
315- eval. eval_function ( f , & [ Value :: testing_new_int ( 100 ) ] , & [ ] ) ? ;
316-
317- module3 . heap ( ) . alloc ( "Thing that goes after" ) ;
318- HeapProfile :: write_summarized_heap_profile ( module3 . heap ( ) ) ;
319- HeapProfile :: write_flame_heap_profile ( module3. heap ( ) ) ;
320-
321- Ok ( ( ) )
322- } )
323- } )
290+ Heap :: temp ( |heap | {
291+ let module = Module :: with_heap ( heap ) ;
292+ let module2 = Module :: with_heap ( heap ) ;
293+ let module3 = Module :: with_heap ( heap ) ;
294+
295+ let mut eval = Evaluator :: new ( & module ) ;
296+ eval. enable_profile ( & ProfileMode :: HeapSummaryAllocated )
297+ . unwrap ( ) ;
298+ let f = eval . eval_module ( ast , & globals ) ? ;
299+
300+ // first check module profiling works
301+ HeapProfile :: write_summarized_heap_profile ( module . heap ( ) ) ;
302+ HeapProfile :: write_flame_heap_profile ( module . heap ( ) ) ;
303+
304+ // second check function profiling works
305+ let mut eval = Evaluator :: new ( & module2 ) ;
306+ eval. enable_profile ( & ProfileMode :: HeapSummaryAllocated )
307+ . unwrap ( ) ;
308+ eval . eval_function ( f , & [ Value :: testing_new_int ( 100 ) ] , & [ ] ) ? ;
309+
310+ HeapProfile :: write_summarized_heap_profile ( module2 . heap ( ) ) ;
311+ HeapProfile :: write_flame_heap_profile ( module2 . heap ( ) ) ;
312+
313+ // finally, check a user can add values into the heap before/after
314+ let mut eval = Evaluator :: new ( & module3 ) ;
315+ module3 . heap ( ) . alloc ( "Thing that goes before" ) ;
316+ eval. enable_profile ( & ProfileMode :: HeapSummaryAllocated )
317+ . unwrap ( ) ;
318+ eval . eval_function ( f , & [ Value :: testing_new_int ( 100 ) ] , & [ ] ) ? ;
319+
320+ module3. heap ( ) . alloc ( "Thing that goes after" ) ;
321+ HeapProfile :: write_summarized_heap_profile ( module3 . heap ( ) ) ;
322+ HeapProfile :: write_flame_heap_profile ( module3 . heap ( ) ) ;
323+
324+ Ok ( ( ) )
324325 } )
325326 }
326327}
0 commit comments