mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
LibCore: Move the Promise::await() result instead of returning a ref
Returning a reference resulted in Mail's use of Promise causing a crash. Also, awaiting an already-awaited promise is an odd thing to do anyway, so let's just make it release the resolved/rejected value instead of returning a reference to it. Co-Authored-By: Valtteri Koskivuori <vkoskiv@gmail.com>
This commit is contained in:
parent
8ed3cc5f7b
commit
9f4feb7315
2 changed files with 5 additions and 5 deletions
|
@ -18,7 +18,7 @@ TEST_CASE(promise_await_async_event)
|
|||
promise->resolve(42);
|
||||
});
|
||||
|
||||
auto& result = promise->await();
|
||||
auto result = promise->await();
|
||||
EXPECT(!result.is_error());
|
||||
EXPECT_EQ(result.value(), 42);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ TEST_CASE(promise_await_async_event_rejection)
|
|||
promise->reject(AK::Error::from_string_literal("lol no"));
|
||||
});
|
||||
|
||||
auto& result = promise->await();
|
||||
auto result = promise->await();
|
||||
EXPECT(result.is_error());
|
||||
EXPECT_EQ(result.error().string_literal(), "lol no"sv);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ TEST_CASE(promise_chain_handlers)
|
|||
promise->resolve(42);
|
||||
});
|
||||
|
||||
promise->await();
|
||||
(void)promise->await();
|
||||
EXPECT(resolved);
|
||||
EXPECT(!rejected);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue