mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
LibCore: Fix compilation of infallible Promise::when_resolved handlers
This overload is currently unused. When used, it doesn't compile due to mismatched return types in the handler provided to the function and the type of `on_resolution`.
This commit is contained in:
parent
75e60d3a68
commit
c190294a76
2 changed files with 24 additions and 7 deletions
|
@ -61,6 +61,26 @@ TEST_CASE(promise_chain_handlers)
|
|||
EXPECT(!rejected);
|
||||
}
|
||||
|
||||
TEST_CASE(infallible_promise_chain_handlers)
|
||||
{
|
||||
Core::EventLoop loop;
|
||||
|
||||
bool resolved = false;
|
||||
bool rejected = false;
|
||||
|
||||
NonnullRefPtr<Core::Promise<int>> promise = MUST(Core::Promise<int>::try_create())
|
||||
->when_resolved([&](int&) { resolved = true; })
|
||||
.when_rejected([&](AK::Error const&) { rejected = true; });
|
||||
|
||||
loop.deferred_invoke([=] {
|
||||
promise->resolve(42);
|
||||
});
|
||||
|
||||
(void)promise->await();
|
||||
EXPECT(resolved);
|
||||
EXPECT(!rejected);
|
||||
}
|
||||
|
||||
TEST_CASE(promise_map)
|
||||
{
|
||||
Core::EventLoop loop;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue