summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/TypedArray/sorting_buffer_access.js
blob: c31f4ca167a0d1f6343846aeff15c3846ee037ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Ensure that when sorting arrays of size greater than 128, which
// calls RadixSort under the hood, we don't access the 'buffer' 
// property of the typed array directly. 


// The buggy behavior in the RadixSort is only exposed when we use
// float arrays, but checking everything just to be sure.
for (var ctor of anyTypedArrayConstructors) {
    var testArray = new ctor(1024);
    Object.defineProperty(testArray, "buffer", { get() { throw new Error("FAIL: Buffer accessed directly"); }  });
    testArray.sort();
}

if (typeof reportCompare === "function")
    reportCompare(true, true);