Changeset 175729 in webkit


Ignore:
Timestamp:
Nov 6, 2014 4:49:36 PM (9 years ago)
Author:
mark.lam@apple.com
Message:

Refactor the get-by-pname.js test [follow up].
<https://webkit.org/b/138483>

Reviewed by Michael Saboff.

Used named properties to make the test code more readable.

  • js/script-tests/get-by-pname.js:

(isTierIteration):
(tierName):
(testExpr): Deleted.
(testExpectedResult): Deleted.

Location:
trunk/LayoutTests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r175724 r175729  
     12014-11-06  Mark Lam  <mark.lam@apple.com>
     2
     3        Refactor the get-by-pname.js test [follow up].
     4        <https://webkit.org/b/138483>
     5
     6        Reviewed by Michael Saboff.
     7
     8        Used named properties to make the test code more readable.
     9       
     10        * js/script-tests/get-by-pname.js:
     11        (isTierIteration):
     12        (tierName):
     13        (testExpr): Deleted.
     14        (testExpectedResult): Deleted.
     15
    1162014-11-06  Mark Lam  <mark.lam@apple.com>
    217
  • trunk/LayoutTests/js/script-tests/get-by-pname.js

    r175724 r175729  
    3434
    3535var testCases = [
    36     [ "foo(o)", "11" ],
    37     [ "foo(p)", "10" ],
    38     [ "foo(q)", "3467" ],
    39     [ "foo(r)", "113" ],
    40     [ "foo(s)", "182" ],
     36    { test: "foo(o)", result: "11" },
     37    { test: "foo(p)", result: "10" },
     38    { test: "foo(q)", result: "3467" },
     39    { test: "foo(r)", result: "113" },
     40    { test: "foo(s)", result: "182" },
    4141
    42     [ "getByPnameOnConstant(a)", "0" ],
    43     [ "getByPnameOnVar(a, 100)", "0" ],
    44     [ "getByPnameOnVar(a, 'abc')", "'0abc'" ],
    45     [ "getByPnameOnVar(a, o)", "0" ],
    46     [ "getByPnameOnVar(a, o1)", "4" ],
    47     [ "getByPnameOnVar(a, a)", "6" ],
     42    { test: "getByPnameOnConstant(a)", result: "0" },
     43    { test: "getByPnameOnVar(a, 100)", result: "0" },
     44    { test: "getByPnameOnVar(a, 'abc')", result: "'0abc'" },
     45    { test: "getByPnameOnVar(a, o)", result: "0" },
     46    { test: "getByPnameOnVar(a, o1)", result: "4" },
     47    { test: "getByPnameOnVar(a, a)", result: "6" },
    4848
    49     [ "getByPnameOnConstant(o1)", "0" ],
    50     [ "getByPnameOnVar(o1, 100)", "0" ],
    51     [ "getByPnameOnVar(o1, 'abc')", "'0bc0'" ],
    52     [ "getByPnameOnVar(o1, o)", "0" ],
    53     [ "getByPnameOnVar(o1, o1)", "11" ],
    54     [ "getByPnameOnVar(o1, a)", "5" ],
     49    { test: "getByPnameOnConstant(o1)", result: "0" },
     50    { test: "getByPnameOnVar(o1, 100)", result: "0" },
     51    { test: "getByPnameOnVar(o1, 'abc')", result: "'0bc0'" },
     52    { test: "getByPnameOnVar(o1, o)", result: "0" },
     53    { test: "getByPnameOnVar(o1, o1)", result: "11" },
     54    { test: "getByPnameOnVar(o1, a)", result: "5" },
    5555
    56     [ "getByPnameOnConstant(o)", "0" ],
    57     [ "getByPnameOnVar(o, 100)", "0" ],
    58     [ "getByPnameOnVar(o, 'abc')", "0" ],
    59     [ "getByPnameOnVar(o, o)", "11" ],
    60     [ "getByPnameOnVar(o, o1)", "0" ],
    61     [ "getByPnameOnVar(o, a)", "0" ],
     56    { test: "getByPnameOnConstant(o)", result: "0" },
     57    { test: "getByPnameOnVar(o, 100)", result: "0" },
     58    { test: "getByPnameOnVar(o, 'abc')", result: "0" },
     59    { test: "getByPnameOnVar(o, o)", result: "11" },
     60    { test: "getByPnameOnVar(o, o1)", result: "0" },
     61    { test: "getByPnameOnVar(o, a)", result: "0" },
    6262
    63     [ "getByPnameOnConstant(0)", "0" ],
    64     [ "getByPnameOnVar(0, 100)", "0" ],
    65     [ "getByPnameOnVar(0, 'abc')", "0" ],
    66     [ "getByPnameOnVar(0, o)", "0" ],
    67     [ "getByPnameOnVar(0, o1)", "0" ],
    68     [ "getByPnameOnVar(0, a)", "0" ],
     63    { test: "getByPnameOnConstant(0)", result: "0" },
     64    { test: "getByPnameOnVar(0, 100)", result: "0" },
     65    { test: "getByPnameOnVar(0, 'abc')", result: "0" },
     66    { test: "getByPnameOnVar(0, o)", result: "0" },
     67    { test: "getByPnameOnVar(0, o1)", result: "0" },
     68    { test: "getByPnameOnVar(0, a)", result: "0" },
    6969
    70     [ "getByPnameOnConstant('abc')", "0" ],
    71     [ "getByPnameOnVar('abc', 100)", "0" ],
    72     [ "getByPnameOnVar('abc', 'abc')", "'0abc'" ],
    73     [ "getByPnameOnVar('abc', o)", "0" ],
    74     [ "getByPnameOnVar('abc', o1)", "4" ],
    75     [ "getByPnameOnVar('abc', a)", "6" ],
    76     [ "getByPnameOnVar('def', 'abc')", "'0abc'" ],
     70    { test: "getByPnameOnConstant('abc')", result: "0" },
     71    { test: "getByPnameOnVar('abc', 100)", result: "0" },
     72    { test: "getByPnameOnVar('abc', 'abc')", result: "'0abc'" },
     73    { test: "getByPnameOnVar('abc', o)", result: "0" },
     74    { test: "getByPnameOnVar('abc', o1)", result: "4" },
     75    { test: "getByPnameOnVar('abc', a)", result: "6" },
     76    { test: "getByPnameOnVar('def', 'abc')", result: "'0abc'" },
    7777];
    78 
    79 function testExpr(index) {
    80     return testCases[index][0];
    81 }
    82 function testExpectedResult(index) {
    83     return testCases[index][1];
    84 }
    8578
    8679// The tiers should be sorted from lowest iterations to highest.
    8780var tiers = [
    8881    // name, iterations
    89     [ "cold", 0 ],
    90     [ "llint", 10 ],
    91     [ "baseline", 500 ],
    92     [ "dfg", 1000 ],
    93     // [ "ftl", 100000 ],
     82    { name: "cold", iterations: 0 },
     83    { name: "llint", iterations: 10 },
     84    { name: "baseline", iterations: 500 },
     85    { name: "dfg", iterations: 1000 },
     86    // { name: "ftl", iterations: 100000 },
    9487];
    95 var highestIteration = tiers[tiers.length - 1][1];
     88var highestIteration = tiers[tiers.length - 1].iterations;
    9689
    9790function isTierIteration(iteration) {
    9891    for (var i = 0; i < tiers.length; i++) {
    99         var tierIteration = tiers[i][1];
     92        var tierIteration = tiers[i].iterations;
    10093        if (iteration < tierIteration)
    10194            return false;
     
    107100function tierName(iteration) {
    108101    for (var i = 0; i < tiers.length; i++) {
    109         if (iteration == tiers[i][1])
    110             return tiers[i][0];
     102        if (iteration == tiers[i].iterations)
     103            return tiers[i].name;
    111104    }
    112105}
     
    116109        debug("Test tier: " + tierName(i));
    117110        for (var j = 0; j < testCases.length; j++)
    118             shouldBe(testExpr(j), testExpectedResult(j));
     111            shouldBe(testCases[j].test, testCases[j].result);
    119112        debug("");
    120113    } else {
    121114        for (var j = 0; j < testCases.length; j++)
    122             eval(testExpr(j));
     115            eval(testCases[j].test);
    123116    }
    124117}
Note: See TracChangeset for help on using the changeset viewer.