Bug 1410545 - Fix sort_snans.js test on big endian. r=jwalden
authorAdrian Bunk <bunk@debian.org>
Tue, 02 Oct 2018 15:50:16 -0400
changeset 495503 e8aec0dccbb8213dd292d7331f01307969cdff9a
parent 495502 2f853725d168f5d61a5a016871af330f51f87eac
child 495504 4b23febdfd1742da5774f548e322e298a8425f6b
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs1410545
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1410545 - Fix sort_snans.js test on big endian. r=jwalden
js/src/tests/non262/TypedArray/sort_snans.js
--- a/js/src/tests/non262/TypedArray/sort_snans.js
+++ b/js/src/tests/non262/TypedArray/sort_snans.js
@@ -29,16 +29,23 @@ function testFloat32NaNRanges(start, end
     floatView.sort();
     assertDeepEq(floatView, NaNArray);
 }
 
 // Test every skipNth value in some range n, where start <= n <= end
 // and startHi, startLow and endHi, endLow should be 32-bit integers which,
 // when combined (Hi + Low), form Float64 NaNs.
 function testFloat64NaNRanges(startHi, startLow, endHi, endLow) {
+
+    // Swap on big endian platforms
+    if (new Uint32Array(new Uint8Array([1,2,3,4]).buffer)[0] === 0x01020304) {
+	[startHi, startLow] = [startLow, startHi];
+	[endHi, endLow] = [endLow, endHi];
+    }
+
     let skipN = 10e6;
 
     let sampleSizeHi  = Math.floor((endHi - startHi)/skipN);
     let sampleSizeLow = Math.floor((endLow - startLow)/skipN);
 
     let NaNArray   = new Float64Array(getNaNArray(sampleSizeHi + sampleSizeLow));
     let buffer     = new ArrayBuffer(8 * (sampleSizeHi + sampleSizeLow));
     let uintView   = new Uint32Array(buffer);