From 81cf8b68eca2636574f3d0a9fa1cf0b428c163e9 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sat, 1 Aug 2026 04:30:34 +0800 Subject: [Backend] Establish standalone build infrastructure Add the thin monorepo CMake entry point and an independently configurable backend project. Enforce the Clang/C++23 toolchain, expose Make/Ninja-neutral tests and developer checks, export an installable RCCBackend package, and introduce the first Support error abstraction. --- backend/unittests/Support/ErrorTest.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 backend/unittests/Support/ErrorTest.cpp (limited to 'backend/unittests/Support/ErrorTest.cpp') diff --git a/backend/unittests/Support/ErrorTest.cpp b/backend/unittests/Support/ErrorTest.cpp new file mode 100644 index 0000000..23140e3 --- /dev/null +++ b/backend/unittests/Support/ErrorTest.cpp @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "rcc/Support/Error.h" + +#include +#include + +namespace { + +int fail(const char *Message) { + std::cerr << Message << '\n'; + return 1; +} + +} // namespace + +int main() { + rcc::Expected Value = 42; + if (!Value || *Value != 42) + return fail("Expected must preserve a successful value"); + + rcc::Expected Failure = rcc::makeUnexpected(rcc::ErrorCode::ParseError, "bad MIR"); + if (Failure) + return fail("Expected must preserve an error"); + if (Failure.error().code() != rcc::ErrorCode::ParseError) + return fail("Error must preserve its code"); + if (Failure.error().message() != "bad MIR") + return fail("Error must preserve its message"); + if (rcc::getErrorCodeName(Failure.error().code()) != "parse error") + return fail("Error code must have a stable name"); + + return 0; +} -- cgit v1.2.3