|
|
@@ -23,7 +23,7 @@ namespace Carbon::Lex {
|
|
|
namespace {
|
|
|
|
|
|
using ::Carbon::Testing::ExpectedToken;
|
|
|
-using ::Carbon::Testing::IsDiagnostic;
|
|
|
+using ::Carbon::Testing::IsSingleDiagnostic;
|
|
|
using ::Carbon::Testing::TestRawOstream;
|
|
|
using ::testing::_;
|
|
|
using ::testing::ElementsAre;
|
|
|
@@ -966,7 +966,7 @@ TEST_F(LexerTest, TypeLiteralTooManyDigits) {
|
|
|
|
|
|
Testing::MockDiagnosticConsumer consumer;
|
|
|
EXPECT_CALL(consumer,
|
|
|
- HandleDiagnostic(IsDiagnostic(
|
|
|
+ HandleDiagnostic(IsSingleDiagnostic(
|
|
|
DiagnosticKind::TooManyDigits, DiagnosticLevel::Error, 1, 2,
|
|
|
HasSubstr(llvm::formatv(" {0} ", Count)))));
|
|
|
auto buffer = Lex(code, consumer);
|
|
|
@@ -990,15 +990,15 @@ TEST_F(LexerTest, DiagnosticTrailingComment) {
|
|
|
)";
|
|
|
|
|
|
Testing::MockDiagnosticConsumer consumer;
|
|
|
- EXPECT_CALL(consumer,
|
|
|
- HandleDiagnostic(IsDiagnostic(DiagnosticKind::TrailingComment,
|
|
|
- DiagnosticLevel::Error, 3, 19, _)));
|
|
|
+ EXPECT_CALL(consumer, HandleDiagnostic(IsSingleDiagnostic(
|
|
|
+ DiagnosticKind::TrailingComment,
|
|
|
+ DiagnosticLevel::Error, 3, 19, _)));
|
|
|
Lex(testcase, consumer);
|
|
|
}
|
|
|
|
|
|
TEST_F(LexerTest, DiagnosticWhitespace) {
|
|
|
Testing::MockDiagnosticConsumer consumer;
|
|
|
- EXPECT_CALL(consumer, HandleDiagnostic(IsDiagnostic(
|
|
|
+ EXPECT_CALL(consumer, HandleDiagnostic(IsSingleDiagnostic(
|
|
|
DiagnosticKind::NoWhitespaceAfterCommentIntroducer,
|
|
|
DiagnosticLevel::Error, 1, 3, _)));
|
|
|
Lex("//no space after comment", consumer);
|
|
|
@@ -1006,7 +1006,7 @@ TEST_F(LexerTest, DiagnosticWhitespace) {
|
|
|
|
|
|
TEST_F(LexerTest, DiagnosticUnrecognizedEscape) {
|
|
|
Testing::MockDiagnosticConsumer consumer;
|
|
|
- EXPECT_CALL(consumer, HandleDiagnostic(IsDiagnostic(
|
|
|
+ EXPECT_CALL(consumer, HandleDiagnostic(IsSingleDiagnostic(
|
|
|
DiagnosticKind::UnknownEscapeSequence,
|
|
|
DiagnosticLevel::Error, 1, 8, HasSubstr("`b`"))));
|
|
|
Lex(R"("hello\bworld")", consumer);
|
|
|
@@ -1014,7 +1014,7 @@ TEST_F(LexerTest, DiagnosticUnrecognizedEscape) {
|
|
|
|
|
|
TEST_F(LexerTest, DiagnosticBadHex) {
|
|
|
Testing::MockDiagnosticConsumer consumer;
|
|
|
- EXPECT_CALL(consumer, HandleDiagnostic(IsDiagnostic(
|
|
|
+ EXPECT_CALL(consumer, HandleDiagnostic(IsSingleDiagnostic(
|
|
|
DiagnosticKind::HexadecimalEscapeMissingDigits,
|
|
|
DiagnosticLevel::Error, 1, 9, _)));
|
|
|
Lex(R"("hello\xabworld")", consumer);
|
|
|
@@ -1022,7 +1022,7 @@ TEST_F(LexerTest, DiagnosticBadHex) {
|
|
|
|
|
|
TEST_F(LexerTest, DiagnosticInvalidDigit) {
|
|
|
Testing::MockDiagnosticConsumer consumer;
|
|
|
- EXPECT_CALL(consumer, HandleDiagnostic(IsDiagnostic(
|
|
|
+ EXPECT_CALL(consumer, HandleDiagnostic(IsSingleDiagnostic(
|
|
|
DiagnosticKind::InvalidDigit,
|
|
|
DiagnosticLevel::Error, 1, 6, HasSubstr("'a'"))));
|
|
|
Lex("0x123abc", consumer);
|
|
|
@@ -1030,17 +1030,17 @@ TEST_F(LexerTest, DiagnosticInvalidDigit) {
|
|
|
|
|
|
TEST_F(LexerTest, DiagnosticMissingTerminator) {
|
|
|
Testing::MockDiagnosticConsumer consumer;
|
|
|
- EXPECT_CALL(consumer,
|
|
|
- HandleDiagnostic(IsDiagnostic(DiagnosticKind::UnterminatedString,
|
|
|
- DiagnosticLevel::Error, 1, 1, _)));
|
|
|
+ EXPECT_CALL(consumer, HandleDiagnostic(IsSingleDiagnostic(
|
|
|
+ DiagnosticKind::UnterminatedString,
|
|
|
+ DiagnosticLevel::Error, 1, 1, _)));
|
|
|
Lex(R"(#" ")", consumer);
|
|
|
}
|
|
|
|
|
|
TEST_F(LexerTest, DiagnosticUnrecognizedChar) {
|
|
|
Testing::MockDiagnosticConsumer consumer;
|
|
|
- EXPECT_CALL(consumer, HandleDiagnostic(
|
|
|
- IsDiagnostic(DiagnosticKind::UnrecognizedCharacters,
|
|
|
- DiagnosticLevel::Error, 1, 1, _)));
|
|
|
+ EXPECT_CALL(consumer, HandleDiagnostic(IsSingleDiagnostic(
|
|
|
+ DiagnosticKind::UnrecognizedCharacters,
|
|
|
+ DiagnosticLevel::Error, 1, 1, _)));
|
|
|
Lex("\b", consumer);
|
|
|
}
|
|
|
|