blob: 61e284d5c8f5c5cd5c63d6a6b22758fe4223f265 [file] [log] [blame]
// { dg-do run }
// Simplest lambda
#include "../coro.h"
// boiler-plate for tests of codegen
#include "../coro1-ret-int-yield-int.h"
int main ()
{
auto f = []() -> coro1
{
PRINT ("coro1: about to return");
co_return 42;
};
PRINT ("main: create coro1");
coro1 x = f ();
PRINT ("main: got coro1 - resuming");
if (x.handle.done())
abort();
x.handle.resume();
PRINT ("main: after resume");
int y = x.handle.promise().get_value();
if ( y != 42 )
abort ();
if (!x.handle.done())
{
PRINT ("main: apparently not done...");
abort ();
}
PRINT ("main: returning");
return 0;
}