Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: qunit/tests/versionComparator.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Patch Set: Rebased Created March 17, 2017, 12:41 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « qunit/tests/url.js ('k') | stats.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 /* globals Cu */
19
18 "use strict"; 20 "use strict";
19 21
22 (function()
20 { 23 {
21 let compare = Services.vc.compare; 24 const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
25 const {compare} = Services.vc;
22 26
23 function allPairs(array) 27 function allPairs(array)
24 { 28 {
25 let pairs = []; 29 let pairs = [];
26 for (let i = 0; i < array.length - 1; i++) 30 for (let i = 0; i < array.length - 1; i++)
31 {
27 for (let j = i + 1; j < array.length; j++) 32 for (let j = i + 1; j < array.length; j++)
28 pairs.push([array[i], array[j]]); 33 pairs.push([array[i], array[j]]);
34 }
29 return pairs; 35 return pairs;
30 } 36 }
31 37
32 function versionsEqual(versions) 38 function versionsEqual(versions)
33 { 39 {
34 allPairs(versions).forEach(pair => 40 allPairs(versions).forEach(pair =>
35 { 41 {
36 let v1 = pair[0]; 42 let v1 = pair[0];
37 let v2 = pair[1]; 43 let v2 = pair[1];
38 equal(compare(v1, v2), 0, "'" + v1 + "' should be equal to '" + v2 + "'"); 44 equal(compare(v1, v2), 0, "'" + v1 + "' should be equal to '" + v2 + "'");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 "1.0+a", 86 "1.0+a",
81 "1.0a", 87 "1.0a",
82 "1.0pre1", 88 "1.0pre1",
83 "1.0pre2", 89 "1.0pre2",
84 ["1.0", "1.0.0", "1.0.0.0"], 90 ["1.0", "1.0.0", "1.0.0.0"],
85 ["1.1pre", "1.1pre0", "1.0+"], 91 ["1.1pre", "1.1pre0", "1.0+"],
86 "1.1pre1a", 92 "1.1pre1a",
87 "1.1pre1", 93 "1.1pre1",
88 "1.1pre10a", 94 "1.1pre10a",
89 ["1.1pre10", "1.1pre010"], 95 ["1.1pre10", "1.1pre010"],
90 ["1.10", "1.010", "1.00010"], 96 ["1.10", "1.010", "1.00010"]
91 ]; 97 ];
92 98
93 examples.forEach(example => 99 examples.forEach(example =>
94 { 100 {
95 if (example instanceof Array) 101 if (example instanceof Array)
96 versionsEqual(example); 102 versionsEqual(example);
97 }); 103 });
98 104
99 allPairs(examples).forEach(pair => 105 allPairs(examples).forEach(pair =>
100 { 106 {
101 let v1 = [].concat(pair[0]); 107 let v1 = [].concat(pair[0]);
102 let v2 = [].concat(pair[1]); 108 let v2 = [].concat(pair[1]);
103 for (let i = 0; i < v1.length; i++) 109 for (let i = 0; i < v1.length; i++)
110 {
104 for (let j = 0; j < v2.length; j++) 111 for (let j = 0; j < v2.length; j++)
105 versionSmaller(v1[i], v2[j]); 112 versionSmaller(v1[i], v2[j]);
113 }
106 }); 114 });
107 }); 115 });
108 } 116 }());
OLDNEW
« no previous file with comments | « qunit/tests/url.js ('k') | stats.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld