mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 20:30:14 +01:00
This is intended to: - Standardize use of line_num (and highlight where no line_num is available). - Standardize indications of runtime/compilation errors. - Make it incrementally easier to write new errors. Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "executable_semantics/common/error.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
namespace Carbon {
|
|
namespace {
|
|
|
|
TEST(ErrorTest, FatalUserError) {
|
|
ASSERT_DEATH({ FATAL_RUNTIME_ERROR_NO_LINE() << "test"; }, "ERROR: test\n");
|
|
}
|
|
|
|
TEST(ErrorTest, FatalRuntimeError) {
|
|
ASSERT_DEATH({ FATAL_RUNTIME_ERROR_NO_LINE() << "test"; },
|
|
"RUNTIME ERROR: test\n");
|
|
}
|
|
|
|
TEST(ErrorTest, FatalCompilationError) {
|
|
ASSERT_DEATH({ FATAL_COMPILATION_ERROR_NO_LINE() << "test"; },
|
|
"COMPILATION ERROR: test\n");
|
|
}
|
|
|
|
TEST(ErrorTest, FatalUserErrorLine) {
|
|
ASSERT_DEATH({ FATAL_USER_ERROR(1) << "test"; }, "ERROR: 1: test\n");
|
|
}
|
|
|
|
auto NoReturnRequired() -> int { FATAL_USER_ERROR_NO_LINE() << "test"; }
|
|
|
|
TEST(ErrorTest, NoReturnRequired) {
|
|
ASSERT_DEATH({ NoReturnRequired(); }, "ERROR: test\n");
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace Carbon
|