Title: [104400] trunk/Tools
Revision
104400
Author
[email protected]
Date
2012-01-08 08:15:51 -0800 (Sun, 08 Jan 2012)

Log Message

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

Reviewed by David Kilzer.

_javascript__unittests.js is a unittest for get_function_line_ranges_for_javascript()
of prepare-ChangeLog.

* Scripts/prepare-ChangeLog:
(get_function_line_ranges_for_javascript): Before this patch, a string found was just
omitted from parsing. Thus,

    str = "foo"
    function func() {
    }

was recognized as equivalent to

    str = function func() {
    }

This patch replaces a string with a dummy identifier 'string_appeared_here'
to tell the parser that a string appeared there.

* Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl:
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/_javascript__unittests-expected.txt: Added.
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/_javascript__unittests.js: Added.
(func1):
(func2):
(func3):
(func4):
(func5):
(func6):
(func7):
(func8):
(func9):
(func10):
(func11):
(func12):
(funcOverloaded):
(Func1.prototype.get x1):
(Func1.prototype.get x2):
(Func1.prototype.set x1):
(Func1.prototype.set x3):
(Func2.prototype.func13):
(Func2.prototype.func14):
(Func2.prototype.func15):
(func16.func17):
(func16.func18):
(func16.func19):
(func16):

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (104399 => 104400)


--- trunk/Tools/ChangeLog	2012-01-08 11:45:58 UTC (rev 104399)
+++ trunk/Tools/ChangeLog	2012-01-08 16:15:51 UTC (rev 104400)
@@ -1,3 +1,57 @@
+2012-01-08  Kentaro Hara  <[email protected]>
+
+        Add unittests for the _javascript_ parser of prepare-ChangeLog
+        https://bugs.webkit.org/show_bug.cgi?id=75201
+
+        Reviewed by David Kilzer.
+
+        _javascript__unittests.js is a unittest for get_function_line_ranges_for_javascript()
+        of prepare-ChangeLog.
+
+        * Scripts/prepare-ChangeLog:
+        (get_function_line_ranges_for_javascript): Before this patch, a string found was just
+        omitted from parsing. Thus,
+
+            str = "foo"
+            function func() {
+            }
+
+        was recognized as equivalent to
+
+            str = function func() {
+            }
+
+        This patch replaces a string with a dummy identifier 'string_appeared_here'
+        to tell the parser that a string appeared there.
+
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl:
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/_javascript__unittests-expected.txt: Added.
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/_javascript__unittests.js: Added.
+        (func1):
+        (func2):
+        (func3):
+        (func4):
+        (func5):
+        (func6):
+        (func7):
+        (func8):
+        (func9):
+        (func10):
+        (func11):
+        (func12):
+        (funcOverloaded):
+        (Func1.prototype.get x1):
+        (Func1.prototype.get x2):
+        (Func1.prototype.set x1):
+        (Func1.prototype.set x3):
+        (Func2.prototype.func13):
+        (Func2.prototype.func14):
+        (Func2.prototype.func15):
+        (func16.func17):
+        (func16.func18):
+        (func16.func19):
+        (func16):
+
 2012-01-08  David Levin  <[email protected]>
 
         [chromium] Add layout test support for autosize code in FrameView.

Modified: trunk/Tools/Scripts/prepare-ChangeLog (104399 => 104400)


--- trunk/Tools/Scripts/prepare-ChangeLog	2012-01-08 11:45:58 UTC (rev 104399)
+++ trunk/Tools/Scripts/prepare-ChangeLog	2012-01-08 16:15:51 UTC (rev 104400)
@@ -1150,7 +1150,7 @@
             } elsif ($match eq '//') {
                 s-//.*--;
             } else { # ' or "
-                if (!s-$match([^\\]|\\.)*?$match--) {
+                if (!s-$match([^\\]|\\.)*?$match-string_appeared_here-) {
                     $inQuotedText = $match if /\\$/;
                     warn "mismatched quotes at line $. in $fileName\n" if $inQuotedText eq "";
                     s-$match.*--;

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


--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl	2012-01-08 11:45:58 UTC (rev 104399)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl	2012-01-08 16:15:51 UTC (rev 104400)
@@ -35,7 +35,9 @@
 my %testFiles = ("perl_unittests.pl" => "perl",
                  "python_unittests.py" => "python",
                  "java_unittests.java" => "java",
-                 "cpp_unittests.cpp" => "cpp");
+                 "cpp_unittests.cpp" => "cpp",
+                 "_javascript__unittests.js" => "_javascript_",
+                );
 
 my $resetResults;
 GetOptions('reset-results' => \$resetResults);

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


--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/_javascript__unittests-expected.txt	                        (rev 0)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/_javascript__unittests-expected.txt	2012-01-08 16:15:51 UTC (rev 104400)
@@ -0,0 +1,132 @@
+[
+  [
+    '20',
+    '22',
+    'func1'
+  ],
+  [
+    '24',
+    '25',
+    'func2'
+  ],
+  [
+    '27',
+    '27',
+    'func3'
+  ],
+  [
+    '29',
+    '32',
+    'func4'
+  ],
+  [
+    '34',
+    '37',
+    'func5'
+  ],
+  [
+    '39',
+    '42',
+    'func6'
+  ],
+  [
+    '50',
+    '52',
+    'func7'
+  ],
+  [
+    '56',
+    '58',
+    'func8'
+  ],
+  [
+    '62',
+    '64',
+    'func9'
+  ],
+  [
+    '66',
+    '68',
+    'func10'
+  ],
+  [
+    '70',
+    '73',
+    'func11'
+  ],
+  [
+    '75',
+    '79',
+    'func12'
+  ],
+  [
+    '81',
+    '83',
+    'funcOverloaded'
+  ],
+  [
+    '85',
+    '87',
+    'funcOverloaded'
+  ],
+  [
+    '89',
+    '91',
+    'funcOverloaded'
+  ],
+  [
+    '94',
+    '96',
+    'Func1.prototype.get x1'
+  ],
+  [
+    '98',
+    '101',
+    'Func1.prototype.get x2'
+  ],
+  [
+    '103',
+    '105',
+    'Func1.prototype.set x1'
+  ],
+  [
+    '107',
+    '110',
+    'Func1.prototype.set x3'
+  ],
+  [
+    '114',
+    '116',
+    'Func2.prototype.func13'
+  ],
+  [
+    '118',
+    '120',
+    'Func2.prototype.func14'
+  ],
+  [
+    '122',
+    '125',
+    'Func2.prototype.func15'
+  ],
+  [
+    '133',
+    '134',
+    'func16.func17'
+  ],
+  [
+    '136',
+    '137',
+    'func16.func18'
+  ],
+  [
+    '139',
+    '141',
+    'func16.func19'
+  ],
+  [
+    '128',
+    '150',
+    'func16'
+  ]
+]

Added: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/_javascript__unittests.js (0 => 104400)


--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/_javascript__unittests.js	                        (rev 0)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/_javascript__unittests.js	2012-01-08 16:15:51 UTC (rev 104400)
@@ -0,0 +1,150 @@
+/*
+ * 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.
+ */
+
+function func1()
+{
+}
+
+function func2() {
+}
+
+function func3() { }
+
+function func4()
+{
+    return 123;
+}
+
+function func5()
+{
+    // comment
+}
+
+function func6()
+{
+    /* comment */
+}
+
+/*
+function funcInsideComment()
+{
+}
+*/
+
+function func7()
+{
+}
+
+var str1 = "function funcInsideDoubleQuotedString() {}";
+
+function func8()
+{
+}
+
+var str2 = 'function funcInsideSingleQuotedString() {}';
+
+function func9(a)
+{
+}
+
+function func10(a, b)
+{
+}
+
+function func11
+    (a, b)
+{
+}
+
+function func12(a, b,
+                c, d
+                , e, f)
+{
+}
+
+function funcOverloaded()
+{
+}
+
+function funcOverloaded(a)
+{
+}
+
+function funcOverloaded(a, b)
+{
+}
+
+Func1.prototype = {
+    get x1()
+    {
+    },
+
+    get x2()
+    {
+        return this.x2;
+    },
+
+    set x1(a)
+    {
+    },
+
+    set x3(a)
+    {
+        this.x3 = a;
+    }
+};
+
+Func2.prototype = {
+    func13 : function()
+    {
+    },
+
+    func14 : function(a)
+    {
+    },
+
+    func15 : function(a, b)
+    {
+        return 123;
+    }
+};
+
+function func16()
+{
+    var a = 123;
+    var b = 456;
+
+    var func17 = function() {
+    };
+
+    var func18 = function(a) {
+    };
+
+    var func19 = function(a, b) {
+        return 123;
+    };
+
+    func20(function()
+           {
+           },
+           function(a)
+           {
+               return 123;
+           });
+}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to