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