Changeset 216090 in webkit


Ignore:
Timestamp:
May 2, 2017 1:10:12 PM (7 years ago)
Author:
ddkilzer@apple.com
Message:

check-webkit-style should keep JavaScript test functions in sync
<https://webkit.org/b/171424>

Reviewed by Joseph Pecoraro.

JSTests:

This change makes shouldBe(), shouldNotBe(), shouldNotThrow()
and shouldThrow() in sync with other copies of these methods.

  • stress/resources/standalone-pre.js:

(shouldBe): Fix whitespace. Prefix 'exception' and 'quiet'
variables with underscore.
(shouldThrow): Fix whitespace.

Tools:

Add a new JSTestChecker for check-webkit-style that keeps these
two files in sync:

LayoutTests/http/tests/resources/js-test-pre.js
LayoutTests/resources/js-test-pre.js

And keeps implementations of shouldBe(), shouldNotBe(),
shouldNotThrow(), and shouldThrow() in sync across multiple
files (with the ability to add more functions later):

JSTests/stress/resources/standalone-pre.js
LayoutTests/http/tests/resources/js-test-pre.js
LayoutTests/resources/js-test-pre.js
LayoutTests/resources/js-test.js
LayoutTests/resources/standalone-pre.js

  • Scripts/webkitpy/style/checker.py: Remove unused import. Add

import for JSTestChecker.
(_NEVER_SKIPPED_FILES): Add array of file names that are never
skipped regardless of other rules.
(_all_categories): Add JSTestChecker categories.
(CheckerDispatcher.should_skip_without_warning): Use
_NEVER_SKIPPED_FILES.
(CheckerDispatcher._create_checker): Return JSTestChecker for
the files to check.

  • Scripts/webkitpy/style/checkers/jstest.py: Add.

(map_functions_to_dict): Parse JavaScript source by splitting on
/function\s+/ regex. This is good enough for the sanity checks
to keep function implementations in sync.
(strip_blank_lines_and_comments): Strips blank lines and lines
with comments from the end of a chunk of text representing a
function.
(JSTestChecker): New checker.
(JSTestChecker.init):
(JSTestChecker.check):
(JSTestChecker.check_js_test_files): Keeps whole files in sync.
(JSTestChecker.check_js_test_functions): Keeps individual
functions in sync.

  • Scripts/webkitpy/style/checkers/jstest_unittest.py: Add test

case.
(JSTestTestCase):
(JSTestTestCase.test_map_functions_to_dict):

LayoutTests:

This change attempts to fix all whitespace issues in these two
files (which are now identical and will be kept in sync by
check-webkit-style):

LayoutTests/http/tests/resources/js-test-pre.js
LayoutTests/resources/js-test-pre.js

It also syncs the implementation of shouldBe(), shouldNotBe(),
shouldNotThrow() and shouldThrow() across the following files:

JSTests/stress/resources/standalone-pre.js
LayoutTests/http/tests/resources/js-test-pre.js
LayoutTests/resources/js-test-pre.js
LayoutTests/resources/js-test.js
LayoutTests/resources/standalone-pre.js

Only interesting (non-whitespace) changes are listed below.

  • http/tests/resources/js-test-pre.js: Copy from resources/js-test-pre.js.

(shouldBe): Prefix 'exception' and 'quiet' variables with
underscore.
(shouldNotBe): Ditto.

  • resources/js-test-pre.js:

(shouldBe): Prefix 'exception' and 'quiet' variables with
underscore.
(shouldNotBe): Ditto.

  • resources/js-test.js:

(shouldBe): Prefix 'quiet' variable with underscore. Use
stringify() when printing '_bv' value.

  • resources/standalone-pre.js:

(shouldBe): Prefix 'exception' and 'quiet' variables with
underscore.
(shouldNotBe): Ditto.

Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r215986 r216090  
     12017-05-02  David Kilzer  <ddkilzer@apple.com>
     2
     3        check-webkit-style should keep JavaScript test functions in sync
     4        <https://webkit.org/b/171424>
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        This change makes shouldBe(), shouldNotBe(), shouldNotThrow()
     9        and shouldThrow() in sync with other copies of these methods.
     10
     11        * stress/resources/standalone-pre.js:
     12        (shouldBe): Fix whitespace.  Prefix 'exception' and 'quiet'
     13        variables with underscore.
     14        (shouldThrow): Fix whitespace.
     15
    1162017-04-30  Oleksandr Skachkov  <gskachkov@gmail.com>
    217
  • trunk/JSTests/stress/resources/standalone-pre.js

    r215894 r216090  
    121121}
    122122
    123 function shouldBe(_a, _b, quiet)
    124 {
    125   if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
    126     debug("WARN: shouldBe() expects function or string arguments");
    127   var exception;
    128   var _av;
    129   try {
    130     _av = (typeof _a == "function" ? _a() : eval(_a));
    131   } catch (e) {
    132     exception = e;
    133   }
    134   var _bv = (typeof _b == "function" ? _b() : eval(_b));
    135 
    136   if (exception)
    137     testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + exception);
    138   else if (isResultCorrect(_av, _bv)) {
    139     if (!quiet) {
    140       testPassed(_a + " is " + (typeof _b == "function" ? _bv : _b));
    141     }
    142   } else if (typeof(_av) == typeof(_bv))
    143     testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
    144   else
    145     testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
     123function shouldBe(_a, _b, _quiet)
     124{
     125    if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
     126        debug("WARN: shouldBe() expects function or string arguments");
     127    var _exception;
     128    var _av;
     129    try {
     130        _av = (typeof _a == "function" ? _a() : eval(_a));
     131    } catch (e) {
     132        _exception = e;
     133    }
     134    var _bv = (typeof _b == "function" ? _b() : eval(_b));
     135
     136    if (_exception)
     137        testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + _exception);
     138    else if (isResultCorrect(_av, _bv)) {
     139        if (!_quiet) {
     140            testPassed(_a + " is " + (typeof _b == "function" ? _bv : _b));
     141        }
     142    } else if (typeof(_av) == typeof(_bv))
     143        testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
     144    else
     145        testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
    146146}
    147147
     
    257257    var _ev;
    258258    if (_e)
    259         _ev =  eval(_e);
     259        _ev = eval(_e);
    260260
    261261    if (_exception) {
  • trunk/LayoutTests/ChangeLog

    r216089 r216090  
     12017-05-02  David Kilzer  <ddkilzer@apple.com>
     2
     3        check-webkit-style should keep JavaScript test functions in sync
     4        <https://webkit.org/b/171424>
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        This change attempts to fix all whitespace issues in these two
     9        files (which are now identical and will be kept in sync by
     10        check-webkit-style):
     11
     12            LayoutTests/http/tests/resources/js-test-pre.js
     13            LayoutTests/resources/js-test-pre.js
     14
     15        It also syncs the implementation of shouldBe(), shouldNotBe(),
     16        shouldNotThrow() and shouldThrow() across the following files:
     17
     18            JSTests/stress/resources/standalone-pre.js
     19            LayoutTests/http/tests/resources/js-test-pre.js
     20            LayoutTests/resources/js-test-pre.js
     21            LayoutTests/resources/js-test.js
     22            LayoutTests/resources/standalone-pre.js
     23
     24        Only interesting (non-whitespace) changes are listed below.
     25
     26        * http/tests/resources/js-test-pre.js: Copy from resources/js-test-pre.js.
     27        (shouldBe): Prefix 'exception' and 'quiet' variables with
     28        underscore.
     29        (shouldNotBe): Ditto.
     30
     31        * resources/js-test-pre.js:
     32        (shouldBe): Prefix 'exception' and 'quiet' variables with
     33        underscore.
     34        (shouldNotBe): Ditto.
     35
     36        * resources/js-test.js:
     37        (shouldBe): Prefix 'quiet' variable with underscore.  Use
     38        stringify() when printing '_bv' value.
     39
     40        * resources/standalone-pre.js:
     41        (shouldBe): Prefix 'exception' and 'quiet' variables with
     42        underscore.
     43        (shouldNotBe): Ditto.
     44
    1452017-05-02  Joanmarie Diggs  <jdiggs@igalia.com>
    246
  • trunk/LayoutTests/http/tests/resources/js-test-pre.js

    r215894 r216090  
    193193function evalAndLog(_a, _quiet)
    194194{
    195   if (typeof _a != "string")
    196     debug("WARN: evalAndLog() expects a string argument");
    197 
    198   // Log first in case things go horribly wrong or this causes a sync event.
    199   if (!_quiet)
    200     debug(_a);
    201 
    202   var _av;
    203   try {
    204      _av = eval(_a);
    205   } catch (e) {
    206     testFailed(_a + " threw exception " + e);
    207   }
    208   return _av;
     195    if (typeof _a != "string")
     196        debug("WARN: evalAndLog() expects a string argument");
     197
     198    // Log first in case things go horribly wrong or this causes a sync event.
     199    if (!_quiet)
     200        debug(_a);
     201
     202    var _av;
     203    try {
     204        _av = eval(_a);
     205    } catch (e) {
     206        testFailed(_a + " threw exception " + e);
     207    }
     208    return _av;
    209209}
    210210
    211211function evalAndLogResult(_a)
    212212{
    213   if (typeof _a != "string")
    214     debug("WARN: evalAndLogResult() expects a string argument");
    215 
    216   var _av;
    217   try {
    218      _av = eval(_a);
    219   } catch (e) {
    220     testFailed(_a + " threw exception " + e);
    221   }
    222 
    223   debug('<span>' + _a + " is " + escapeHTML(_av) + '</span>');
    224 }
    225 
    226 function shouldBe(_a, _b, quiet)
    227 {
    228   if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
    229     debug("WARN: shouldBe() expects function or string arguments");
    230   var exception;
    231   var _av;
    232   try {
    233     _av = (typeof _a == "function" ? _a() : eval(_a));
    234   } catch (e) {
    235     exception = e;
    236   }
    237   var _bv = (typeof _b == "function" ? _b() : eval(_b));
    238 
    239   if (exception)
    240     testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + exception);
    241   else if (isResultCorrect(_av, _bv)) {
    242     if (!quiet) {
    243       testPassed(_a + " is " + (typeof _b == "function" ? _bv : _b));
    244     }
    245   } else if (typeof(_av) == typeof(_bv))
    246     testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
    247   else
    248     testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
     213    if (typeof _a != "string")
     214        debug("WARN: evalAndLogResult() expects a string argument");
     215
     216    var _av;
     217    try {
     218        _av = eval(_a);
     219    } catch (e) {
     220        testFailed(_a + " threw exception " + e);
     221    }
     222
     223    debug('<span>' + _a + " is " + escapeHTML(_av) + '</span>');
     224}
     225
     226function shouldBe(_a, _b, _quiet)
     227{
     228    if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
     229        debug("WARN: shouldBe() expects function or string arguments");
     230    var _exception;
     231    var _av;
     232    try {
     233        _av = (typeof _a == "function" ? _a() : eval(_a));
     234    } catch (e) {
     235        _exception = e;
     236    }
     237    var _bv = (typeof _b == "function" ? _b() : eval(_b));
     238
     239    if (_exception)
     240        testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + _exception);
     241    else if (isResultCorrect(_av, _bv)) {
     242        if (!_quiet) {
     243            testPassed(_a + " is " + (typeof _b == "function" ? _bv : _b));
     244        }
     245    } else if (typeof(_av) == typeof(_bv))
     246        testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
     247    else
     248        testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
    249249}
    250250
    251251function dfgShouldBe(theFunction, _a, _b)
    252252{
    253   if (typeof theFunction != "function" || typeof _a != "string" || typeof _b != "string")
    254     debug("WARN: dfgShouldBe() expects a function and two strings");
    255   noInline(theFunction);
    256   var exception;
    257   var values = [];
    258 
    259   // Defend against tests that muck with numeric properties on array.prototype.
    260   values.__proto__ = null;
    261   values.push = Array.prototype.push;
    262  
    263   try {
    264     while (!dfgCompiled({f:theFunction}))
    265       values.push(eval(_a));
    266     values.push(eval(_a));
    267   } catch (e) {
    268     exception = e;
    269   }
    270 
    271   var _bv = eval(_b);
    272   if (exception)
    273     testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (values.length + 1) + ", threw exception " + exception);
    274   else {
    275     var allPassed = true;
    276     for (var i = 0; i < values.length; ++i) {
    277       var _av = values[i];
    278       if (isResultCorrect(_av, _bv))
    279         continue;
    280       if (typeof(_av) == typeof(_bv))
    281         testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (i + 1) + ", was " + stringify(_av) + ".");
    282       else
    283         testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). On iteration " + (i + 1) + ", was " + _av + " (of type " + typeof _av + ").");
    284       allPassed = false;
    285     }
    286     if (allPassed)
    287       testPassed(_a + " is " + _b + " on all iterations including after DFG tier-up.");
    288   }
    289  
    290   return values.length;
     253    if (typeof theFunction != "function" || typeof _a != "string" || typeof _b != "string")
     254        debug("WARN: dfgShouldBe() expects a function and two strings");
     255    noInline(theFunction);
     256    var exception;
     257    var values = [];
     258
     259    // Defend against tests that muck with numeric properties on array.prototype.
     260    values.__proto__ = null;
     261    values.push = Array.prototype.push;
     262
     263    try {
     264        while (!dfgCompiled({f:theFunction}))
     265            values.push(eval(_a));
     266        values.push(eval(_a));
     267    } catch (e) {
     268        exception = e;
     269    }
     270
     271    var _bv = eval(_b);
     272    if (exception)
     273        testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (values.length + 1) + ", threw exception " + exception);
     274    else {
     275        var allPassed = true;
     276        for (var i = 0; i < values.length; ++i) {
     277            var _av = values[i];
     278            if (isResultCorrect(_av, _bv))
     279                continue;
     280            if (typeof(_av) == typeof(_bv))
     281                testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (i + 1) + ", was " + stringify(_av) + ".");
     282            else
     283                testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). On iteration " + (i + 1) + ", was " + _av + " (of type " + typeof _av + ").");
     284            allPassed = false;
     285        }
     286        if (allPassed)
     287            testPassed(_a + " is " + _b + " on all iterations including after DFG tier-up.");
     288    }
     289
     290    return values.length;
    291291}
    292292
     
    294294function _waitForCondition(condition, completionHandler)
    295295{
    296   if (condition())
    297     completionHandler();
    298   else
    299     setTimeout(_waitForCondition, 5, condition, completionHandler);
     296    if (condition())
     297        completionHandler();
     298    else
     299        setTimeout(_waitForCondition, 5, condition, completionHandler);
    300300}
    301301
    302302function shouldBecomeEqual(_a, _b, completionHandler)
    303303{
    304   if (typeof _a != "string" || typeof _b != "string")
    305     debug("WARN: shouldBecomeEqual() expects string arguments");
    306 
    307   function condition() {
     304    if (typeof _a != "string" || typeof _b != "string")
     305        debug("WARN: shouldBecomeEqual() expects string arguments");
     306
     307    function condition() {
     308        var exception;
     309        var _av;
     310        try {
     311            _av = eval(_a);
     312        } catch (e) {
     313            exception = e;
     314        }
     315        var _bv = eval(_b);
     316        if (exception)
     317            testFailed(_a + " should become " + _bv + ". Threw exception " + exception);
     318        if (isResultCorrect(_av, _bv)) {
     319            testPassed(_a + " became " + _b);
     320            return true;
     321        }
     322        return false;
     323    }
     324    setTimeout(_waitForCondition, 0, condition, completionHandler);
     325}
     326
     327function shouldBecomeEqualToString(value, reference, completionHandler)
     328{
     329    if (typeof value !== "string" || typeof reference !== "string")
     330        debug("WARN: shouldBecomeEqualToString() expects string arguments");
     331    var unevaledString = JSON.stringify(reference);
     332    shouldBecomeEqual(value, unevaledString, completionHandler);
     333}
     334
     335function shouldBeType(_a, _type) {
    308336    var exception;
    309337    var _av;
    310338    try {
    311       _av = eval(_a);
    312     } catch (e) {
    313       exception = e;
    314     }
    315     var _bv = eval(_b);
    316     if (exception)
    317       testFailed(_a + " should become " + _bv + ". Threw exception " + exception);
    318     if (isResultCorrect(_av, _bv)) {
    319       testPassed(_a + " became " + _b);
    320       return true;
    321     }
    322     return false;
    323   }
    324   setTimeout(_waitForCondition, 0, condition, completionHandler);
    325 }
    326 
    327 function shouldBecomeEqualToString(value, reference, completionHandler)
    328 {
    329   if (typeof value !== "string" || typeof reference !== "string")
    330     debug("WARN: shouldBecomeEqualToString() expects string arguments");
    331   var unevaledString = JSON.stringify(reference);
    332   shouldBecomeEqual(value, unevaledString, completionHandler);
    333 }
    334 
    335 function shouldBeType(_a, _type) {
    336   var exception;
    337   var _av;
    338   try {
    339     _av = eval(_a);
    340   } catch (e) {
    341     exception = e;
    342   }
    343 
    344   var _typev = eval(_type);
    345   if (_av instanceof _typev) {
    346     testPassed(_a + " is an instance of " + _type);
    347   } else {
    348     testFailed(_a + " is not an instance of " + _type);
    349   }
     339        _av = eval(_a);
     340    } catch (e) {
     341        exception = e;
     342    }
     343
     344    var _typev = eval(_type);
     345    if (_av instanceof _typev) {
     346        testPassed(_a + " is an instance of " + _type);
     347    } else {
     348        testFailed(_a + " is not an instance of " + _type);
     349    }
    350350}
    351351
     
    354354function shouldBeCloseTo(_to_eval, _target, _tolerance, quiet)
    355355{
    356   if (typeof _to_eval != "string") {
    357     testFailed("shouldBeCloseTo() requires string argument _to_eval. was type " + typeof _to_eval);
    358     return;
    359   }
    360   if (typeof _target != "number") {
    361     testFailed("shouldBeCloseTo() requires numeric argument _target. was type " + typeof _target);
    362     return;
    363   }
    364   if (typeof _tolerance != "number") {
    365     testFailed("shouldBeCloseTo() requires numeric argument _tolerance. was type " + typeof _tolerance);
    366     return;
    367   }
    368 
    369   var _result;
    370   try {
    371      _result = eval(_to_eval);
    372   } catch (e) {
    373     testFailed(_to_eval + " should be within " + _tolerance + " of "
    374                + _target + ". Threw exception " + e);
    375     return;
    376   }
    377 
    378   if (typeof(_result) != typeof(_target)) {
    379     testFailed(_to_eval + " should be of type " + typeof _target
    380                + " but was of type " + typeof _result);
    381   } else if (Math.abs(_result - _target) <= _tolerance) {
    382     if (!quiet) {
    383         testPassed(_to_eval + " is within " + _tolerance + " of " + _target);
    384     }
    385   } else {
    386     testFailed(_to_eval + " should be within " + _tolerance + " of " + _target
    387                + ". Was " + _result + ".");
    388   }
    389 }
    390 
    391 function shouldNotBe(_a, _b, quiet)
    392 {
    393   if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
    394     debug("WARN: shouldNotBe() expects function or string arguments");
    395   var exception;
    396   var _av;
    397   try {
    398     _av = (typeof _a == "function" ? _a() : eval(_a));
    399   } catch (e) {
    400     exception = e;
    401   }
    402   var _bv = (typeof _b == "function" ? _b() : eval(_b));
    403 
    404   if (exception)
    405     testFailed(_a + " should not be " + _bv + ". Threw exception " + exception);
    406   else if (!isResultCorrect(_av, _bv)) {
    407     if (!quiet) {
    408       testPassed(_a + " is not " + (typeof _b == "function" ? _bv : _b));
    409     }
    410   } else
    411     testFailed(_a + " should not be " + _bv + ".");
     356    if (typeof _to_eval != "string") {
     357        testFailed("shouldBeCloseTo() requires string argument _to_eval. was type " + typeof _to_eval);
     358        return;
     359    }
     360    if (typeof _target != "number") {
     361        testFailed("shouldBeCloseTo() requires numeric argument _target. was type " + typeof _target);
     362        return;
     363    }
     364    if (typeof _tolerance != "number") {
     365        testFailed("shouldBeCloseTo() requires numeric argument _tolerance. was type " + typeof _tolerance);
     366        return;
     367    }
     368
     369    var _result;
     370    try {
     371        _result = eval(_to_eval);
     372    } catch (e) {
     373        testFailed(_to_eval + " should be within " + _tolerance + " of "
     374                   + _target + ". Threw exception " + e);
     375        return;
     376    }
     377
     378    if (typeof(_result) != typeof(_target)) {
     379        testFailed(_to_eval + " should be of type " + typeof _target
     380                   + " but was of type " + typeof _result);
     381    } else if (Math.abs(_result - _target) <= _tolerance) {
     382        if (!quiet) {
     383            testPassed(_to_eval + " is within " + _tolerance + " of " + _target);
     384        }
     385    } else {
     386        testFailed(_to_eval + " should be within " + _tolerance + " of " + _target
     387                   + ". Was " + _result + ".");
     388    }
     389}
     390
     391function shouldNotBe(_a, _b, _quiet)
     392{
     393    if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
     394        debug("WARN: shouldNotBe() expects function or string arguments");
     395    var _exception;
     396    var _av;
     397    try {
     398        _av = (typeof _a == "function" ? _a() : eval(_a));
     399    } catch (e) {
     400        _exception = e;
     401    }
     402    var _bv = (typeof _b == "function" ? _b() : eval(_b));
     403
     404    if (_exception)
     405        testFailed(_a + " should not be " + _bv + ". Threw exception " + _exception);
     406    else if (!isResultCorrect(_av, _bv)) {
     407        if (!_quiet) {
     408            testPassed(_a + " is not " + (typeof _b == "function" ? _bv : _b));
     409        }
     410    } else
     411        testFailed(_a + " should not be " + _bv + ".");
    412412}
    413413
    414414function shouldBecomeDifferent(_a, _b, completionHandler)
    415415{
    416   if (typeof _a != "string" || typeof _b != "string")
    417     debug("WARN: shouldBecomeDifferent() expects string arguments");
    418 
    419   function condition() {
    420     var exception;
    421     var _av;
    422     try {
    423       _av = eval(_a);
    424     } catch (e) {
    425       exception = e;
    426     }
    427     var _bv = eval(_b);
    428     if (exception)
    429       testFailed(_a + " should became not equal to " + _bv + ". Threw exception " + exception);
    430     if (!isResultCorrect(_av, _bv)) {
    431       testPassed(_a + " became different from " + _b);
    432       return true;
    433     }
    434     return false;
    435   }
    436   setTimeout(_waitForCondition, 0, condition, completionHandler);
     416    if (typeof _a != "string" || typeof _b != "string")
     417        debug("WARN: shouldBecomeDifferent() expects string arguments");
     418
     419    function condition() {
     420        var exception;
     421        var _av;
     422        try {
     423            _av = eval(_a);
     424        } catch (e) {
     425            exception = e;
     426        }
     427        var _bv = eval(_b);
     428        if (exception)
     429            testFailed(_a + " should became not equal to " + _bv + ". Threw exception " + exception);
     430        if (!isResultCorrect(_av, _bv)) {
     431            testPassed(_a + " became different from " + _b);
     432            return true;
     433        }
     434        return false;
     435    }
     436    setTimeout(_waitForCondition, 0, condition, completionHandler);
    437437}
    438438
     
    446446function shouldBeEqualToString(a, b)
    447447{
    448   if (typeof a !== "string" || typeof b !== "string")
    449     debug("WARN: shouldBeEqualToString() expects string arguments");
    450   var unevaledString = JSON.stringify(b);
    451   shouldBe(a, unevaledString);
     448    if (typeof a !== "string" || typeof b !== "string")
     449        debug("WARN: shouldBeEqualToString() expects string arguments");
     450    var unevaledString = JSON.stringify(b);
     451    shouldBe(a, unevaledString);
    452452}
    453453
    454454function shouldNotBeEqualToString(a, b)
    455455{
    456   if (typeof a !== "string" || typeof b !== "string")
    457     debug("WARN: shouldBeEqualToString() expects string arguments");
    458   var unevaledString = JSON.stringify(b);
    459   shouldNotBe(a, unevaledString);
     456    if (typeof a !== "string" || typeof b !== "string")
     457        debug("WARN: shouldBeEqualToString() expects string arguments");
     458    var unevaledString = JSON.stringify(b);
     459    shouldNotBe(a, unevaledString);
    460460}
    461461function shouldBeEmptyString(_a) { shouldBeEqualToString(_a, ""); }
     
    463463function shouldEvaluateTo(actual, expected)
    464464{
    465   // A general-purpose comparator.  'actual' should be a string to be
    466   // evaluated, as for shouldBe(). 'expected' may be any type and will be
    467   // used without being eval'ed.
    468   if (expected == null) {
    469     // Do this before the object test, since null is of type 'object'.
    470     shouldBeNull(actual);
    471   } else if (typeof expected == "undefined") {
    472     shouldBeUndefined(actual);
    473   } else if (typeof expected == "function") {
    474     // All this fuss is to avoid the string-arg warning from shouldBe().
    475     try {
    476       actualValue = eval(actual);
    477     } catch (e) {
    478       testFailed("Evaluating " + actual + ": Threw exception " + e);
    479       return;
    480     }
    481     shouldBe("'" + actualValue.toString().replace(/\n/g, "") + "'",
    482              "'" + expected.toString().replace(/\n/g, "") + "'");
    483   } else if (typeof expected == "object") {
    484     shouldBeTrue(actual + " == '" + expected + "'");
    485   } else if (typeof expected == "string") {
    486     shouldBe(actual, expected);
    487   } else if (typeof expected == "boolean") {
    488     shouldBe("typeof " + actual, "'boolean'");
    489     if (expected)
    490       shouldBeTrue(actual);
    491     else
    492       shouldBeFalse(actual);
    493   } else if (typeof expected == "number") {
    494     shouldBe(actual, stringify(expected));
    495   } else {
    496     debug(expected + " is unknown type " + typeof expected);
    497     shouldBeTrue(actual, "'"  +expected.toString() + "'");
    498   }
     465    // A general-purpose comparator.  'actual' should be a string to be
     466    // evaluated, as for shouldBe(). 'expected' may be any type and will be
     467    // used without being eval'ed.
     468    if (expected == null) {
     469        // Do this before the object test, since null is of type 'object'.
     470        shouldBeNull(actual);
     471    } else if (typeof expected == "undefined") {
     472        shouldBeUndefined(actual);
     473    } else if (typeof expected == "function") {
     474        // All this fuss is to avoid the string-arg warning from shouldBe().
     475        try {
     476            actualValue = eval(actual);
     477        } catch (e) {
     478            testFailed("Evaluating " + actual + ": Threw exception " + e);
     479            return;
     480        }
     481        shouldBe("'" + actualValue.toString().replace(/\n/g, "") + "'",
     482                 "'" + expected.toString().replace(/\n/g, "") + "'");
     483    } else if (typeof expected == "object") {
     484        shouldBeTrue(actual + " == '" + expected + "'");
     485    } else if (typeof expected == "string") {
     486        shouldBe(actual, expected);
     487    } else if (typeof expected == "boolean") {
     488        shouldBe("typeof " + actual, "'boolean'");
     489        if (expected)
     490            shouldBeTrue(actual);
     491        else
     492            shouldBeFalse(actual);
     493    } else if (typeof expected == "number") {
     494        shouldBe(actual, stringify(expected));
     495    } else {
     496        debug(expected + " is unknown type " + typeof expected);
     497        shouldBeTrue(actual, "'"  +expected.toString() + "'");
     498    }
    499499}
    500500
    501501function shouldBeNonZero(_a)
    502502{
    503   var exception;
    504   var _av;
    505   try {
    506      _av = eval(_a);
    507   } catch (e) {
    508      exception = e;
    509   }
    510 
    511   if (exception)
    512     testFailed(_a + " should be non-zero. Threw exception " + exception);
    513   else if (_av != 0)
    514     testPassed(_a + " is non-zero.");
    515   else
    516     testFailed(_a + " should be non-zero. Was " + _av);
     503    var exception;
     504    var _av;
     505    try {
     506        _av = eval(_a);
     507    } catch (e) {
     508        exception = e;
     509    }
     510
     511    if (exception)
     512        testFailed(_a + " should be non-zero. Threw exception " + exception);
     513    else if (_av != 0)
     514        testPassed(_a + " is non-zero.");
     515    else
     516        testFailed(_a + " should be non-zero. Was " + _av);
    517517}
    518518
    519519function shouldBeNonNull(_a)
    520520{
    521   var exception;
    522   var _av;
    523   try {
    524      _av = eval(_a);
    525   } catch (e) {
    526      exception = e;
    527   }
    528 
    529   if (exception)
    530     testFailed(_a + " should be non-null. Threw exception " + exception);
    531   else if (_av != null)
    532     testPassed(_a + " is non-null.");
    533   else
    534     testFailed(_a + " should be non-null. Was " + _av);
     521    var exception;
     522    var _av;
     523    try {
     524        _av = eval(_a);
     525    } catch (e) {
     526        exception = e;
     527    }
     528
     529    if (exception)
     530        testFailed(_a + " should be non-null. Threw exception " + exception);
     531    else if (_av != null)
     532        testPassed(_a + " is non-null.");
     533    else
     534        testFailed(_a + " should be non-null. Was " + _av);
    535535}
    536536
    537537function shouldBeUndefined(_a)
    538538{
    539   var exception;
    540   var _av;
    541   try {
    542      _av = eval(_a);
    543   } catch (e) {
    544      exception = e;
    545   }
    546 
    547   if (exception)
    548     testFailed(_a + " should be undefined. Threw exception " + exception);
    549   else if (typeof _av == "undefined")
    550     testPassed(_a + " is undefined.");
    551   else
    552     testFailed(_a + " should be undefined. Was " + _av);
     539    var exception;
     540    var _av;
     541    try {
     542        _av = eval(_a);
     543    } catch (e) {
     544        exception = e;
     545    }
     546
     547    if (exception)
     548        testFailed(_a + " should be undefined. Threw exception " + exception);
     549    else if (typeof _av == "undefined")
     550        testPassed(_a + " is undefined.");
     551    else
     552        testFailed(_a + " should be undefined. Was " + _av);
    553553}
    554554
    555555function shouldBeDefined(_a)
    556556{
    557   var exception;
    558   var _av;
    559   try {
    560      _av = eval(_a);
    561   } catch (e) {
    562      exception = e;
    563   }
    564 
    565   if (exception)
    566     testFailed(_a + " should be defined. Threw exception " + exception);
    567   else if (_av !== undefined)
    568     testPassed(_a + " is defined.");
    569   else
    570     testFailed(_a + " should be defined. Was " + _av);
     557    var exception;
     558    var _av;
     559    try {
     560        _av = eval(_a);
     561    } catch (e) {
     562        exception = e;
     563    }
     564
     565    if (exception)
     566        testFailed(_a + " should be defined. Threw exception " + exception);
     567    else if (_av !== undefined)
     568        testPassed(_a + " is defined.");
     569    else
     570        testFailed(_a + " should be defined. Was " + _av);
    571571}
    572572
     
    593593
    594594function expectTrue(v, msg) {
    595   if (v) {
    596     testPassed(msg);
    597   } else {
    598     testFailed(msg);
    599   }
     595    if (v) {
     596        testPassed(msg);
     597    } else {
     598        testFailed(msg);
     599    }
    600600}
    601601
     
    645645    }
    646646
    647      return _av.then(function(result) {
     647    return _av.then(function(result) {
    648648        testFailed((_message ? _message : _a) + " should reject promise. Resolved with " + result + ".");
    649649    }, function(error) {
     
    703703{
    704704    var numberOfCompiles = "compiles" in argument ? argument.compiles : 1;
    705    
     705
    706706    if (!("f" in argument))
    707707        throw new Error("dfgCompiled called with invalid argument.");
    708    
     708
    709709    if (argument.f instanceof Array) {
    710710        for (var i = 0; i < argument.f.length; ++i) {
     
    716716            return false;
    717717    }
    718    
     718
    719719    return true;
    720720}
     
    724724    if (!self.testRunner)
    725725        return argument.i;
    726    
     726
    727727    if (argument.i < argument.n)
    728728        return argument.i;
    729    
     729
    730730    if (didFailSomeTests)
    731731        return argument.i;
    732    
     732
    733733    if (!dfgCompiled(argument))
    734734        return "start" in argument ? argument.start : 0;
    735    
     735
    736736    return argument.i;
    737737}
     
    741741    if (!self.testRunner)
    742742        return;
    743    
     743
    744744    testRunner.neverInlineFunction(theFunction);
    745745}
     
    779779        var workerPrefix = "[Worker] ";
    780780        if (event.data.length < 5 || event.data.charAt(4) != ':') {
    781           debug(workerPrefix + event.data);
    782           return;
     781            debug(workerPrefix + event.data);
     782            return;
    783783        }
    784784        var code = event.data.substring(0, 4);
  • trunk/LayoutTests/resources/js-test-pre.js

    r215894 r216090  
    193193function evalAndLog(_a, _quiet)
    194194{
    195   if (typeof _a != "string")
    196     debug("WARN: evalAndLog() expects a string argument");
    197 
    198   // Log first in case things go horribly wrong or this causes a sync event.
    199   if (!_quiet)
    200     debug(_a);
    201 
    202   var _av;
    203   try {
    204      _av = eval(_a);
    205   } catch (e) {
    206     testFailed(_a + " threw exception " + e);
    207   }
    208   return _av;
     195    if (typeof _a != "string")
     196        debug("WARN: evalAndLog() expects a string argument");
     197
     198    // Log first in case things go horribly wrong or this causes a sync event.
     199    if (!_quiet)
     200        debug(_a);
     201
     202    var _av;
     203    try {
     204        _av = eval(_a);
     205    } catch (e) {
     206        testFailed(_a + " threw exception " + e);
     207    }
     208    return _av;
    209209}
    210210
    211211function evalAndLogResult(_a)
    212212{
    213   if (typeof _a != "string")
    214     debug("WARN: evalAndLogResult() expects a string argument");
    215 
    216   var _av;
    217   try {
    218      _av = eval(_a);
    219   } catch (e) {
    220     testFailed(_a + " threw exception " + e);
    221   }
    222 
    223   debug('<span>' + _a + " is " + escapeHTML(_av) + '</span>');
    224 }
    225 
    226 function shouldBe(_a, _b, quiet)
    227 {
    228   if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
    229     debug("WARN: shouldBe() expects function or string arguments");
    230   var exception;
    231   var _av;
    232   try {
    233     _av = (typeof _a == "function" ? _a() : eval(_a));
    234   } catch (e) {
    235     exception = e;
    236   }
    237   var _bv = (typeof _b == "function" ? _b() : eval(_b));
    238 
    239   if (exception)
    240     testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + exception);
    241   else if (isResultCorrect(_av, _bv)) {
    242     if (!quiet) {
    243       testPassed(_a + " is " + (typeof _b == "function" ? _bv : _b));
    244     }
    245   } else if (typeof(_av) == typeof(_bv))
    246     testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
    247   else
    248     testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
     213    if (typeof _a != "string")
     214        debug("WARN: evalAndLogResult() expects a string argument");
     215
     216    var _av;
     217    try {
     218        _av = eval(_a);
     219    } catch (e) {
     220        testFailed(_a + " threw exception " + e);
     221    }
     222
     223    debug('<span>' + _a + " is " + escapeHTML(_av) + '</span>');
     224}
     225
     226function shouldBe(_a, _b, _quiet)
     227{
     228    if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
     229        debug("WARN: shouldBe() expects function or string arguments");
     230    var _exception;
     231    var _av;
     232    try {
     233        _av = (typeof _a == "function" ? _a() : eval(_a));
     234    } catch (e) {
     235        _exception = e;
     236    }
     237    var _bv = (typeof _b == "function" ? _b() : eval(_b));
     238
     239    if (_exception)
     240        testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + _exception);
     241    else if (isResultCorrect(_av, _bv)) {
     242        if (!_quiet) {
     243            testPassed(_a + " is " + (typeof _b == "function" ? _bv : _b));
     244        }
     245    } else if (typeof(_av) == typeof(_bv))
     246        testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
     247    else
     248        testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
    249249}
    250250
    251251function dfgShouldBe(theFunction, _a, _b)
    252252{
    253   if (typeof theFunction != "function" || typeof _a != "string" || typeof _b != "string")
    254     debug("WARN: dfgShouldBe() expects a function and two strings");
    255   noInline(theFunction);
    256   var exception;
    257   var values = [];
    258 
    259   // Defend against tests that muck with numeric properties on array.prototype.
    260   values.__proto__ = null;
    261   values.push = Array.prototype.push;
    262  
    263   try {
    264     while (!dfgCompiled({f:theFunction}))
    265       values.push(eval(_a));
    266     values.push(eval(_a));
    267   } catch (e) {
    268     exception = e;
    269   }
    270 
    271   var _bv = eval(_b);
    272   if (exception)
    273     testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (values.length + 1) + ", threw exception " + exception);
    274   else {
    275     var allPassed = true;
    276     for (var i = 0; i < values.length; ++i) {
    277       var _av = values[i];
    278       if (isResultCorrect(_av, _bv))
    279         continue;
    280       if (typeof(_av) == typeof(_bv))
    281         testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (i + 1) + ", was " + stringify(_av) + ".");
    282       else
    283         testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). On iteration " + (i + 1) + ", was " + _av + " (of type " + typeof _av + ").");
    284       allPassed = false;
    285     }
    286     if (allPassed)
    287       testPassed(_a + " is " + _b + " on all iterations including after DFG tier-up.");
    288   }
    289  
    290   return values.length;
     253    if (typeof theFunction != "function" || typeof _a != "string" || typeof _b != "string")
     254        debug("WARN: dfgShouldBe() expects a function and two strings");
     255    noInline(theFunction);
     256    var exception;
     257    var values = [];
     258
     259    // Defend against tests that muck with numeric properties on array.prototype.
     260    values.__proto__ = null;
     261    values.push = Array.prototype.push;
     262
     263    try {
     264        while (!dfgCompiled({f:theFunction}))
     265            values.push(eval(_a));
     266        values.push(eval(_a));
     267    } catch (e) {
     268        exception = e;
     269    }
     270
     271    var _bv = eval(_b);
     272    if (exception)
     273        testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (values.length + 1) + ", threw exception " + exception);
     274    else {
     275        var allPassed = true;
     276        for (var i = 0; i < values.length; ++i) {
     277            var _av = values[i];
     278            if (isResultCorrect(_av, _bv))
     279                continue;
     280            if (typeof(_av) == typeof(_bv))
     281                testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (i + 1) + ", was " + stringify(_av) + ".");
     282            else
     283                testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). On iteration " + (i + 1) + ", was " + _av + " (of type " + typeof _av + ").");
     284            allPassed = false;
     285        }
     286        if (allPassed)
     287            testPassed(_a + " is " + _b + " on all iterations including after DFG tier-up.");
     288    }
     289
     290    return values.length;
    291291}
    292292
     
    294294function _waitForCondition(condition, completionHandler)
    295295{
    296   if (condition())
    297     completionHandler();
    298   else
    299     setTimeout(_waitForCondition, 5, condition, completionHandler);
     296    if (condition())
     297        completionHandler();
     298    else
     299        setTimeout(_waitForCondition, 5, condition, completionHandler);
    300300}
    301301
    302302function shouldBecomeEqual(_a, _b, completionHandler)
    303303{
    304   if (typeof _a != "string" || typeof _b != "string")
    305     debug("WARN: shouldBecomeEqual() expects string arguments");
    306 
    307   function condition() {
     304    if (typeof _a != "string" || typeof _b != "string")
     305        debug("WARN: shouldBecomeEqual() expects string arguments");
     306
     307    function condition() {
     308        var exception;
     309        var _av;
     310        try {
     311            _av = eval(_a);
     312        } catch (e) {
     313            exception = e;
     314        }
     315        var _bv = eval(_b);
     316        if (exception)
     317            testFailed(_a + " should become " + _bv + ". Threw exception " + exception);
     318        if (isResultCorrect(_av, _bv)) {
     319            testPassed(_a + " became " + _b);
     320            return true;
     321        }
     322        return false;
     323    }
     324    setTimeout(_waitForCondition, 0, condition, completionHandler);
     325}
     326
     327function shouldBecomeEqualToString(value, reference, completionHandler)
     328{
     329    if (typeof value !== "string" || typeof reference !== "string")
     330        debug("WARN: shouldBecomeEqualToString() expects string arguments");
     331    var unevaledString = JSON.stringify(reference);
     332    shouldBecomeEqual(value, unevaledString, completionHandler);
     333}
     334
     335function shouldBeType(_a, _type) {
    308336    var exception;
    309337    var _av;
    310338    try {
    311       _av = eval(_a);
    312     } catch (e) {
    313       exception = e;
    314     }
    315     var _bv = eval(_b);
    316     if (exception)
    317       testFailed(_a + " should become " + _bv + ". Threw exception " + exception);
    318     if (isResultCorrect(_av, _bv)) {
    319       testPassed(_a + " became " + _b);
    320       return true;
    321     }
    322     return false;
    323   }
    324   setTimeout(_waitForCondition, 0, condition, completionHandler);
    325 }
    326 
    327 function shouldBecomeEqualToString(value, reference, completionHandler)
    328 {
    329   if (typeof value !== "string" || typeof reference !== "string")
    330     debug("WARN: shouldBecomeEqualToString() expects string arguments");
    331   var unevaledString = JSON.stringify(reference);
    332   shouldBecomeEqual(value, unevaledString, completionHandler);
    333 }
    334 
    335 function shouldBeType(_a, _type) {
    336   var exception;
    337   var _av;
    338   try {
    339     _av = eval(_a);
    340   } catch (e) {
    341     exception = e;
    342   }
    343 
    344   var _typev = eval(_type);
    345   if (_av instanceof _typev) {
    346     testPassed(_a + " is an instance of " + _type);
    347   } else {
    348     testFailed(_a + " is not an instance of " + _type);
    349   }
     339        _av = eval(_a);
     340    } catch (e) {
     341        exception = e;
     342    }
     343
     344    var _typev = eval(_type);
     345    if (_av instanceof _typev) {
     346        testPassed(_a + " is an instance of " + _type);
     347    } else {
     348        testFailed(_a + " is not an instance of " + _type);
     349    }
    350350}
    351351
     
    354354function shouldBeCloseTo(_to_eval, _target, _tolerance, quiet)
    355355{
    356   if (typeof _to_eval != "string") {
    357     testFailed("shouldBeCloseTo() requires string argument _to_eval. was type " + typeof _to_eval);
    358     return;
    359   }
    360   if (typeof _target != "number") {
    361     testFailed("shouldBeCloseTo() requires numeric argument _target. was type " + typeof _target);
    362     return;
    363   }
    364   if (typeof _tolerance != "number") {
    365     testFailed("shouldBeCloseTo() requires numeric argument _tolerance. was type " + typeof _tolerance);
    366     return;
    367   }
    368 
    369   var _result;
    370   try {
    371      _result = eval(_to_eval);
    372   } catch (e) {
    373     testFailed(_to_eval + " should be within " + _tolerance + " of "
    374                + _target + ". Threw exception " + e);
    375     return;
    376   }
    377 
    378   if (typeof(_result) != typeof(_target)) {
    379     testFailed(_to_eval + " should be of type " + typeof _target
    380                + " but was of type " + typeof _result);
    381   } else if (Math.abs(_result - _target) <= _tolerance) {
    382     if (!quiet) {
    383         testPassed(_to_eval + " is within " + _tolerance + " of " + _target);
    384     }
    385   } else {
    386     testFailed(_to_eval + " should be within " + _tolerance + " of " + _target
    387                + ". Was " + _result + ".");
    388   }
    389 }
    390 
    391 function shouldNotBe(_a, _b, quiet)
    392 {
    393   if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
    394     debug("WARN: shouldNotBe() expects function or string arguments");
    395   var exception;
    396   var _av;
    397   try {
    398     _av = (typeof _a == "function" ? _a() : eval(_a));
    399   } catch (e) {
    400     exception = e;
    401   }
    402   var _bv = (typeof _b == "function" ? _b() : eval(_b));
    403 
    404   if (exception)
    405     testFailed(_a + " should not be " + _bv + ". Threw exception " + exception);
    406   else if (!isResultCorrect(_av, _bv)) {
    407     if (!quiet) {
    408       testPassed(_a + " is not " + (typeof _b == "function" ? _bv : _b));
    409     }
    410   } else
    411     testFailed(_a + " should not be " + _bv + ".");
     356    if (typeof _to_eval != "string") {
     357        testFailed("shouldBeCloseTo() requires string argument _to_eval. was type " + typeof _to_eval);
     358        return;
     359    }
     360    if (typeof _target != "number") {
     361        testFailed("shouldBeCloseTo() requires numeric argument _target. was type " + typeof _target);
     362        return;
     363    }
     364    if (typeof _tolerance != "number") {
     365        testFailed("shouldBeCloseTo() requires numeric argument _tolerance. was type " + typeof _tolerance);
     366        return;
     367    }
     368
     369    var _result;
     370    try {
     371        _result = eval(_to_eval);
     372    } catch (e) {
     373        testFailed(_to_eval + " should be within " + _tolerance + " of "
     374                   + _target + ". Threw exception " + e);
     375        return;
     376    }
     377
     378    if (typeof(_result) != typeof(_target)) {
     379        testFailed(_to_eval + " should be of type " + typeof _target
     380                   + " but was of type " + typeof _result);
     381    } else if (Math.abs(_result - _target) <= _tolerance) {
     382        if (!quiet) {
     383            testPassed(_to_eval + " is within " + _tolerance + " of " + _target);
     384        }
     385    } else {
     386        testFailed(_to_eval + " should be within " + _tolerance + " of " + _target
     387                   + ". Was " + _result + ".");
     388    }
     389}
     390
     391function shouldNotBe(_a, _b, _quiet)
     392{
     393    if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
     394        debug("WARN: shouldNotBe() expects function or string arguments");
     395    var _exception;
     396    var _av;
     397    try {
     398        _av = (typeof _a == "function" ? _a() : eval(_a));
     399    } catch (e) {
     400        _exception = e;
     401    }
     402    var _bv = (typeof _b == "function" ? _b() : eval(_b));
     403
     404    if (_exception)
     405        testFailed(_a + " should not be " + _bv + ". Threw exception " + _exception);
     406    else if (!isResultCorrect(_av, _bv)) {
     407        if (!_quiet) {
     408            testPassed(_a + " is not " + (typeof _b == "function" ? _bv : _b));
     409        }
     410    } else
     411        testFailed(_a + " should not be " + _bv + ".");
    412412}
    413413
    414414function shouldBecomeDifferent(_a, _b, completionHandler)
    415415{
    416   if (typeof _a != "string" || typeof _b != "string")
    417     debug("WARN: shouldBecomeDifferent() expects string arguments");
    418 
    419   function condition() {
    420     var exception;
    421     var _av;
    422     try {
    423       _av = eval(_a);
    424     } catch (e) {
    425       exception = e;
    426     }
    427     var _bv = eval(_b);
    428     if (exception)
    429       testFailed(_a + " should became not equal to " + _bv + ". Threw exception " + exception);
    430     if (!isResultCorrect(_av, _bv)) {
    431       testPassed(_a + " became different from " + _b);
    432       return true;
    433     }
    434     return false;
    435   }
    436   setTimeout(_waitForCondition, 0, condition, completionHandler);
     416    if (typeof _a != "string" || typeof _b != "string")
     417        debug("WARN: shouldBecomeDifferent() expects string arguments");
     418
     419    function condition() {
     420        var exception;
     421        var _av;
     422        try {
     423            _av = eval(_a);
     424        } catch (e) {
     425            exception = e;
     426        }
     427        var _bv = eval(_b);
     428        if (exception)
     429            testFailed(_a + " should became not equal to " + _bv + ". Threw exception " + exception);
     430        if (!isResultCorrect(_av, _bv)) {
     431            testPassed(_a + " became different from " + _b);
     432            return true;
     433        }
     434        return false;
     435    }
     436    setTimeout(_waitForCondition, 0, condition, completionHandler);
    437437}
    438438
     
    446446function shouldBeEqualToString(a, b)
    447447{
    448   if (typeof a !== "string" || typeof b !== "string")
    449     debug("WARN: shouldBeEqualToString() expects string arguments");
    450   var unevaledString = JSON.stringify(b);
    451   shouldBe(a, unevaledString);
     448    if (typeof a !== "string" || typeof b !== "string")
     449        debug("WARN: shouldBeEqualToString() expects string arguments");
     450    var unevaledString = JSON.stringify(b);
     451    shouldBe(a, unevaledString);
    452452}
    453453
    454454function shouldNotBeEqualToString(a, b)
    455455{
    456   if (typeof a !== "string" || typeof b !== "string")
    457     debug("WARN: shouldBeEqualToString() expects string arguments");
    458   var unevaledString = JSON.stringify(b);
    459   shouldNotBe(a, unevaledString);
     456    if (typeof a !== "string" || typeof b !== "string")
     457        debug("WARN: shouldBeEqualToString() expects string arguments");
     458    var unevaledString = JSON.stringify(b);
     459    shouldNotBe(a, unevaledString);
    460460}
    461461function shouldBeEmptyString(_a) { shouldBeEqualToString(_a, ""); }
     
    463463function shouldEvaluateTo(actual, expected)
    464464{
    465   // A general-purpose comparator.  'actual' should be a string to be
    466   // evaluated, as for shouldBe(). 'expected' may be any type and will be
    467   // used without being eval'ed.
    468   if (expected == null) {
    469     // Do this before the object test, since null is of type 'object'.
    470     shouldBeNull(actual);
    471   } else if (typeof expected == "undefined") {
    472     shouldBeUndefined(actual);
    473   } else if (typeof expected == "function") {
    474     // All this fuss is to avoid the string-arg warning from shouldBe().
    475     try {
    476       actualValue = eval(actual);
    477     } catch (e) {
    478       testFailed("Evaluating " + actual + ": Threw exception " + e);
    479       return;
    480     }
    481     shouldBe("'" + actualValue.toString().replace(/\n/g, "") + "'",
    482              "'" + expected.toString().replace(/\n/g, "") + "'");
    483   } else if (typeof expected == "object") {
    484     shouldBeTrue(actual + " == '" + expected + "'");
    485   } else if (typeof expected == "string") {
    486     shouldBe(actual, expected);
    487   } else if (typeof expected == "boolean") {
    488     shouldBe("typeof " + actual, "'boolean'");
    489     if (expected)
    490       shouldBeTrue(actual);
    491     else
    492       shouldBeFalse(actual);
    493   } else if (typeof expected == "number") {
    494     shouldBe(actual, stringify(expected));
    495   } else {
    496     debug(expected + " is unknown type " + typeof expected);
    497     shouldBeTrue(actual, "'"  +expected.toString() + "'");
    498   }
     465    // A general-purpose comparator.  'actual' should be a string to be
     466    // evaluated, as for shouldBe(). 'expected' may be any type and will be
     467    // used without being eval'ed.
     468    if (expected == null) {
     469        // Do this before the object test, since null is of type 'object'.
     470        shouldBeNull(actual);
     471    } else if (typeof expected == "undefined") {
     472        shouldBeUndefined(actual);
     473    } else if (typeof expected == "function") {
     474        // All this fuss is to avoid the string-arg warning from shouldBe().
     475        try {
     476            actualValue = eval(actual);
     477        } catch (e) {
     478            testFailed("Evaluating " + actual + ": Threw exception " + e);
     479            return;
     480        }
     481        shouldBe("'" + actualValue.toString().replace(/\n/g, "") + "'",
     482                 "'" + expected.toString().replace(/\n/g, "") + "'");
     483    } else if (typeof expected == "object") {
     484        shouldBeTrue(actual + " == '" + expected + "'");
     485    } else if (typeof expected == "string") {
     486        shouldBe(actual, expected);
     487    } else if (typeof expected == "boolean") {
     488        shouldBe("typeof " + actual, "'boolean'");
     489        if (expected)
     490            shouldBeTrue(actual);
     491        else
     492            shouldBeFalse(actual);
     493    } else if (typeof expected == "number") {
     494        shouldBe(actual, stringify(expected));
     495    } else {
     496        debug(expected + " is unknown type " + typeof expected);
     497        shouldBeTrue(actual, "'"  +expected.toString() + "'");
     498    }
    499499}
    500500
    501501function shouldBeNonZero(_a)
    502502{
    503   var exception;
    504   var _av;
    505   try {
    506      _av = eval(_a);
    507   } catch (e) {
    508      exception = e;
    509   }
    510 
    511   if (exception)
    512     testFailed(_a + " should be non-zero. Threw exception " + exception);
    513   else if (_av != 0)
    514     testPassed(_a + " is non-zero.");
    515   else
    516     testFailed(_a + " should be non-zero. Was " + _av);
     503    var exception;
     504    var _av;
     505    try {
     506        _av = eval(_a);
     507    } catch (e) {
     508        exception = e;
     509    }
     510
     511    if (exception)
     512        testFailed(_a + " should be non-zero. Threw exception " + exception);
     513    else if (_av != 0)
     514        testPassed(_a + " is non-zero.");
     515    else
     516        testFailed(_a + " should be non-zero. Was " + _av);
    517517}
    518518
    519519function shouldBeNonNull(_a)
    520520{
    521   var exception;
    522   var _av;
    523   try {
    524      _av = eval(_a);
    525   } catch (e) {
    526      exception = e;
    527   }
    528 
    529   if (exception)
    530     testFailed(_a + " should be non-null. Threw exception " + exception);
    531   else if (_av != null)
    532     testPassed(_a + " is non-null.");
    533   else
    534     testFailed(_a + " should be non-null. Was " + _av);
     521    var exception;
     522    var _av;
     523    try {
     524        _av = eval(_a);
     525    } catch (e) {
     526        exception = e;
     527    }
     528
     529    if (exception)
     530        testFailed(_a + " should be non-null. Threw exception " + exception);
     531    else if (_av != null)
     532        testPassed(_a + " is non-null.");
     533    else
     534        testFailed(_a + " should be non-null. Was " + _av);
    535535}
    536536
    537537function shouldBeUndefined(_a)
    538538{
    539   var exception;
    540   var _av;
    541   try {
    542      _av = eval(_a);
    543   } catch (e) {
    544      exception = e;
    545   }
    546 
    547   if (exception)
    548     testFailed(_a + " should be undefined. Threw exception " + exception);
    549   else if (typeof _av == "undefined")
    550     testPassed(_a + " is undefined.");
    551   else
    552     testFailed(_a + " should be undefined. Was " + _av);
     539    var exception;
     540    var _av;
     541    try {
     542        _av = eval(_a);
     543    } catch (e) {
     544        exception = e;
     545    }
     546
     547    if (exception)
     548        testFailed(_a + " should be undefined. Threw exception " + exception);
     549    else if (typeof _av == "undefined")
     550        testPassed(_a + " is undefined.");
     551    else
     552        testFailed(_a + " should be undefined. Was " + _av);
    553553}
    554554
    555555function shouldBeDefined(_a)
    556556{
    557   var exception;
    558   var _av;
    559   try {
    560      _av = eval(_a);
    561   } catch (e) {
    562      exception = e;
    563   }
    564 
    565   if (exception)
    566     testFailed(_a + " should be defined. Threw exception " + exception);
    567   else if (_av !== undefined)
    568     testPassed(_a + " is defined.");
    569   else
    570     testFailed(_a + " should be defined. Was " + _av);
     557    var exception;
     558    var _av;
     559    try {
     560        _av = eval(_a);
     561    } catch (e) {
     562        exception = e;
     563    }
     564
     565    if (exception)
     566        testFailed(_a + " should be defined. Threw exception " + exception);
     567    else if (_av !== undefined)
     568        testPassed(_a + " is defined.");
     569    else
     570        testFailed(_a + " should be defined. Was " + _av);
    571571}
    572572
     
    593593
    594594function expectTrue(v, msg) {
    595   if (v) {
    596     testPassed(msg);
    597   } else {
    598     testFailed(msg);
    599   }
     595    if (v) {
     596        testPassed(msg);
     597    } else {
     598        testFailed(msg);
     599    }
    600600}
    601601
     
    645645    }
    646646
    647      return _av.then(function(result) {
     647    return _av.then(function(result) {
    648648        testFailed((_message ? _message : _a) + " should reject promise. Resolved with " + result + ".");
    649649    }, function(error) {
     
    703703{
    704704    var numberOfCompiles = "compiles" in argument ? argument.compiles : 1;
    705    
     705
    706706    if (!("f" in argument))
    707707        throw new Error("dfgCompiled called with invalid argument.");
    708    
     708
    709709    if (argument.f instanceof Array) {
    710710        for (var i = 0; i < argument.f.length; ++i) {
     
    716716            return false;
    717717    }
    718    
     718
    719719    return true;
    720720}
     
    724724    if (!self.testRunner)
    725725        return argument.i;
    726    
     726
    727727    if (argument.i < argument.n)
    728728        return argument.i;
    729    
     729
    730730    if (didFailSomeTests)
    731731        return argument.i;
    732    
     732
    733733    if (!dfgCompiled(argument))
    734734        return "start" in argument ? argument.start : 0;
    735    
     735
    736736    return argument.i;
    737737}
     
    741741    if (!self.testRunner)
    742742        return;
    743    
     743
    744744    testRunner.neverInlineFunction(theFunction);
    745745}
     
    779779        var workerPrefix = "[Worker] ";
    780780        if (event.data.length < 5 || event.data.charAt(4) != ':') {
    781           debug(workerPrefix + event.data);
    782           return;
     781            debug(workerPrefix + event.data);
     782            return;
    783783        }
    784784        var code = event.data.substring(0, 4);
  • trunk/LayoutTests/resources/js-test.js

    r215894 r216090  
    229229}
    230230
    231 function shouldBe(_a, _b, quiet)
    232 {
    233   if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
    234     debug("WARN: shouldBe() expects function or string arguments");
    235   var _exception;
    236   var _av;
    237   try {
    238     _av = (typeof _a == "function" ? _a() : eval(_a));
    239   } catch (e) {
    240     _exception = e;
    241   }
    242   var _bv = (typeof _b == "function" ? _b() : eval(_b));
    243 
    244   if (_exception)
    245     testFailed(_a + " should be " + _bv + ". Threw exception " + _exception);
    246   else if (isResultCorrect(_av, _bv)) {
    247     if (!quiet) {
    248       testPassed(_a + " is " + (typeof _b == "function" ? _bv : _b));
    249     }
    250   } else if (typeof(_av) == typeof(_bv))
    251     testFailed(_a + " should be " + _bv + ". Was " + stringify(_av) + ".");
    252   else
    253     testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
     231function shouldBe(_a, _b, _quiet)
     232{
     233    if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
     234        debug("WARN: shouldBe() expects function or string arguments");
     235    var _exception;
     236    var _av;
     237    try {
     238        _av = (typeof _a == "function" ? _a() : eval(_a));
     239    } catch (e) {
     240        _exception = e;
     241    }
     242    var _bv = (typeof _b == "function" ? _b() : eval(_b));
     243
     244    if (_exception)
     245        testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + _exception);
     246    else if (isResultCorrect(_av, _bv)) {
     247        if (!_quiet) {
     248            testPassed(_a + " is " + (typeof _b == "function" ? _bv : _b));
     249        }
     250    } else if (typeof(_av) == typeof(_bv))
     251        testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
     252    else
     253        testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
    254254}
    255255
     
    354354function shouldNotBe(_a, _b, _quiet)
    355355{
    356   if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
    357     debug("WARN: shouldNotBe() expects function or string arguments");
    358   var _exception;
    359   var _av;
    360   try {
    361     _av = (typeof _a == "function" ? _a() : eval(_a));
    362   } catch (e) {
    363     _exception = e;
    364   }
    365   var _bv = (typeof _b == "function" ? _b() : eval(_b));
    366 
    367   if (_exception)
    368     testFailed(_a + " should not be " + _bv + ". Threw exception " + _exception);
    369   else if (!isResultCorrect(_av, _bv)) {
    370     if (!_quiet) {
    371       testPassed(_a + " is not " + (typeof _b == "function" ? _bv : _b));
    372     }
    373   } else
    374     testFailed(_a + " should not be " + _bv + ".");
     356    if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
     357        debug("WARN: shouldNotBe() expects function or string arguments");
     358    var _exception;
     359    var _av;
     360    try {
     361        _av = (typeof _a == "function" ? _a() : eval(_a));
     362    } catch (e) {
     363        _exception = e;
     364    }
     365    var _bv = (typeof _b == "function" ? _b() : eval(_b));
     366
     367    if (_exception)
     368        testFailed(_a + " should not be " + _bv + ". Threw exception " + _exception);
     369    else if (!isResultCorrect(_av, _bv)) {
     370        if (!_quiet) {
     371            testPassed(_a + " is not " + (typeof _b == "function" ? _bv : _b));
     372        }
     373    } else
     374        testFailed(_a + " should not be " + _bv + ".");
    375375}
    376376
     
    565565function shouldNotThrow(_a, _message) {
    566566    try {
    567         typeof _a == "function" ?  _a() : eval(_a);
     567        typeof _a == "function" ? _a() : eval(_a);
    568568        testPassed((_message ? _message : _a) + " did not throw exception.");
    569569    } catch (e) {
  • trunk/LayoutTests/resources/standalone-pre.js

    r215894 r216090  
    112112}
    113113
    114 function shouldBe(_a, _b, quiet)
    115 {
    116   if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
    117     debug("WARN: shouldBe() expects function or string arguments");
    118   var exception;
    119   var _av;
    120   try {
    121     _av = (typeof _a == "function" ? _a() : eval(_a));
    122   } catch (e) {
    123     exception = e;
    124   }
    125   var _bv = (typeof _b == "function" ? _b() : eval(_b));
    126 
    127   if (exception)
    128     testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + exception);
    129   else if (isResultCorrect(_av, _bv)) {
    130     if (!quiet) {
    131       testPassed(_a + " is " + (typeof _b == "function" ? _bv : _b));
    132     }
    133   } else if (typeof(_av) == typeof(_bv))
    134     testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
    135   else
    136     testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
     114function shouldBe(_a, _b, _quiet)
     115{
     116    if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
     117        debug("WARN: shouldBe() expects function or string arguments");
     118    var _exception;
     119    var _av;
     120    try {
     121        _av = (typeof _a == "function" ? _a() : eval(_a));
     122    } catch (e) {
     123        _exception = e;
     124    }
     125    var _bv = (typeof _b == "function" ? _b() : eval(_b));
     126
     127    if (_exception)
     128        testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + _exception);
     129    else if (isResultCorrect(_av, _bv)) {
     130        if (!_quiet) {
     131            testPassed(_a + " is " + (typeof _b == "function" ? _bv : _b));
     132        }
     133    } else if (typeof(_av) == typeof(_bv))
     134        testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
     135    else
     136        testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
    137137}
    138138
     
    196196}
    197197
    198 function shouldNotBe(_a, _b, quiet)
    199 {
    200   if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
    201     debug("WARN: shouldNotBe() expects function or string arguments");
    202   var exception;
    203   var _av;
    204   try {
    205     _av = (typeof _a == "function" ? _a() : eval(_a));
    206   } catch (e) {
    207     exception = e;
    208   }
    209   var _bv = (typeof _b == "function" ? _b() : eval(_b));
    210 
    211   if (exception)
    212     testFailed(_a + " should not be " + _bv + ". Threw exception " + exception);
    213   else if (!isResultCorrect(_av, _bv)) {
    214     if (!quiet) {
    215       testPassed(_a + " is not " + (typeof _b == "function" ? _bv : _b));
    216     }
    217   } else
    218     testFailed(_a + " should not be " + _bv + ".");
     198function shouldNotBe(_a, _b, _quiet)
     199{
     200    if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
     201        debug("WARN: shouldNotBe() expects function or string arguments");
     202    var _exception;
     203    var _av;
     204    try {
     205        _av = (typeof _a == "function" ? _a() : eval(_a));
     206    } catch (e) {
     207        _exception = e;
     208    }
     209    var _bv = (typeof _b == "function" ? _b() : eval(_b));
     210
     211    if (_exception)
     212        testFailed(_a + " should not be " + _bv + ". Threw exception " + _exception);
     213    else if (!isResultCorrect(_av, _bv)) {
     214        if (!_quiet) {
     215            testPassed(_a + " is not " + (typeof _b == "function" ? _bv : _b));
     216        }
     217    } else
     218        testFailed(_a + " should not be " + _bv + ".");
    219219}
    220220
     
    289289    var _ev;
    290290    if (_e)
    291         _ev =  eval(_e);
     291        _ev = eval(_e);
    292292
    293293    if (_exception) {
  • trunk/Tools/ChangeLog

    r216089 r216090  
     12017-05-02  David Kilzer  <ddkilzer@apple.com>
     2
     3        check-webkit-style should keep JavaScript test functions in sync
     4        <https://webkit.org/b/171424>
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Add a new JSTestChecker for check-webkit-style that keeps these
     9        two files in sync:
     10
     11            LayoutTests/http/tests/resources/js-test-pre.js
     12            LayoutTests/resources/js-test-pre.js
     13
     14        And keeps implementations of shouldBe(), shouldNotBe(),
     15        shouldNotThrow(), and shouldThrow() in sync across multiple
     16        files (with the ability to add more functions later):
     17
     18            JSTests/stress/resources/standalone-pre.js
     19            LayoutTests/http/tests/resources/js-test-pre.js
     20            LayoutTests/resources/js-test-pre.js
     21            LayoutTests/resources/js-test.js
     22            LayoutTests/resources/standalone-pre.js
     23
     24        * Scripts/webkitpy/style/checker.py: Remove unused import.  Add
     25        import for JSTestChecker.
     26        (_NEVER_SKIPPED_FILES): Add array of file names that are never
     27        skipped regardless of other rules.
     28        (_all_categories): Add JSTestChecker categories.
     29        (CheckerDispatcher.should_skip_without_warning): Use
     30        _NEVER_SKIPPED_FILES.
     31        (CheckerDispatcher._create_checker): Return JSTestChecker for
     32        the files to check.
     33
     34        * Scripts/webkitpy/style/checkers/jstest.py: Add.
     35        (map_functions_to_dict): Parse JavaScript source by splitting on
     36        /^function\s+/ regex.  This is good enough for the sanity checks
     37        to keep function implementations in sync.
     38        (strip_blank_lines_and_comments): Strips blank lines and lines
     39        with comments from the end of a chunk of text representing a
     40        function.
     41        (JSTestChecker): New checker.
     42        (JSTestChecker.__init__):
     43        (JSTestChecker.check):
     44        (JSTestChecker.check_js_test_files): Keeps whole files in sync.
     45        (JSTestChecker.check_js_test_functions): Keeps individual
     46        functions in sync.
     47
     48        * Scripts/webkitpy/style/checkers/jstest_unittest.py: Add test
     49        case.
     50        (JSTestTestCase):
     51        (JSTestTestCase.test_map_functions_to_dict):
     52
    1532017-05-02  Joanmarie Diggs  <jdiggs@igalia.com>
    254
  • trunk/Tools/Scripts/webkitpy/style/checker.py

    r216049 r216090  
    3535import os.path
    3636import re
    37 import sys
    3837
    3938from checkers.common import categories as CommonCategories
     
    4948from checkers.jsonchecker import JSONFeaturesChecker
    5049from checkers.jsonchecker import JSONCSSPropertiesChecker
     50from checkers.jstest import JSTestChecker
    5151from checkers.messagesin import MessagesInChecker
    5252from checkers.png import PNGChecker
     
    300300_CMAKE_FILE_EXTENSION = 'cmake'
    301301
     302# Files that are never skipped by name.
     303#
     304# Do not skip these files, even when they appear in
     305# _SKIPPED_FILES_WITH_WARNING or _SKIPPED_FILES_WITHOUT_WARNING.
     306_NEVER_SKIPPED_FILES = [
     307    'js-test-pre.js',
     308    'standalone-pre.js',
     309    'TestExpectations',
     310]
     311
    302312# Files to skip that are less obvious.
    303313#
     
    355365    categories = categories.union(JSChecker.categories)
    356366    categories = categories.union(JSONChecker.categories)
     367    categories = categories.union(JSTestChecker.categories)
    357368    categories = categories.union(TestExpectationsChecker.categories)
    358369    categories = categories.union(ChangeLogChecker.categories)
     
    551562        if basename.startswith('ChangeLog'):
    552563            return False
    553         elif basename == 'TestExpectations':
     564        elif basename in _NEVER_SKIPPED_FILES:
    554565            return False
    555566        for skipped_file in _SKIPPED_FILES_WITHOUT_WARNING:
     
    614625                                 handle_style_error, min_confidence)
    615626        elif file_type == FileType.JS:
     627            basename = os.path.basename(file_path)
    616628            # Do not attempt to check non-Inspector or 3rd-party JavaScript files as JS.
    617629            if os.path.join('WebInspectorUI', 'UserInterface') in file_path and (not 'External' in file_path):
    618630                checker = JSChecker(file_path, handle_style_error)
     631            elif basename == 'js-test-pre.js' or basename == 'standalone-pre.js':
     632                checker = JSTestChecker(file_path, handle_style_error)
    619633            else:
    620634                checker = TextChecker(file_path, handle_style_error)
Note: See TracChangeset for help on using the changeset viewer.