Title: [103668] trunk/Tools
Revision
103668
Author
hara...@chromium.org
Date
2011-12-25 00:15:16 -0800 (Sun, 25 Dec 2011)

Log Message

Add unittests for the Java parser of prepare-ChangeLog
https://bugs.webkit.org/show_bug.cgi?id=75195

Reviewed by Ryosuke Niwa.

java_unittests.java is unittest cases for get_function_line_ranges_for_java()
of prepare-ChangeLog.

* Scripts/prepare-ChangeLog:
(get_function_line_ranges_for_java): Fixed a parser bug.

    interface I
    {
        void f()
        {
        }
    }

should be recognized as "I.f", and

    class C interface I
    {
        void f()
        {
        }
    }

should be recognized as "C.f".
Without this patch, both are recognized as "I.f".

* Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl:
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/java_unittests-expected.txt: Added.
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/java_unittests.java: Added.
(Simple):
(Simple.func1):
(Simple.func2):
(Simple.func3):
(Simple.func4):
(Simple.func5):
(Simple.func6):
(Simple.func7):
(Simple.func8):
(Simple.func9):
(Simple.func10):
(Simple.funcOverloaded):
(Simple.func11):
(Simple.func12):
(Simple.func13):
(Simple.func14):
(Simple.func15):
(Simple.func16):
(Simple.func17):
(Simple.func18):
(Simple.func19):
(Simple.func20):
(Simple.func21):
(Derived1):
(Derived1.Derived1):
(Derived1.func22):
(Interface1):
(Interface2):
(Interface2.func23):
(Derived2):
(Derived2.Derived2):
(Derived2.func23):

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (103667 => 103668)


--- trunk/Tools/ChangeLog	2011-12-25 08:09:36 UTC (rev 103667)
+++ trunk/Tools/ChangeLog	2011-12-25 08:15:16 UTC (rev 103668)
@@ -1,5 +1,73 @@
 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
+
+        Reviewed by Ryosuke Niwa.
+
+        java_unittests.java is unittest cases for get_function_line_ranges_for_java()
+        of prepare-ChangeLog.
+
+        * Scripts/prepare-ChangeLog:
+        (get_function_line_ranges_for_java): Fixed a parser bug.
+
+            interface I
+            {
+                void f()
+                {
+                }
+            }
+
+        should be recognized as "I.f", and
+
+            class C interface I
+            {
+                void f()
+                {
+                }
+            }
+
+        should be recognized as "C.f".
+        Without this patch, both are recognized as "I.f".
+
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl:
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/java_unittests-expected.txt: Added.
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/java_unittests.java: Added.
+        (Simple):
+        (Simple.func1):
+        (Simple.func2):
+        (Simple.func3):
+        (Simple.func4):
+        (Simple.func5):
+        (Simple.func6):
+        (Simple.func7):
+        (Simple.func8):
+        (Simple.func9):
+        (Simple.func10):
+        (Simple.funcOverloaded):
+        (Simple.func11):
+        (Simple.func12):
+        (Simple.func13):
+        (Simple.func14):
+        (Simple.func15):
+        (Simple.func16):
+        (Simple.func17):
+        (Simple.func18):
+        (Simple.func19):
+        (Simple.func20):
+        (Simple.func21):
+        (Derived1):
+        (Derived1.Derived1):
+        (Derived1.func22):
+        (Interface1):
+        (Interface2):
+        (Interface2.func23):
+        (Derived2):
+        (Derived2.Derived2):
+        (Derived2.func23):
+
+2011-12-24  Kentaro Hara  <hara...@chromium.org>
+
         Add unittests for the Python parser of prepare-ChangeLog
         https://bugs.webkit.org/show_bug.cgi?id=75197
 

Modified: trunk/Tools/Scripts/prepare-ChangeLog (103667 => 103668)


--- trunk/Tools/Scripts/prepare-ChangeLog	2011-12-25 08:09:36 UTC (rev 103667)
+++ trunk/Tools/Scripts/prepare-ChangeLog	2011-12-25 08:15:16 UTC (rev 103668)
@@ -909,6 +909,7 @@
     my $in_braces = 0;
     my $in_non_block_braces = 0;
     my $class_or_interface_just_seen = 0;
+    my $in_class_declaration = 0;
 
     my $word = "";
 
@@ -977,6 +978,8 @@
 
             # Open brace.
             if ($1 eq "{") {
+                $in_class_declaration = 0;
+
                 # Promote potential name to real function name at the
                 # start of the outer level set of braces (function/class/interface body?).
                 if (!$in_non_block_braces
@@ -1045,7 +1048,10 @@
                 next;
             }
 
-            if ($1 eq "class" or $1 eq "interface") {
+            if ($1 eq "class") {
+                $in_class_declaration = 1;
+            }
+            if ($1 eq "class" or (!$in_class_declaration and $1 eq "interface")) {
                 $class_or_interface_just_seen = 1;
                 next;
             }

Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl (103667 => 103668)


--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl	2011-12-25 08:09:36 UTC (rev 103667)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl	2011-12-25 08:15:16 UTC (rev 103668)
@@ -33,7 +33,8 @@
 use LoadAsModule qw(PrepareChangeLog prepare-ChangeLog);
 
 my %testFiles = ("perl_unittests.pl" => "perl",
-                 "python_unittests.py" => "python");
+                 "python_unittests.py" => "python",
+                 "java_unittests.java" => "java");
 
 my $resetResults;
 GetOptions('reset-results' => \$resetResults);

Added: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/java_unittests-expected.txt (0 => 103668)


--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/java_unittests-expected.txt	                        (rev 0)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/java_unittests-expected.txt	2011-12-25 08:15:16 UTC (rev 103668)
@@ -0,0 +1,317 @@
+[
+  [
+    '20',
+    '26',
+    'Simple'
+  ],
+  [
+    '26',
+    '28',
+    'Simple.func1'
+  ],
+  [
+    '29',
+    '30',
+    'Simple'
+  ],
+  [
+    '30',
+    '33',
+    'Simple.func2'
+  ],
+  [
+    '34',
+    '34',
+    'Simple'
+  ],
+  [
+    '35',
+    '37',
+    'Simple.func3'
+  ],
+  [
+    '38',
+    '38',
+    'Simple'
+  ],
+  [
+    '39',
+    '39',
+    'Simple.func4'
+  ],
+  [
+    '40',
+    '41',
+    'Simple'
+  ],
+  [
+    '41',
+    '44',
+    'Simple.func5'
+  ],
+  [
+    '45',
+    '52',
+    'Simple'
+  ],
+  [
+    '52',
+    '54',
+    'Simple.func6'
+  ],
+  [
+    '55',
+    '56',
+    'Simple'
+  ],
+  [
+    '56',
+    '58',
+    'Simple.func7'
+  ],
+  [
+    '59',
+    '62',
+    'Simple'
+  ],
+  [
+    '60',
+    '64',
+    'Simple.func8'
+  ],
+  [
+    '65',
+    '67',
+    'Simple'
+  ],
+  [
+    '66',
+    '69',
+    'Simple.func9'
+  ],
+  [
+    '70',
+    '71',
+    'Simple'
+  ],
+  [
+    '71',
+    '73',
+    'Simple.func10'
+  ],
+  [
+    '74',
+    '75',
+    'Simple'
+  ],
+  [
+    '75',
+    '77',
+    'Simple.funcOverloaded'
+  ],
+  [
+    '78',
+    '79',
+    'Simple'
+  ],
+  [
+    '79',
+    '81',
+    'Simple.funcOverloaded'
+  ],
+  [
+    '82',
+    '83',
+    'Simple'
+  ],
+  [
+    '83',
+    '85',
+    'Simple.funcOverloaded'
+  ],
+  [
+    '86',
+    '87',
+    'Simple'
+  ],
+  [
+    '87',
+    '89',
+    'Simple.func11'
+  ],
+  [
+    '90',
+    '91',
+    'Simple'
+  ],
+  [
+    '91',
+    '93',
+    'Simple.func12'
+  ],
+  [
+    '94',
+    '95',
+    'Simple'
+  ],
+  [
+    '95',
+    '97',
+    'Simple.func13'
+  ],
+  [
+    '98',
+    '99',
+    'Simple'
+  ],
+  [
+    '99',
+    '101',
+    'Simple.func14'
+  ],
+  [
+    '102',
+    '103',
+    'Simple'
+  ],
+  [
+    '103',
+    '105',
+    'Simple.func15'
+  ],
+  [
+    '106',
+    '107',
+    'Simple'
+  ],
+  [
+    '107',
+    '109',
+    'Simple.func16'
+  ],
+  [
+    '110',
+    '111',
+    'Simple'
+  ],
+  [
+    '111',
+    '113',
+    'Simple.func17'
+  ],
+  [
+    '114',
+    '115',
+    'Simple'
+  ],
+  [
+    '115',
+    '117',
+    'Simple.func18'
+  ],
+  [
+    '118',
+    '119',
+    'Simple'
+  ],
+  [
+    '119',
+    '121',
+    'Simple.func19'
+  ],
+  [
+    '122',
+    '123',
+    'Simple'
+  ],
+  [
+    '123',
+    '125',
+    'Simple.func20'
+  ],
+  [
+    '126',
+    '127',
+    'Simple'
+  ],
+  [
+    '127',
+    '129',
+    'Simple.func21'
+  ],
+  [
+    '130',
+    '130',
+    'Simple'
+  ],
+  [
+    '135',
+    '137',
+    'Derived1'
+  ],
+  [
+    '137',
+    '139',
+    'Derived1.Derived1'
+  ],
+  [
+    '140',
+    '141',
+    'Derived1'
+  ],
+  [
+    '141',
+    '143',
+    'Derived1.func22'
+  ],
+  [
+    '144',
+    '144',
+    'Derived1'
+  ],
+  [
+    '146',
+    '148',
+    'Interface1'
+  ],
+  [
+    '150',
+    '154',
+    'Interface2'
+  ],
+  [
+    '154',
+    '156',
+    'Interface2.func23'
+  ],
+  [
+    '157',
+    '157',
+    'Interface2'
+  ],
+  [
+    '159',
+    '161',
+    'Derived2'
+  ],
+  [
+    '161',
+    '163',
+    'Derived2.Derived2'
+  ],
+  [
+    '164',
+    '165',
+    'Derived2'
+  ],
+  [
+    '165',
+    '167',
+    'Derived2.func23'
+  ],
+  [
+    '168',
+    '168',
+    'Derived2'
+  ]
+]

Added: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/java_unittests.java (0 => 103668)


--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/java_unittests.java	                        (rev 0)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/java_unittests.java	2011-12-25 08:15:16 UTC (rev 103668)
@@ -0,0 +1,168 @@
+/*
+ * 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.
+ */
+
+public class Simple
+{
+    int a;
+    String b;
+    final int c = 12345;
+
+    void func1()
+    {
+    }
+
+    void func2()
+    {
+        return 123;
+    }
+
+    void func3() {
+        return 123;
+    }
+
+    void func4() { return 123; }
+
+    void func5()
+    {
+        /* comment */
+    }
+
+    /*
+      void funcInsideComment()
+      {
+      }
+    */
+
+    void func6(int a)
+    {
+    }
+
+    void func7(int a, int b, int c)
+    {
+    }
+
+    void func8(int a, int b,
+               int c, int d
+               , int e, int f)
+    {
+    }
+
+    void func9
+        (int a, int b)
+    {
+    }
+
+    LinkedList func10()
+    {
+    }
+
+    void funcOverloaded()
+    {
+    }
+
+    void funcOverloaded(int a)
+    {
+    }
+
+    void funcOverloaded(float a)
+    {
+    }
+
+    static void func11()
+    {
+    }
+
+    public void func12()
+    {
+    }
+
+    protected void func13()
+    {
+    }
+
+    private void func14()
+    {
+    }
+
+    static void func15()
+    {
+    }
+
+    final void func16()
+    {
+    }
+
+    abstract void func17()
+    {
+    }
+
+    synchronized void func18()
+    {
+    }
+
+    final static public synchronized void func19()
+    {
+    }
+
+    void func20() throws IOException
+    {
+    }
+
+    void func21() throws IOException, ArithmeticException
+    {
+    }
+}
+
+import java.util.*;
+import java.math.*;
+
+class Derived1 extends Base
+{
+    public Derived1()
+    {
+    }
+
+    public func22()
+    {
+    }
+}
+
+interface Interface1
+{
+}
+
+interface Interface2
+{
+    int a;
+
+    void func23()
+    {
+    }
+}
+
+class Derived2 extends Base interface Interface1, Interface2
+{
+    public Derived2()
+    {
+    }
+
+    public func23()
+    {
+    }
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to