forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/3.0'
This commit is contained in:
@@ -175,6 +175,8 @@ private slots:
|
||||
void test_checksymbols_VirtualMethodUse();
|
||||
void test_checksymbols_LabelUse();
|
||||
void test_checksymbols_MacroUse();
|
||||
void test_checksymbols_Macros__FILE__LINE__DATE__TIME__1();
|
||||
void test_checksymbols_Macros__FILE__LINE__DATE__TIME__2();
|
||||
void test_checksymbols_FunctionUse();
|
||||
void test_checksymbols_PseudoKeywordUse();
|
||||
void test_checksymbols_StaticUse();
|
||||
@@ -326,6 +328,55 @@ void tst_CheckSymbols::test_checksymbols_MacroUse()
|
||||
TestData::check(source, expectedUses, macroUses);
|
||||
}
|
||||
|
||||
void tst_CheckSymbols::test_checksymbols_Macros__FILE__LINE__DATE__TIME__1()
|
||||
{
|
||||
const QByteArray source =
|
||||
"#define FILE_DATE_TIME __FILE__ \" / \" __DATE__ \" / \" __TIME__\n"
|
||||
"#define LINE_NUMBER 0 + __LINE__\n"
|
||||
"\n"
|
||||
"void f()\n"
|
||||
"{\n"
|
||||
" class Printer;\n"
|
||||
" Printer::printText(FILE_DATE_TIME); Printer::printInteger(LINE_NUMBER); Printer::nl();\n"
|
||||
" return;\n"
|
||||
"}\n";
|
||||
const QList<Use> expectedUses = QList<Use>()
|
||||
<< Use(4, 6, 1, CppHighlightingSupport::FunctionUse)
|
||||
<< Use(6, 11, 7, CppHighlightingSupport::TypeUse)
|
||||
<< Use(6, 11, 7, CppHighlightingSupport::TypeUse)
|
||||
<< Use(7, 5, 7, CppHighlightingSupport::TypeUse)
|
||||
<< Use(7, 41, 7, CppHighlightingSupport::TypeUse)
|
||||
<< Use(7, 77, 7, CppHighlightingSupport::TypeUse)
|
||||
;
|
||||
|
||||
TestData::check(source, expectedUses);
|
||||
}
|
||||
|
||||
void tst_CheckSymbols::test_checksymbols_Macros__FILE__LINE__DATE__TIME__2()
|
||||
{
|
||||
const QByteArray source =
|
||||
"void f()\n"
|
||||
"{\n"
|
||||
" class Printer;\n"
|
||||
" Printer::printInteger(__LINE__); Printer::printText(__FILE__); Printer::nl();\n"
|
||||
" Printer::printText(__DATE__); Printer::printText(__TIME__); Printer::nl();\n"
|
||||
" return;\n"
|
||||
"}\n";
|
||||
const QList<Use> expectedUses = QList<Use>()
|
||||
<< Use(1, 6, 1, CppHighlightingSupport::FunctionUse)
|
||||
<< Use(3, 11, 7, CppHighlightingSupport::TypeUse)
|
||||
<< Use(3, 11, 7, CppHighlightingSupport::TypeUse)
|
||||
<< Use(4, 5, 7, CppHighlightingSupport::TypeUse)
|
||||
<< Use(4, 38, 7, CppHighlightingSupport::TypeUse)
|
||||
<< Use(4, 68, 7, CppHighlightingSupport::TypeUse)
|
||||
<< Use(5, 5, 7, CppHighlightingSupport::TypeUse)
|
||||
<< Use(5, 35, 7, CppHighlightingSupport::TypeUse)
|
||||
<< Use(5, 65, 7, CppHighlightingSupport::TypeUse)
|
||||
;
|
||||
|
||||
TestData::check(source, expectedUses);
|
||||
}
|
||||
|
||||
void tst_CheckSymbols::test_checksymbols_FunctionUse()
|
||||
{
|
||||
const QByteArray source =
|
||||
|
||||
@@ -334,6 +334,7 @@ private slots:
|
||||
void unfinished_function_like_macro_call();
|
||||
void nasty_macro_expansion();
|
||||
void glib_attribute();
|
||||
void builtin__FILE__();
|
||||
void blockSkipping();
|
||||
void includes_1();
|
||||
void dont_eagerly_expand();
|
||||
@@ -783,6 +784,27 @@ void tst_Preprocessor::glib_attribute()
|
||||
QCOMPARE(preprocessed, result____);
|
||||
}
|
||||
|
||||
void tst_Preprocessor::builtin__FILE__()
|
||||
{
|
||||
Client *client = 0; // no client.
|
||||
Environment env;
|
||||
|
||||
Preprocessor preprocess(client, &env);
|
||||
QByteArray preprocessed = preprocess.run(
|
||||
QLatin1String("some-file.c"),
|
||||
QByteArray("const char *f = __FILE__\n"
|
||||
));
|
||||
const QByteArray result____ =
|
||||
"# 1 \"some-file.c\"\n"
|
||||
"const char *f =\n"
|
||||
"# expansion begin 16,8 ~1\n"
|
||||
"\"some-file.c\"\n"
|
||||
"# expansion end\n"
|
||||
"# 2 \"some-file.c\"\n";
|
||||
|
||||
QCOMPARE(preprocessed, result____);
|
||||
}
|
||||
|
||||
void tst_Preprocessor::comparisons_data()
|
||||
{
|
||||
QTest::addColumn<QString>("infile");
|
||||
|
||||
Reference in New Issue
Block a user