Log Message
Add unittests for the C++ parser of prepare-ChangeLog https://bugs.webkit.org/show_bug.cgi?id=75191
Reviewed by Ryosuke Niwa. cpp_unittests.cpp is the unittests for get_function_line_ranges_for_cpp() of prepare-ChangeLog. * Scripts/prepare-ChangeLog: (get_function_line_ranges): Renames get_function_line_ranges_for_c() to get_function_line_ranges_for_cpp(). * Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl: * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt: Added. * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp: Added. (func1): (func2): (func3): (func4): (func5): (func6): (func7): (func8): (func9): (func10): (func11): (func12): (func13): (func14): (func15): (funcOverloaded): (Class::func16): (Class1::Class2::func17): (Class2::func18): (Class2::func19): (Class2::func20): (Class2::func21): (Class2::func22): (func23): (func24): (Class2::func25): (Class1::func26): (Class2::func27): (Class3::func28): (Class7::operator+): (Class100::Class100): (Class101::~Class101): (Class102::Class102): (Class103::Class103): (Struct1::func29): (Struct2::func30): (NameSpace1::func30): (NameSpace1::NameSpace2::func31):
Modified Paths
- trunk/Tools/ChangeLog
- trunk/Tools/Scripts/prepare-ChangeLog
- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl
Added Paths
Diff
Modified: trunk/Tools/ChangeLog (103668 => 103669)
--- trunk/Tools/ChangeLog 2011-12-25 08:15:16 UTC (rev 103668)
+++ trunk/Tools/ChangeLog 2011-12-25 08:24:07 UTC (rev 103669)
@@ -1,5 +1,60 @@
2011-12-24 Kentaro Hara <hara...@chromium.org>
+ Add unittests for the C++ parser of prepare-ChangeLog
+ https://bugs.webkit.org/show_bug.cgi?id=75191
+
+ Reviewed by Ryosuke Niwa.
+
+ cpp_unittests.cpp is the unittests for get_function_line_ranges_for_cpp()
+ of prepare-ChangeLog.
+
+ * Scripts/prepare-ChangeLog:
+ (get_function_line_ranges): Renames get_function_line_ranges_for_c()
+ to get_function_line_ranges_for_cpp().
+ * Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl:
+ * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt: Added.
+ * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp: Added.
+ (func1):
+ (func2):
+ (func3):
+ (func4):
+ (func5):
+ (func6):
+ (func7):
+ (func8):
+ (func9):
+ (func10):
+ (func11):
+ (func12):
+ (func13):
+ (func14):
+ (func15):
+ (funcOverloaded):
+ (Class::func16):
+ (Class1::Class2::func17):
+ (Class2::func18):
+ (Class2::func19):
+ (Class2::func20):
+ (Class2::func21):
+ (Class2::func22):
+ (func23):
+ (func24):
+ (Class2::func25):
+ (Class1::func26):
+ (Class2::func27):
+ (Class3::func28):
+ (Class7::operator+):
+ (Class100::Class100):
+ (Class101::~Class101):
+ (Class102::Class102):
+ (Class103::Class103):
+ (Struct1::func29):
+ (Struct2::func30):
+ (NameSpace1::func30):
+ (NameSpace1::NameSpace2::func31):
+
+2011-12-24 Kentaro Hara <hara...@chromium.org>
+
Add unittests for the Java parser of prepare-ChangeLog
https://bugs.webkit.org/show_bug.cgi?id=75195
Modified: trunk/Tools/Scripts/prepare-ChangeLog (103668 => 103669)
--- trunk/Tools/Scripts/prepare-ChangeLog 2011-12-25 08:15:16 UTC (rev 103668)
+++ trunk/Tools/Scripts/prepare-ChangeLog 2011-12-25 08:24:07 UTC (rev 103669)
@@ -82,7 +82,7 @@
sub generateNewChangeLogs($$$$$$$$$$$);
sub getLatestChangeLogs($);
sub get_function_line_ranges($$);
-sub get_function_line_ranges_for_c($$);
+sub get_function_line_ranges_for_cpp($$);
sub get_function_line_ranges_for_java($$);
sub get_function_line_ranges_for_javascript($$);
sub get_function_line_ranges_for_perl($$);
@@ -551,7 +551,7 @@
# Try to determine the source language based on the file extension.
- return get_function_line_ranges_for_c($file_handle, $file_name) if $file_name =~ /\.(c|cpp|m|mm|h)$/;
+ return get_function_line_ranges_for_cpp($file_handle, $file_name) if $file_name =~ /\.(c|cpp|m|mm|h)$/;
return get_function_line_ranges_for_java($file_handle, $file_name) if $file_name =~ /\.java$/;
return get_function_line_ranges_for_javascript($file_handle, $file_name) if $file_name =~ /\.js$/;
return get_selector_line_ranges_for_css($file_handle, $file_name) if $file_name =~ /\.css$/;
@@ -607,7 +607,7 @@
#
# Result is a list of triples: [ start_line, end_line, function_name ].
-sub get_function_line_ranges_for_c($$)
+sub get_function_line_ranges_for_cpp($$)
{
my ($file_handle, $file_name) = @_;
Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl (103668 => 103669)
--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl 2011-12-25 08:15:16 UTC (rev 103668)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl 2011-12-25 08:24:07 UTC (rev 103669)
@@ -34,7 +34,8 @@
my %testFiles = ("perl_unittests.pl" => "perl",
"python_unittests.py" => "python",
- "java_unittests.java" => "java");
+ "java_unittests.java" => "java",
+ "cpp_unittests.cpp" => "cpp");
my $resetResults;
GetOptions('reset-results' => \$resetResults);
Added: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt (0 => 103669)
--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt (rev 0)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt 2011-12-25 08:24:07 UTC (rev 103669)
@@ -0,0 +1,197 @@
+[
+ [
+ '20',
+ '22',
+ 'func1'
+ ],
+ [
+ '24',
+ '27',
+ 'func2'
+ ],
+ [
+ '29',
+ '29',
+ 'func3'
+ ],
+ [
+ '33',
+ '36',
+ 'func5'
+ ],
+ [
+ '44',
+ '46',
+ 'func6'
+ ],
+ [
+ '52',
+ '54',
+ 'func7'
+ ],
+ [
+ '58',
+ '60',
+ 'func8'
+ ],
+ [
+ '62',
+ '64',
+ 'func9'
+ ],
+ [
+ '67',
+ '69',
+ 'func10'
+ ],
+ [
+ '76',
+ '78',
+ 'func11'
+ ],
+ [
+ '85',
+ '87',
+ 'func12'
+ ],
+ [
+ '89',
+ '91',
+ 'func13'
+ ],
+ [
+ '93',
+ '97',
+ 'func14'
+ ],
+ [
+ '99',
+ '102',
+ 'func15'
+ ],
+ [
+ '104',
+ '106',
+ 'funcOverloaded'
+ ],
+ [
+ '108',
+ '110',
+ 'funcOverloaded'
+ ],
+ [
+ '112',
+ '114',
+ 'funcOverloaded'
+ ],
+ [
+ '116',
+ '118',
+ 'Class::func16'
+ ],
+ [
+ '120',
+ '122',
+ 'Class1::Class2::func17'
+ ],
+ [
+ '124',
+ '126',
+ 'Class2::func18'
+ ],
+ [
+ '128',
+ '130',
+ 'Class2::func19'
+ ],
+ [
+ '132',
+ '134',
+ 'Class2::func20'
+ ],
+ [
+ '136',
+ '138',
+ 'Class2::func21'
+ ],
+ [
+ '140',
+ '142',
+ 'Class2::func22'
+ ],
+ [
+ '144',
+ '146',
+ 'func23'
+ ],
+ [
+ '149',
+ '151',
+ 'func24'
+ ],
+ [
+ '153',
+ '155',
+ 'Class2::func25'
+ ],
+ [
+ '162',
+ '164',
+ 'Class1::func26'
+ ],
+ [
+ '167',
+ '169',
+ 'Class2::func27'
+ ],
+ [
+ '173',
+ '175',
+ 'Class3::func28'
+ ],
+ [
+ '179',
+ '182',
+ 'Class7::operator+'
+ ],
+ [
+ '185',
+ '187',
+ 'Class100::Class100'
+ ],
+ [
+ '189',
+ '191',
+ 'Class101::~Class101'
+ ],
+ [
+ '193',
+ '196',
+ 'Class102::Class102'
+ ],
+ [
+ '198',
+ '201',
+ 'Class103::Class103'
+ ],
+ [
+ '208',
+ '210',
+ 'Struct1::func29'
+ ],
+ [
+ '213',
+ '215',
+ 'Struct2::func30'
+ ],
+ [
+ '220',
+ '222',
+ 'NameSpace1::func30'
+ ],
+ [
+ '229',
+ '231',
+ 'NameSpace1::NameSpace2::func31'
+ ]
+]
Added: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp (0 => 103669)
--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp (rev 0)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp 2011-12-25 08:24:07 UTC (rev 103669)
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+void func1()
+{
+}
+
+void func2()
+{
+ return 123;
+}
+
+void func3() { return 123; }
+
+void func4();
+
+void func5()
+{
+ /* comment */
+}
+
+/*
+void funcInsideComment()
+{
+}
+*/
+
+void func6()
+{
+}
+
+#define MACRO 123 \
+ 456 \
+ 789
+
+void func7()
+{
+}
+
+#if 1 || 1 || \
+ 1 || 1 || 1
+void func8()
+{
+}
+#else
+void func9()
+{
+}
+#endif
+
+void func10()
+{
+}
+
+std::string str = "abcde"
+"void funcInsideDoubleQuotedString()"
+"{"
+"}";
+
+void func11()
+{
+}
+
+std::string str = 'abcde'
+'void funcInsideSingleQuotedString()'
+'{'
+'}';
+
+void func12(int a)
+{
+}
+
+void func13(int a, int b, int c)
+{
+}
+
+void func14(int a, int b,
+ int c, int d
+ , int e, int f)
+{
+}
+
+void func15
+ (int a, int b)
+{
+}
+
+void funcOverloaded()
+{
+}
+
+void funcOverloaded(int a)
+{
+}
+
+void funcOverloaded(float a)
+{
+}
+
+void Class::func16()
+{
+}
+
+void Class1::Class2::func17()
+{
+}
+
+static void Class2::func18()
+{
+}
+
+inline void Class2::func19()
+{
+}
+
+const void Class2::func20()
+{
+}
+
+Class1::Type Class2::func21()
+{
+}
+
+inline static const Class1::Type Class2::func22()
+{
+}
+
+template<class T> void func23(T t)
+{
+}
+
+template<class T>
+void func24(T t)
+{
+}
+
+inline static Class1::Type Class2::func25()
+{
+}
+
+class Class1 {
+public:
+ void func26();
+};
+
+void Class1::func26()
+{
+}
+
+class Class2 {
+ void func27()
+ {
+ }
+};
+
+class Class3 : public Class4, Class5, Class6 {
+ void func28()
+ {
+ }
+};
+
+class Class7 {
+ int operator+()
+ {
+ return 123;
+ }
+};
+
+Class100::Class100()
+{
+}
+
+Class101::~Class101()
+{
+}
+
+Class102::Class102() :
+ member(1), member(2)
+{
+}
+
+Class103::Class103()
+ : member(1), member(2)
+{
+}
+
+struct Struct1 {
+public:
+ void func29();
+};
+
+void Struct1::func29()
+{
+}
+
+struct Struct2 {
+ void func30()
+ {
+ }
+};
+
+namespace NameSpace1 {
+
+void func30()
+{
+}
+
+}
+
+namespace NameSpace1 {
+namespace NameSpace2 {
+
+void func31()
+{
+}
+
+}
+}
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes