namespace {
-// Come up with our hacked version of MCAsmInfo.
-// This hacked version derives from the main MCAsmInfo instance.
-// Here, we're free to override whatever we want, without polluting
-// the main MCAsmInfo interface.
-class MockedUpMCAsmInfo : public MCAsmInfo {
-public:
- void setRestrictCommentStringToStartOfStatement(bool Value) {
- RestrictCommentStringToStartOfStatement = Value;
- }
- void setCommentString(StringRef Value) { CommentString = Value; }
- void setAllowAdditionalComments(bool Value) {
- AllowAdditionalComments = Value;
- }
- void setAllowQuestionAtStartOfIdentifier(bool Value) {
- AllowQuestionAtStartOfIdentifier = Value;
- }
- void setAllowAtAtStartOfIdentifier(bool Value) {
- AllowAtAtStartOfIdentifier = Value;
- }
- void setAllowDollarAtStartOfIdentifier(bool Value) {
- AllowDollarAtStartOfIdentifier = Value;
- }
- void setAllowHashAtStartOfIdentifier(bool Value) {
- AllowHashAtStartOfIdentifier = Value;
- }
- void setAllowDotIsPC(bool Value) { DotIsPC = Value; }
- void setAssemblerDialect(unsigned Value) { AssemblerDialect = Value; }
- void setEmitLabelsInUpperCase(bool Value) { EmitLabelsInUpperCase = Value; }
-};
-
// Setup a testing class that the GTest framework can call.
class SystemZAsmLexerTest : public ::testing::Test {
protected:
}
std::unique_ptr<MCRegisterInfo> MRI;
- std::unique_ptr<MockedUpMCAsmInfo> MUPMAI;
+ std::unique_ptr<MCAsmInfo> MAI;
std::unique_ptr<const MCInstrInfo> MII;
std::unique_ptr<MCObjectFileInfo> MOFI;
std::unique_ptr<MCStreamer> Str;
const MCTargetOptions MCOptions;
- SystemZAsmLexerTest() {
+ SystemZAsmLexerTest() = delete;
+
+ SystemZAsmLexerTest(std::string SystemZTriple) {
// We will use the SystemZ triple, because of missing
// Object File and Streamer support for the z/OS target.
- TripleName = "s390x-ibm-linux";
+ TripleName = SystemZTriple;
Triple = llvm::Triple(TripleName);
std::string Error;
STI.reset(TheTarget->createMCSubtargetInfo(TripleName, "z10", ""));
EXPECT_NE(STI, nullptr);
- std::unique_ptr<MCAsmInfo> MAI;
MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
EXPECT_NE(MAI, nullptr);
-
- // Now we cast to our mocked up version of MCAsmInfo.
- MUPMAI.reset(static_cast<MockedUpMCAsmInfo *>(MAI.release()));
- // MUPMAI should "hold" MAI.
- EXPECT_NE(MUPMAI, nullptr);
- // After releasing, MAI should now be null.
- EXPECT_EQ(MAI, nullptr);
}
void setupCallToAsmParser(StringRef AsmStr) {
SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
EXPECT_EQ(Buffer, nullptr);
- Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), STI.get(), &SrcMgr,
+ Ctx.reset(new MCContext(Triple, MAI.get(), MRI.get(), STI.get(), &SrcMgr,
&MCOptions));
MOFI.reset(TheTarget->createMCObjectFileInfo(*Ctx, /*PIC=*/false,
/*LargeCodeModel=*/false));
Str.reset(TheTarget->createNullStreamer(*Ctx));
- Parser.reset(createMCAsmParser(SrcMgr, *Ctx, *Str, *MUPMAI));
+ Parser.reset(createMCAsmParser(SrcMgr, *Ctx, *Str, *MAI));
TargetAsmParser.reset(
TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));
}
};
-TEST_F(SystemZAsmLexerTest, CheckDontRestrictCommentStringToStartOfStatement) {
+class SystemZAsmLexerLinux : public SystemZAsmLexerTest {
+protected:
+ SystemZAsmLexerLinux() : SystemZAsmLexerTest("s390x-ibm-linux") {}
+};
+
+class SystemZAsmLexerZOS : public SystemZAsmLexerTest {
+protected:
+ SystemZAsmLexerZOS() : SystemZAsmLexerTest("s390x-ibm-zos") {}
+};
+
+TEST_F(SystemZAsmLexerLinux, CheckDontRestrictCommentStringToStartOfStatement) {
StringRef AsmStr = "jne #-4";
// Setup.
lexAndCheckTokens(AsmStr /* "jne #-4" */, ExpectedTokens);
}
-// Testing MCAsmInfo's RestrictCommentStringToStartOfStatement attribute.
-TEST_F(SystemZAsmLexerTest, CheckRestrictCommentStringToStartOfStatement) {
+TEST_F(SystemZAsmLexerZOS, CheckRestrictCommentStringToStartOfStatement) {
StringRef AsmStr = "jne #-4";
// Setup.
- MUPMAI->setRestrictCommentStringToStartOfStatement(true);
setupCallToAsmParser(AsmStr);
// Lex initially to get the string.
// Minus - '-'
// Integer - '4'
SmallVector<AsmToken::TokenKind> ExpectedTokens(
- {AsmToken::Identifier, AsmToken::Hash, AsmToken::Minus,
- AsmToken::Integer});
+ {AsmToken::Identifier, AsmToken::Space, AsmToken::Identifier});
lexAndCheckTokens(AsmStr /* "jne #-4" */, ExpectedTokens);
}
// Test HLASM Comment Syntax ('*')
-TEST_F(SystemZAsmLexerTest, CheckHLASMComment) {
+TEST_F(SystemZAsmLexerZOS, CheckHLASMComment) {
StringRef AsmStr = "* lhi 1,10";
// Setup.
- MUPMAI->setCommentString("*");
setupCallToAsmParser(AsmStr);
// Lex initially to get the string.
lexAndCheckTokens(AsmStr /* "* lhi 1,10" */, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckHashDefault) {
+TEST_F(SystemZAsmLexerLinux, CheckHashDefault) {
StringRef AsmStr = "lh#123";
// Setup.
}
// Test if "#" is accepted as an Identifier
-TEST_F(SystemZAsmLexerTest, CheckAllowHashInIdentifier) {
+TEST_F(SystemZAsmLexerZOS, CheckAllowHashInIdentifier) {
StringRef AsmStr = "lh#123";
// Setup.
setupCallToAsmParser(AsmStr);
- Parser->getLexer().setAllowHashInIdentifier(true);
// Lex initially to get the string.
Parser->getLexer().Lex();
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckAllowHashInIdentifier2) {
+TEST_F(SystemZAsmLexerZOS, CheckAllowHashInIdentifier2) {
StringRef AsmStr = "lh#12*3";
// Setup.
- MUPMAI->setCommentString("*");
- MUPMAI->setRestrictCommentStringToStartOfStatement(true);
setupCallToAsmParser(AsmStr);
- Parser->getLexer().setAllowHashInIdentifier(true);
// Lex initially to get the string.
Parser->getLexer().Lex();
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, DontCheckStrictCommentString) {
+TEST_F(SystemZAsmLexerLinux, DontCheckStrictCommentString) {
StringRef AsmStr = "# abc\n/* def */// xyz";
// Setup.
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, DontCheckStrictCommentString2) {
- StringRef AsmStr = "# abc\n/* def */// xyz\n* rst";
-
- // Setup.
- MUPMAI->setCommentString("*");
- setupCallToAsmParser(AsmStr);
-
- // Lex initially to get the string.
- Parser->getLexer().Lex();
-
- SmallVector<AsmToken::TokenKind> ExpectedTokens(
- {AsmToken::EndOfStatement, AsmToken::Comment, AsmToken::EndOfStatement,
- AsmToken::EndOfStatement, AsmToken::Eof});
- lexAndCheckTokens(AsmStr, ExpectedTokens);
-}
-
-TEST_F(SystemZAsmLexerTest, CheckStrictCommentString) {
+TEST_F(SystemZAsmLexerZOS, CheckStrictCommentString) {
StringRef AsmStr = "# abc\n/* def */// xyz";
// Setup.
- MUPMAI->setAllowAdditionalComments(false);
- setupCallToAsmParser(AsmStr);
-
- // Lex initially to get the string.
- Parser->getLexer().Lex();
-
- // "# abc" -> still treated as a comment, since CommentString
- // is set to "#"
- SmallVector<AsmToken::TokenKind> ExpectedTokens;
- ExpectedTokens.push_back(AsmToken::EndOfStatement); // "# abc\n"
- ExpectedTokens.push_back(AsmToken::Slash); // "/"
- ExpectedTokens.push_back(AsmToken::Star); // "*"
- ExpectedTokens.push_back(AsmToken::Identifier); // "def"
- ExpectedTokens.push_back(AsmToken::Star); // "*"
- ExpectedTokens.push_back(AsmToken::Slash); // "/"
- ExpectedTokens.push_back(AsmToken::Slash); // "/"
- ExpectedTokens.push_back(AsmToken::Slash); // "/"
- ExpectedTokens.push_back(AsmToken::Identifier); // "xyz"
- ExpectedTokens.push_back(AsmToken::EndOfStatement);
- ExpectedTokens.push_back(AsmToken::Eof);
-
- lexAndCheckTokens(AsmStr, ExpectedTokens);
-}
-
-TEST_F(SystemZAsmLexerTest, CheckStrictCommentString2) {
- StringRef AsmStr = "// abc";
-
- // Setup.
- MUPMAI->setAllowAdditionalComments(false);
- MUPMAI->setCommentString("//");
- setupCallToAsmParser(AsmStr);
-
- // Lex initially to get the string.
- Parser->getLexer().Lex();
-
- // "// abc" -> will still be treated as a comment because "//" is the
- // CommentString
- SmallVector<AsmToken::TokenKind> ExpectedTokens(
- {AsmToken::EndOfStatement, AsmToken::Eof});
- lexAndCheckTokens(AsmStr /* "// abc" */, ExpectedTokens);
-}
-
-TEST_F(SystemZAsmLexerTest, CheckStrictCommentString3) {
- StringRef AsmStr = "/* abc */";
-
- // Setup.
- MUPMAI->setAllowAdditionalComments(false);
setupCallToAsmParser(AsmStr);
// Lex initially to get the string.
Parser->getLexer().Lex();
SmallVector<AsmToken::TokenKind> ExpectedTokens;
- ExpectedTokens.push_back(AsmToken::Slash);
- ExpectedTokens.push_back(AsmToken::Star);
- ExpectedTokens.push_back(AsmToken::Identifier);
- ExpectedTokens.push_back(AsmToken::Star);
- ExpectedTokens.push_back(AsmToken::Slash);
- ExpectedTokens.push_back(AsmToken::EndOfStatement);
- ExpectedTokens.push_back(AsmToken::Eof);
-
- lexAndCheckTokens(AsmStr, ExpectedTokens);
-}
-
-TEST_F(SystemZAsmLexerTest, CheckStrictCommentString4) {
- StringRef AsmStr = "# abc\n/* def */// xyz";
-
- // Setup.
- MUPMAI->setCommentString("*");
- MUPMAI->setAllowAdditionalComments(false);
- MUPMAI->setRestrictCommentStringToStartOfStatement(true);
- setupCallToAsmParser(AsmStr);
-
- // Lex initially to get the string.
- Parser->getLexer().Lex();
-
- SmallVector<AsmToken::TokenKind> ExpectedTokens;
- ExpectedTokens.push_back(AsmToken::Hash); // "#"
+ ExpectedTokens.push_back(AsmToken::Identifier); // "#"
+ ExpectedTokens.push_back(AsmToken::Space); // " "
ExpectedTokens.push_back(AsmToken::Identifier); // "abc"
ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
ExpectedTokens.push_back(AsmToken::Slash); // "/"
ExpectedTokens.push_back(AsmToken::Star); // "*"
+ ExpectedTokens.push_back(AsmToken::Space); // " "
ExpectedTokens.push_back(AsmToken::Identifier); // "def"
+ ExpectedTokens.push_back(AsmToken::Space); // " "
ExpectedTokens.push_back(AsmToken::Star); // "*"
ExpectedTokens.push_back(AsmToken::Slash); // "/"
ExpectedTokens.push_back(AsmToken::Slash); // "/"
ExpectedTokens.push_back(AsmToken::Slash); // "/"
+ ExpectedTokens.push_back(AsmToken::Space); // " "
ExpectedTokens.push_back(AsmToken::Identifier); // "xyz"
ExpectedTokens.push_back(AsmToken::EndOfStatement);
ExpectedTokens.push_back(AsmToken::Eof);
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckStrictCommentString5) {
- StringRef AsmStr = "#abc\n/* def */// xyz";
-
- // Setup.
- MUPMAI->setCommentString("*");
- MUPMAI->setAllowAdditionalComments(false);
- setupCallToAsmParser(AsmStr);
-
- // Lex initially to get the string.
- Parser->getLexer().Lex();
-
- SmallVector<AsmToken::TokenKind> ExpectedTokens;
- ExpectedTokens.push_back(AsmToken::Hash); // "#"
- ExpectedTokens.push_back(AsmToken::Identifier); // "abc"
- ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
- ExpectedTokens.push_back(AsmToken::Slash); // "/"
- ExpectedTokens.push_back(AsmToken::EndOfStatement); // "* def */// xyz"
- ExpectedTokens.push_back(AsmToken::Eof);
-
- lexAndCheckTokens(AsmStr, ExpectedTokens);
-}
-
-TEST_F(SystemZAsmLexerTest, CheckValidHLASMIntegers) {
+TEST_F(SystemZAsmLexerZOS, CheckValidHLASMIntegers) {
StringRef AsmStr = "123\n000123\n1999\n007\n12300\n12021\n";
// StringRef AsmStr = "123";
// Setup.
setupCallToAsmParser(AsmStr);
- Parser->getLexer().setLexHLASMIntegers(true);
// Lex initially to get the string.
Parser->getLexer().Lex();
lexAndCheckIntegerTokensAndValues(AsmStr, ExpectedValues);
}
-TEST_F(SystemZAsmLexerTest, CheckInvalidHLASMIntegers) {
+TEST_F(SystemZAsmLexerZOS, CheckInvalidHLASMIntegers) {
StringRef AsmStr = "0b0101\n0xDEADBEEF\nfffh\n.133\n";
// Setup.
setupCallToAsmParser(AsmStr);
- Parser->getLexer().setLexHLASMIntegers(true);
// Lex initially to get the string.
Parser->getLexer().Lex();
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckDefaultIntegers) {
+TEST_F(SystemZAsmLexerLinux, CheckDefaultIntegers) {
StringRef AsmStr = "0b0101\n0xDEADBEEF\nfffh\n";
// Setup.
lexAndCheckIntegerTokensAndValues(AsmStr, ExpectedValues);
}
-TEST_F(SystemZAsmLexerTest, CheckDefaultFloats) {
+TEST_F(SystemZAsmLexerLinux, CheckDefaultFloats) {
StringRef AsmStr = "0.333\n1.3\n2.5\n3.0\n";
// Setup.
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckDefaultQuestionAtStartOfIdentifier) {
+TEST_F(SystemZAsmLexerLinux, CheckDefaultQuestionAtStartOfIdentifier) {
StringRef AsmStr = "?lh1?23";
// Setup.
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckAcceptQuestionAtStartOfIdentifier) {
- StringRef AsmStr = "?????lh1?23";
-
- // Setup.
- MUPMAI->setAllowQuestionAtStartOfIdentifier(true);
- setupCallToAsmParser(AsmStr);
-
- // Lex initially to get the string.
- Parser->getLexer().Lex();
-
- SmallVector<AsmToken::TokenKind> ExpectedTokens(
- {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
- lexAndCheckTokens(AsmStr, ExpectedTokens);
-}
-
-TEST_F(SystemZAsmLexerTest, CheckDefaultAtAtStartOfIdentifier) {
+TEST_F(SystemZAsmLexerLinux, CheckDefaultAtAtStartOfIdentifier) {
StringRef AsmStr = "@@lh1?23";
// Setup.
- MUPMAI->setAllowQuestionAtStartOfIdentifier(true);
setupCallToAsmParser(AsmStr);
// Lex initially to get the string.
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckAcceptAtAtStartOfIdentifier) {
+TEST_F(SystemZAsmLexerZOS, CheckAcceptAtAtStartOfIdentifier) {
StringRef AsmStr = "@@lh1?23";
// Setup.
- MUPMAI->setAllowAtAtStartOfIdentifier(true);
setupCallToAsmParser(AsmStr);
// Lex initially to get the string.
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckAccpetAtAtStartOfIdentifier2) {
- StringRef AsmStr = "@@lj1?23";
-
- // Setup.
- MUPMAI->setCommentString("@");
- MUPMAI->setAllowAtAtStartOfIdentifier(true);
- setupCallToAsmParser(AsmStr);
-
- // Lex initially to get the string.
- Parser->getLexer().Lex();
-
- // "@@lj1?23" -> still lexed as a comment as that takes precedence.
- SmallVector<AsmToken::TokenKind> ExpectedTokens(
- {AsmToken::EndOfStatement, AsmToken::Eof});
- lexAndCheckTokens(AsmStr, ExpectedTokens);
-}
-
-TEST_F(SystemZAsmLexerTest, CheckDefaultDollarAtStartOfIdentifier) {
+TEST_F(SystemZAsmLexerLinux, CheckDefaultDollarAtStartOfIdentifier) {
StringRef AsmStr = "$$ac$c";
// Setup.
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckAcceptDollarAtStartOfIdentifier) {
+TEST_F(SystemZAsmLexerZOS, CheckAcceptDollarAtStartOfIdentifier) {
StringRef AsmStr = "$$ab$c";
// Setup.
- MUPMAI->setAllowDollarAtStartOfIdentifier(true);
setupCallToAsmParser(AsmStr);
// Lex initially to get the string.
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckAcceptHashAtStartOfIdentifier) {
+TEST_F(SystemZAsmLexerZOS, CheckAcceptHashAtStartOfIdentifier) {
StringRef AsmStr = "##a#b$c";
// Setup.
- MUPMAI->setAllowHashAtStartOfIdentifier(true);
- MUPMAI->setCommentString("*");
- MUPMAI->setAllowAdditionalComments(false);
setupCallToAsmParser(AsmStr);
- Parser->getLexer().setAllowHashInIdentifier(true);
// Lex initially to get the string.
Parser->getLexer().Lex();
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckAcceptHashAtStartOfIdentifier2) {
+TEST_F(SystemZAsmLexerLinux, CheckAcceptHashAtStartOfIdentifier2) {
StringRef AsmStr = "##a#b$c";
// Setup.
- MUPMAI->setAllowHashAtStartOfIdentifier(true);
setupCallToAsmParser(AsmStr);
- Parser->getLexer().setAllowHashInIdentifier(true);
// Lex initially to get the string.
Parser->getLexer().Lex();
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckAcceptHashAtStartOfIdentifier3) {
+TEST_F(SystemZAsmLexerZOS, CheckAcceptHashAtStartOfIdentifier3) {
StringRef AsmStr = "##a#b$c";
// Setup.
- MUPMAI->setAllowHashAtStartOfIdentifier(true);
- MUPMAI->setCommentString("*");
setupCallToAsmParser(AsmStr);
- Parser->getLexer().setAllowHashInIdentifier(true);
// Lex initially to get the string.
Parser->getLexer().Lex();
- // By default, the AsmLexer treats strings that start with "#"
- // as a line comment.
- // Hence, "##a$b$c" is lexed as a line comment irrespective
- // of whether the AllowHashAtStartOfIdentifier attribute is set to true.
SmallVector<AsmToken::TokenKind> ExpectedTokens(
- {AsmToken::EndOfStatement, AsmToken::Eof});
+ {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckAcceptHashAtStartOfIdentifier4) {
+TEST_F(SystemZAsmLexerZOS, CheckAcceptHashAtStartOfIdentifier4) {
StringRef AsmStr = "##a#b$c";
// Setup.
- MUPMAI->setAllowHashAtStartOfIdentifier(true);
- MUPMAI->setCommentString("*");
- MUPMAI->setAllowAdditionalComments(false);
setupCallToAsmParser(AsmStr);
- Parser->getLexer().setAllowHashInIdentifier(true);
// Lex initially to get the string.
Parser->getLexer().Lex();
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckRejectDotAsCurrentPC) {
+TEST_F(SystemZAsmLexerZOS, CheckRejectDotAsCurrentPC) {
StringRef AsmStr = ".-4";
// Setup.
- MUPMAI->setAllowDotIsPC(false);
setupCallToAsmParser(AsmStr);
// Lex initially to get the string.
EXPECT_EQ(Parser->hasPendingError(), true);
}
-TEST_F(SystemZAsmLexerTest, CheckRejectStarAsCurrentPC) {
+TEST_F(SystemZAsmLexerLinux, CheckRejectStarAsCurrentPC) {
StringRef AsmStr = "*-4";
// Setup.
EXPECT_EQ(Parser->hasPendingError(), true);
}
-TEST_F(SystemZAsmLexerTest, CheckRejectCharLiterals) {
+TEST_F(SystemZAsmLexerZOS, CheckRejectCharLiterals) {
StringRef AsmStr = "abc 'd'";
// Setup.
setupCallToAsmParser(AsmStr);
- Parser->getLexer().setLexHLASMStrings(true);
// Lex initially to get the string.
Parser->getLexer().Lex();
SmallVector<AsmToken::TokenKind> ExpectedTokens(
- {AsmToken::Identifier, AsmToken::Error, AsmToken::Error,
+ {AsmToken::Identifier, AsmToken::Space, AsmToken::Error, AsmToken::Error,
AsmToken::EndOfStatement, AsmToken::Eof});
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckRejectStringLiterals) {
+TEST_F(SystemZAsmLexerZOS, CheckRejectStringLiterals) {
StringRef AsmStr = "abc \"ef\"";
// Setup.
setupCallToAsmParser(AsmStr);
- Parser->getLexer().setLexHLASMStrings(true);
// Lex initially to get the string.
Parser->getLexer().Lex();
SmallVector<AsmToken::TokenKind> ExpectedTokens(
- {AsmToken::Identifier, AsmToken::Error, AsmToken::Identifier,
- AsmToken::Error, AsmToken::EndOfStatement, AsmToken::Eof});
+ {AsmToken::Identifier, AsmToken::Space, AsmToken::Error,
+ AsmToken::Identifier, AsmToken::Error, AsmToken::EndOfStatement,
+ AsmToken::Eof});
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
-TEST_F(SystemZAsmLexerTest, CheckPrintAcceptableSymbol) {
+TEST_F(SystemZAsmLexerZOS, CheckPrintAcceptableSymbol) {
+ std::string AsmStr = "ab13_$.@";
+ EXPECT_EQ(true, MAI->isValidUnquotedName(AsmStr));
+ AsmStr += "#";
+ EXPECT_EQ(true, MAI->isValidUnquotedName(AsmStr));
+}
+
+TEST_F(SystemZAsmLexerLinux, CheckPrintAcceptableSymbol) {
std::string AsmStr = "ab13_$.@";
- EXPECT_EQ(true, MUPMAI->isValidUnquotedName(AsmStr));
+ EXPECT_EQ(true, MAI->isValidUnquotedName(AsmStr));
AsmStr += "#";
- EXPECT_EQ(false, MUPMAI->isValidUnquotedName(AsmStr));
+ EXPECT_EQ(false, MAI->isValidUnquotedName(AsmStr));
}
-TEST_F(SystemZAsmLexerTest, CheckLabelCaseUpperCase2) {
- StringRef AsmStr = "label\nlabel";
+TEST_F(SystemZAsmLexerZOS, CheckLabelCaseUpperCase) {
+ StringRef AsmStr = "label";
// Setup.
setupCallToAsmParser(AsmStr);
const MCSymbolRefExpr *SymbolExpr = dyn_cast<MCSymbolRefExpr>(Expr);
EXPECT_NE(SymbolExpr, nullptr);
EXPECT_NE(&SymbolExpr->getSymbol(), nullptr);
- EXPECT_EQ((&SymbolExpr->getSymbol())->getName(), StringRef("label"));
+ EXPECT_EQ((&SymbolExpr->getSymbol())->getName(), StringRef("LABEL"));
+}
- // Lex the end of statement token.
- Parser->getLexer().Lex();
+TEST_F(SystemZAsmLexerLinux, CheckLabelUpperCase2) {
+ StringRef AsmStr = "label";
- MUPMAI->setEmitLabelsInUpperCase(true);
+ // Setup.
+ setupCallToAsmParser(AsmStr);
- ParsePrimaryExpr = Parser->parseExpression(Expr);
+ // Lex initially to get the string.
+ Parser->getLexer().Lex();
+
+ const MCExpr *Expr;
+ bool ParsePrimaryExpr = Parser->parseExpression(Expr);
EXPECT_EQ(ParsePrimaryExpr, false);
- SymbolExpr = dyn_cast<MCSymbolRefExpr>(Expr);
+ const MCSymbolRefExpr *SymbolExpr = dyn_cast<MCSymbolRefExpr>(Expr);
EXPECT_NE(SymbolExpr, nullptr);
EXPECT_NE(&SymbolExpr->getSymbol(), nullptr);
- EXPECT_EQ((&SymbolExpr->getSymbol())->getName(), StringRef("LABEL"));
+ EXPECT_EQ((&SymbolExpr->getSymbol())->getName(), StringRef("label"));
}
} // end anonymous namespace