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 | load(libdir + "parallelarray-helpers.js"); |
michael@0 | 2 | |
michael@0 | 3 | // Test that we are able to compare numbers even if the typesets are |
michael@0 | 4 | // not "clean" because we have previously added strings and numbers. |
michael@0 | 5 | // Also test that we distinguish between bools/numbers etc for strict |
michael@0 | 6 | // equality but not loose equality. |
michael@0 | 7 | |
michael@0 | 8 | function theTest() { |
michael@0 | 9 | var ints = range(0, 1024); |
michael@0 | 10 | var doubles = ints.map(v => v + 0.1); |
michael@0 | 11 | var bools = ints.map(v => (v % 2) == 0); |
michael@0 | 12 | var strings = ints.map(v => String(v)); |
michael@0 | 13 | |
michael@0 | 14 | function looselyCompareToDoubles(e, i) { |
michael@0 | 15 | return doubles[i] == e; |
michael@0 | 16 | } |
michael@0 | 17 | print("doubles"); |
michael@0 | 18 | assertArraySeqParResultsEq(doubles, "map", looselyCompareToDoubles); |
michael@0 | 19 | print("bools"); |
michael@0 | 20 | assertArraySeqParResultsEq(bools, "map", looselyCompareToDoubles); |
michael@0 | 21 | // ion bails out when converting a string to a double right now, |
michael@0 | 22 | // so par exec cannot proceed |
michael@0 | 23 | print("strings"); |
michael@0 | 24 | assertParallelExecWillBail(function (mode) { |
michael@0 | 25 | strings.mapPar(looselyCompareToDoubles, mode) |
michael@0 | 26 | }); |
michael@0 | 27 | print("ints"); |
michael@0 | 28 | assertArraySeqParResultsEq(ints, "map", looselyCompareToDoubles); |
michael@0 | 29 | |
michael@0 | 30 | function strictlyCompareToDoubles(e, i) { |
michael@0 | 31 | return doubles[i] === e; |
michael@0 | 32 | } |
michael@0 | 33 | print("doubles, strict"); |
michael@0 | 34 | assertArraySeqParResultsEq(doubles, "map", strictlyCompareToDoubles); |
michael@0 | 35 | print("bools, strict"); |
michael@0 | 36 | assertArraySeqParResultsEq(bools, "map", strictlyCompareToDoubles); |
michael@0 | 37 | print("strings, strict"); |
michael@0 | 38 | assertArraySeqParResultsEq(strings, "map", strictlyCompareToDoubles); |
michael@0 | 39 | print("ints, strict"); |
michael@0 | 40 | assertArraySeqParResultsEq(ints, "map", strictlyCompareToDoubles); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | if (getBuildConfiguration().parallelJS) |
michael@0 | 44 | theTest(); |