Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Versions to test listed in ascending order, none can be equal |
michael@0 | 2 | var comparisons = [ |
michael@0 | 3 | "0.9", |
michael@0 | 4 | "0.9.1", |
michael@0 | 5 | "1.0pre1", |
michael@0 | 6 | "1.0pre2", |
michael@0 | 7 | "1.0", |
michael@0 | 8 | "1.1pre", |
michael@0 | 9 | "1.1pre1a", |
michael@0 | 10 | "1.1pre1", |
michael@0 | 11 | "1.1pre10a", |
michael@0 | 12 | "1.1pre10", |
michael@0 | 13 | "1.1", |
michael@0 | 14 | "1.1.0.1", |
michael@0 | 15 | "1.1.1", |
michael@0 | 16 | "1.1.*", |
michael@0 | 17 | "1.*", |
michael@0 | 18 | "2.0", |
michael@0 | 19 | "2.1", |
michael@0 | 20 | "3.0.-1", |
michael@0 | 21 | "3.0" |
michael@0 | 22 | ]; |
michael@0 | 23 | |
michael@0 | 24 | // Every version in this list means the same version number |
michael@0 | 25 | var equality = [ |
michael@0 | 26 | "1.1pre", |
michael@0 | 27 | "1.1pre0", |
michael@0 | 28 | "1.0+" |
michael@0 | 29 | ]; |
michael@0 | 30 | |
michael@0 | 31 | function run_test() |
michael@0 | 32 | { |
michael@0 | 33 | var vc = Components.classes["@mozilla.org/xpcom/version-comparator;1"] |
michael@0 | 34 | .getService(Components.interfaces.nsIVersionComparator); |
michael@0 | 35 | |
michael@0 | 36 | for (var i = 0; i < comparisons.length; i++) { |
michael@0 | 37 | for (var j = 0; j < comparisons.length; j++) { |
michael@0 | 38 | var result = vc.compare(comparisons[i], comparisons[j]); |
michael@0 | 39 | if (i == j) { |
michael@0 | 40 | if (result != 0) |
michael@0 | 41 | do_throw(comparisons[i] + " should be the same as itself"); |
michael@0 | 42 | } |
michael@0 | 43 | else if (i < j) { |
michael@0 | 44 | if (!(result < 0)) |
michael@0 | 45 | do_throw(comparisons[i] + " should be less than " + comparisons[j]); |
michael@0 | 46 | } |
michael@0 | 47 | else if (!(result > 0)) { |
michael@0 | 48 | do_throw(comparisons[i] + " should be greater than " + comparisons[j]); |
michael@0 | 49 | } |
michael@0 | 50 | } |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | for (i = 0; i < equality.length; i++) { |
michael@0 | 54 | for (j = 0; j < equality.length; j++) { |
michael@0 | 55 | if (vc.compare(equality[i], equality[j]) != 0) |
michael@0 | 56 | do_throw(equality[i] + " should equal " + equality[j]); |
michael@0 | 57 | } |
michael@0 | 58 | } |
michael@0 | 59 | } |