mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 17:05:05 +01:00
This will be more correct if a user file is named prelude.carbon, and reduces the explorer runtime by about 10% by removing a string comparison from the check for whether trace output is enabled. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
27 lines
713 B
C++
27 lines
713 B
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 "explorer/common/error_builders.h"
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "explorer/common/source_location.h"
|
|
#include "testing/util/test_raw_ostream.h"
|
|
|
|
namespace Carbon::Testing {
|
|
namespace {
|
|
|
|
TEST(ErrorBuildersTest, ProgramError) {
|
|
Error err = ProgramError(SourceLocation("x", 1, FileKind::Main)) << "test";
|
|
EXPECT_EQ(err.location(), "x:1");
|
|
EXPECT_EQ(err.message(), "test");
|
|
|
|
TestRawOstream out;
|
|
out << err;
|
|
EXPECT_EQ(out.TakeStr(), "x:1: test");
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace Carbon::Testing
|