mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 07:21:04 +01:00
Remove RuntimeError / CompilationError. (#2258)
Instead, work out the prefix for an error based on whether it was produced during parsing, semantic analysis, or when running the program.
This commit is contained in:
@@ -18,28 +18,11 @@ auto ToString(const Error& err) -> std::string {
|
||||
return result;
|
||||
}
|
||||
|
||||
TEST(ErrorBuildersTest, CompilationError) {
|
||||
Error err = CompilationError(SourceLocation("x", 1)) << "test";
|
||||
EXPECT_EQ(err.prefix(), "COMPILATION ERROR");
|
||||
EXPECT_EQ(err.location(), "x:1");
|
||||
EXPECT_EQ(err.message(), "test");
|
||||
EXPECT_EQ(ToString(err), "COMPILATION ERROR: x:1: test");
|
||||
}
|
||||
|
||||
TEST(ErrorBuildersTest, ProgramError) {
|
||||
Error err = ProgramError(SourceLocation("x", 1)) << "test";
|
||||
EXPECT_EQ(err.prefix(), "PROGRAM ERROR");
|
||||
EXPECT_EQ(err.location(), "x:1");
|
||||
EXPECT_EQ(err.message(), "test");
|
||||
EXPECT_EQ(ToString(err), "PROGRAM ERROR: x:1: test");
|
||||
}
|
||||
|
||||
TEST(ErrorBuildersTest, RuntimeError) {
|
||||
Error err = RuntimeError(SourceLocation("x", 1)) << "test";
|
||||
EXPECT_EQ(err.prefix(), "RUNTIME ERROR");
|
||||
EXPECT_EQ(err.location(), "x:1");
|
||||
EXPECT_EQ(err.message(), "test");
|
||||
EXPECT_EQ(ToString(err), "RUNTIME ERROR: x:1: test");
|
||||
EXPECT_EQ(ToString(err), "x:1: test");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user