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 Feb. 28, 2017, 3:47 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 Services */
19
18 "use strict"; 20 "use strict";
19 21
20 { 22 {
21 let compare = Services.vc.compare; 23 let {compare} = Services.vc;
22 24
23 function allPairs(array) 25 function allPairs(array)
24 { 26 {
25 let pairs = []; 27 let pairs = [];
26 for (let i = 0; i < array.length - 1; i++) 28 for (let i = 0; i < array.length - 1; i++)
29 {
27 for (let j = i + 1; j < array.length; j++) 30 for (let j = i + 1; j < array.length; j++)
28 pairs.push([array[i], array[j]]); 31 pairs.push([array[i], array[j]]);
32 }
29 return pairs; 33 return pairs;
30 } 34 }
31 35
32 function versionsEqual(versions) 36 function versionsEqual(versions)
33 { 37 {
34 allPairs(versions).forEach(pair => 38 allPairs(versions).forEach(pair =>
35 { 39 {
36 let v1 = pair[0]; 40 let v1 = pair[0];
37 let v2 = pair[1]; 41 let v2 = pair[1];
38 equal(compare(v1, v2), 0, "'" + v1 + "' should be equal to '" + v2 + "'"); 42 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", 84 "1.0+a",
81 "1.0a", 85 "1.0a",
82 "1.0pre1", 86 "1.0pre1",
83 "1.0pre2", 87 "1.0pre2",
84 ["1.0", "1.0.0", "1.0.0.0"], 88 ["1.0", "1.0.0", "1.0.0.0"],
85 ["1.1pre", "1.1pre0", "1.0+"], 89 ["1.1pre", "1.1pre0", "1.0+"],
86 "1.1pre1a", 90 "1.1pre1a",
87 "1.1pre1", 91 "1.1pre1",
88 "1.1pre10a", 92 "1.1pre10a",
89 ["1.1pre10", "1.1pre010"], 93 ["1.1pre10", "1.1pre010"],
90 ["1.10", "1.010", "1.00010"], 94 ["1.10", "1.010", "1.00010"]
91 ]; 95 ];
92 96
93 examples.forEach(example => 97 examples.forEach(example =>
94 { 98 {
95 if (example instanceof Array) 99 if (example instanceof Array)
96 versionsEqual(example); 100 versionsEqual(example);
97 }); 101 });
98 102
99 allPairs(examples).forEach(pair => 103 allPairs(examples).forEach(pair =>
100 { 104 {
101 let v1 = [].concat(pair[0]); 105 let v1 = [].concat(pair[0]);
102 let v2 = [].concat(pair[1]); 106 let v2 = [].concat(pair[1]);
103 for (let i = 0; i < v1.length; i++) 107 for (let i = 0; i < v1.length; i++)
108 {
104 for (let j = 0; j < v2.length; j++) 109 for (let j = 0; j < v2.length; j++)
105 versionSmaller(v1[i], v2[j]); 110 versionSmaller(v1[i], v2[j]);
111 }
106 }); 112 });
107 }); 113 });
108 } 114 }
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