1 // { dg-do run } 2 3 // Simplest lambda 4 5 #include "../coro.h" 6 7 // boiler-plate for tests of codegen 8 #include "../coro1-ret-int-yield-int.h" 9 main()10int main () 11 { 12 auto f = []() -> coro1 13 { 14 PRINT ("coro1: about to return"); 15 co_return 42; 16 }; 17 18 PRINT ("main: create coro1"); 19 coro1 x = f (); 20 PRINT ("main: got coro1 - resuming"); 21 if (x.handle.done()) 22 abort(); 23 x.handle.resume(); 24 PRINT ("main: after resume"); 25 int y = x.handle.promise().get_value(); 26 if ( y != 42 ) 27 abort (); 28 if (!x.handle.done()) 29 { 30 PRINT ("main: apparently not done..."); 31 abort (); 32 } 33 PRINT ("main: returning"); 34 return 0; 35 } 36