File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -407,6 +407,34 @@ impl Emitter {
407
407
}
408
408
}
409
409
410
+ /// Ensures that mutabled tracked calls in a nested function are properly
411
+ /// replayed when there is a cache hit for a top-level function.
412
+ #[ test]
413
+ #[ serial]
414
+ fn test_mutable_nested ( ) {
415
+ #[ comemo:: memoize]
416
+ fn a ( counter : TrackedMut < Counter > , _k : usize ) {
417
+ b ( counter) ;
418
+ }
419
+
420
+ #[ comemo:: memoize]
421
+ fn b ( mut counter : TrackedMut < Counter > ) {
422
+ counter. add ( 3 ) ;
423
+ }
424
+
425
+ let mut c1 = Counter ( 0 ) ;
426
+ a ( c1. track_mut ( ) , 0 ) ;
427
+ assert_eq ! ( c1. 0 , 3 ) ;
428
+
429
+ let mut c2 = Counter ( 0 ) ;
430
+ a ( c2. track_mut ( ) , 1 ) ;
431
+ assert_eq ! ( c2. 0 , 3 ) ;
432
+
433
+ let mut c3 = Counter ( 0 ) ;
434
+ a ( c3. track_mut ( ) , 1 ) ;
435
+ assert_eq ! ( c3. 0 , 3 ) ;
436
+ }
437
+
410
438
/// Ensures that we don't run into quadratic runtime during cache validation of
411
439
/// many cache entries with the same key hash.
412
440
#[ test]
You can’t perform that action at this time.
0 commit comments