1 // { dg-do run } 2 3 // Test promise construction from function args list. 4 5 #include "../coro.h" 6 7 // boiler-plate for tests of codegen 8 #include "../coro1-ret-int-yield-int.h" 9 10 struct coro1 f(int x)11f (int x) noexcept 12 { 13 PRINT ("coro1: about to return"); 14 co_return 42; 15 } 16 main()17int main () 18 { 19 PRINT ("main: create coro1"); 20 struct coro1 x = f (555); 21 int y = x.handle.promise().get_value(); 22 if ( y != 555 ) 23 { 24 PRINT ("main: incorrect ctor value"); 25 abort (); 26 } 27 PRINTF ("main: after coro1 ctor %d - now resuming\n", y); 28 if (x.handle.done()) 29 abort(); 30 x.handle.resume(); 31 PRINT ("main: after resume"); 32 y = x.handle.promise().get_value(); 33 if ( y != 42 ) 34 abort (); 35 if (!x.handle.done()) 36 { 37 PRINT ("main: apparently not done..."); 38 abort (); 39 } 40 PRINT ("main: returning"); 41 return 0; 42 } 43