AK: Allow Optional<T> to be used in constant expressions

This commit is contained in:
Jonne Ransijn 2025-04-11 15:55:43 +02:00 committed by Andrew Kaster
commit a059ab4677
Notes: github-actions[bot] 2025-04-23 03:21:35 +00:00
4 changed files with 233 additions and 86 deletions

View file

@ -130,6 +130,9 @@ bool assume(T const& expression, StringView expression_string, SourceLocation lo
return true;
}
template<typename T>
consteval void expect_consteval(T) { }
}
#define EXPECT(...) \
@ -179,6 +182,8 @@ bool assume(T const& expression, StringView expression_string, SourceLocation lo
::Test::set_current_test_result(::Test::TestResult::Failed); \
} while (false)
#define EXPECT_CONSTEVAL(...) ::Test::expect_consteval(__VA_ARGS__)
// To use, specify the lambda to execute in a sub process and verify it exits:
// EXPECT_CRASH("This should fail", []{
// return Test::Crash::Failure::DidNotCrash;