diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2013-12-17 20:17:41 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2013-12-23 13:46:49 +0100 |
commit | 0909c0295f901b3b656335ef08352a90a4e01ad0 (patch) | |
tree | b40237ba64b61289fc139513958586dc685f203e /src/plugins/cpptools/cpptoolsplugin.h | |
parent | ed2d98577a53d5c023f972683109ca2c44b9db21 (diff) | |
download | qt-creator-0909c0295f901b3b656335ef08352a90a4e01ad0.tar.gz |
CppTools: Make completion tests data-driven
Mostly done using the following Ruby script:
Fname = 'src/plugins/cpptools/cppcompletion_test.cpp'
s = File.read(Fname)
mod = s.gsub(/(?<declaration>void CppToolsPlugin::test_(?<test_name>[^(]+)\(\)\n\{)(?<body>.*?\n)\}/m) { |func|
match = $~
declaration = match['declaration']
body = match['body']
test_name = match['test_name'].sub('_data', '')
final = body.gsub(/(?:completions.clear\(\);\s+)?(?: +)[^\n]* =\n(?<code>.*?);\s*(?<completions>(?:completions.append\(QLatin1String\("[^"]*"\)\);\s*)*)QTest::newRow\("case: (?<name>.+?)"\)\s*<< code << _\("(?<prefix>[^"]+)"\) << completions;/m) {
m = $~
res = " QTest::newRow(\"#{test_name}: #{m['name']}\") << _(\n#{m['code'].rstrip}\n ) << _(\"#{m['prefix']}\") << (QStringList()"
m['completions'].scan(/completions.append\((.+)\);/) { |comp|
res << "\n << #{comp[0]}"
}
res + ');'
}.gsub(/(?: +)[^\n]* =\n(?<code>.*?);\n\s*CompletionTestCase test\(.+?, "(?<prefix>.+?)"\);\s*QStringList expected;\s*(?<completions>(?:expected.append\(QLatin1String\("[^"]*"\)\);\s*)*)const QStringList completions = test.getCompletions\(\);\s*QCOMPARE\(completions, expected\);/m) {
m = $~
res = " QTest::newRow(\"#{test_name}\") << _(\n#{m['code'].rstrip}\n ) << _(\"#{m['prefix']}\") << (QStringList()"
m['completions'].scan(/expected.append\((.+)\);/) { |comp|
res << "\n << #{comp[0]}"
}
res + ');'
}.gsub(/(?: +)[^\n]* =\n(?<code>.*?);\n\s*CompletionTestCase test\(.+?(?:, (?<prefix>".+?"))?\);\s*(?:const )?QStringList completions = test.getCompletions\(\);\s*QCOMPARE\(completions.size\(\), \d+\);(?<completions>(?:\s*QVERIFY\(completions.contains\([^\n]+\);)*)\n/m) { |mm|
m = $~
res = " QTest::newRow(\"#{test_name}\") << _(\n#{m['code'].rstrip}\n ) << _(#{m['prefix']}) << (QStringList()"
m['completions'].scan(/QVERIFY\(completions.contains\((.+?)\)\);/) { |comp|
res << "\n << #{comp[0]}"
}
res + ");\n"
}.gsub(/(?: +)[^\n]* =\n(?<code>.*?);\n\s*CompletionTestCase test\(.+?(?:, (?<prefix>".+?"))?\);\s*bool replaceAccessOperator = false;\s*const QStringList completions = test.getCompletions\(\&replaceAccessOperator\);\s*QCOMPARE\(completions.size\(\), \d+\);(?<completions>(?:\s*QVERIFY\(completions.contains\([^\n]+\);)*)\s*QVERIFY\((?<replace>!?)[^)]*\);\n/m) { |mm|
m = $~
res = " QTest::newRow(\"#{test_name}\") << _(\n#{m['code'].rstrip}\n ) << _(#{m['prefix']}) << (QStringList()"
m['completions'].scan(/QVERIFY\(completions.contains\((.+?)\)\);/) { |comp|
res << "\n << #{comp[0]}"
}
res + ")\n << #{m['replace'].empty?};\n"
}
if final == body or final['QTest::addColumn']
declaration + final + "}"
else
final
end
}.gsub(/QTest::newRow\("([^"]+)"/) { |m|
name = $1
if name.size > 73
space = name[0..73].rindex(/[ _]/)
"QTest::newRow(\"#{name[0..space]}\"\n \"#{name[space+1..-1]}\""
else
m
end
}.gsub(/\s+QTest::newRow/, "\n\n QTest::newRow")
if mod != s
File.open(Fname, 'wt').write(mod)
end
Change-Id: Id6bfb03cdf31ac27b36028fcdc861c340a5398f4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cpptoolsplugin.h')
-rw-r--r-- | src/plugins/cpptools/cpptoolsplugin.h | 107 |
1 files changed, 9 insertions, 98 deletions
diff --git a/src/plugins/cpptools/cpptoolsplugin.h b/src/plugins/cpptools/cpptoolsplugin.h index bb5cd9b3c6..9ea623f10b 100644 --- a/src/plugins/cpptools/cpptoolsplugin.h +++ b/src/plugins/cpptools/cpptoolsplugin.h @@ -91,106 +91,20 @@ private slots: void test_codegen_definition_middle_member_surrounded_by_undefined(); void test_codegen_definition_member_specific_file(); - void test_completion_forward_declarations_present(); - void test_completion_inside_parentheses_c_style_conversion(); - void test_completion_inside_parentheses_cast_operator_conversion(); void test_completion_basic_1(); - void test_completion_template_1(); - void test_completion_template_2(); - void test_completion_template_3(); - void test_completion_template_4(); - void test_completion_template_5(); - void test_completion_template_6(); - void test_completion_template_7(); - void test_completion_type_of_pointer_is_typedef(); - void test_completion_instantiate_full_specialization(); - void test_completion_template_as_base(); - void test_completion_template_as_base_data(); - void test_completion_use_global_identifier_as_base_class(); - void test_completion_use_global_identifier_as_base_class_data(); - void test_completion_base_class_has_name_the_same_as_derived(); - void test_completion_base_class_has_name_the_same_as_derived_data(); - void test_completion_cyclic_inheritance(); - void test_completion_cyclic_inheritance_data(); - void test_completion_template_function(); + void test_completion_template_function_data(); - void test_completion_enclosing_template_class(); - void test_completion_enclosing_template_class_data(); - void test_completion_instantiate_nested_class_when_enclosing_is_template(); - void test_completion_instantiate_nested_of_nested_class_when_enclosing_is_template(); - void test_completion_instantiate_template_with_default_argument_type(); - void test_completion_instantiate_template_with_default_argument_type_as_template(); - void test_completion_member_access_operator_1(); - - void test_completion_typedef_of_type_and_decl_of_type_no_replace_access_operator(); - void test_completion_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator(); - void test_completion_typedef_of_type_and_decl_of_pointer_replace_access_operator(); - void test_completion_typedef_of_pointer_and_decl_of_type_replace_access_operator(); - - void test_completion_predecl_typedef_of_type_and_decl_of_pointer_replace_access_operator(); - void test_completion_predecl_typedef_of_type_and_decl_type_no_replace_access_operator(); - void test_completion_predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator(); - void test_completion_predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator(); - - void test_completion_typedef_of_pointer(); - void test_completion_typedef_of_pointer_inside_function(); - void test_completion_typedef_is_inside_function_before_declaration_block(); - void test_completion_resolve_complex_typedef_with_template(); - void test_completion_template_specialization_with_pointer(); - void test_completion_typedef_using_templates1(); - void test_completion_typedef_using_templates2(); - void test_completion_namespace_alias_with_many_namespace_declarations(); - void test_completion_QTCREATORBUG9098(); - void test_completion_type_and_using_declaration(); - void test_completion_type_and_using_declaration_data(); - void test_completion_instantiate_template_with_anonymous_class(); - void test_completion_instantiate_template_function(); - void test_completion_crash_cloning_template_class_QTCREATORBUG9329(); - void test_completion_recursive_auto_declarations1_QTCREATORBUG9503(); - void test_completion_recursive_auto_declarations2_QTCREATORBUG9503(); - void test_completion_recursive_typedefs_declarations1(); - void test_completion_recursive_typedefs_declarations2(); - void test_completion_recursive_using_declarations1(); - void test_completion_recursive_using_declarations2(); - void test_completion_recursive_using_typedef_declarations(); - void test_completion_recursive_typedefs_in_templates1(); - void test_completion_recursive_typedefs_in_templates2(); + void test_completion_template_function(); + + void test_completion_data(); + void test_completion(); + + void test_completion_member_access_operator_data(); + void test_completion_member_access_operator(); + void test_completion_prefix_first_QTCREATORBUG_8737(); void test_completion_prefix_first_QTCREATORBUG_9236(); - void test_completion_class_declaration_inside_function_or_block_QTCREATORBUG3620(); - void test_completion_class_declaration_inside_function_or_block_QTCREATORBUG3620_data(); - void test_completion_namespace_alias_inside_function_or_block_QTCREATORBUG166(); - void test_completion_namespace_alias_inside_function_or_block_QTCREATORBUG166_data(); - void test_completion_class_declaration_inside_function_or_block_QTCREATORBUG3620_static_member(); - void test_completion_enum_inside_block_inside_function_QTCREATORBUG5456(); - void test_completion_enum_inside_function_QTCREATORBUG5456(); - - void test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG9169_1(); - void test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG9169_2(); - void test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_1(); - void test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_2(); - void test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_3(); - - //lambda - void test_completion_lambdaCalls_1(); - void test_completion_lambdaCalls_2(); - void test_completion_lambdaCalls_3(); - void test_completion_lambdaCalls_4(); - void test_completion_lambdaCalls_5(); - - void test_completion_member_of_class_accessed_by_using_QTCREATORBUG9037_1(); - void test_completion_member_of_class_accessed_by_using_QTCREATORBUG9037_2(); - - void test_completion_local_type_and_member_1(); - void test_completion_local_type_and_member_2(); - void test_completion_local_type_and_member_3(); - void test_completion_local_type_and_member_4(); - void test_completion_local_type_and_member_5(); - void test_completion_local_type_and_member_6(); - - void test_completion_signals_hide_QPrivateSignal(); - void test_format_pointerdeclaration_in_simpledeclarations(); void test_format_pointerdeclaration_in_simpledeclarations_data(); void test_format_pointerdeclaration_in_controlflowstatements(); @@ -235,9 +149,6 @@ private slots: void test_typehierarchy_data(); void test_typehierarchy(); - -private: - void test_completion(); #endif private: |