js/src/jit-test/tests/basic/testWeirdDateParse.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 var global = this;
michael@0 2 function testWeirdDateParseOuter()
michael@0 3 {
michael@0 4 var vDateParts = ["11", "17", "2008"];
michael@0 5 var out = [];
michael@0 6 for (var vI = 0; vI < vDateParts.length; vI++)
michael@0 7 out.push(testWeirdDateParseInner(vDateParts[vI]));
michael@0 8 /* Mutate the global shape so we fall off trace; this causes
michael@0 9 * additional oddity */
michael@0 10 global.x = Math.random();
michael@0 11 return out;
michael@0 12 }
michael@0 13 function testWeirdDateParseInner(pVal)
michael@0 14 {
michael@0 15 var vR = 0;
michael@0 16 for (var vI = 0; vI < pVal.length; vI++) {
michael@0 17 var vC = pVal.charAt(vI);
michael@0 18 if ((vC >= '0') && (vC <= '9'))
michael@0 19 vR = (vR * 10) + parseInt(vC);
michael@0 20 }
michael@0 21 return vR;
michael@0 22 }
michael@0 23 function testWeirdDateParse() {
michael@0 24 var result = [];
michael@0 25 result.push(testWeirdDateParseInner("11"));
michael@0 26 result.push(testWeirdDateParseInner("17"));
michael@0 27 result.push(testWeirdDateParseInner("2008"));
michael@0 28 result.push(testWeirdDateParseInner("11"));
michael@0 29 result.push(testWeirdDateParseInner("17"));
michael@0 30 result.push(testWeirdDateParseInner("2008"));
michael@0 31 result = result.concat(testWeirdDateParseOuter());
michael@0 32 result = result.concat(testWeirdDateParseOuter());
michael@0 33 result.push(testWeirdDateParseInner("11"));
michael@0 34 result.push(testWeirdDateParseInner("17"));
michael@0 35 result.push(testWeirdDateParseInner("2008"));
michael@0 36 return result.join(",");
michael@0 37 }
michael@0 38 assertEq(testWeirdDateParse(), "11,17,2008,11,17,2008,11,17,2008,11,17,2008,11,17,2008");

mercurial