forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for %TypedArray%.prototype.sort stability
- Loading branch information
1 parent
e39604f
commit 1d77c79
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2019 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-%typedarray%.prototype.sort | ||
description: Stability of %TypedArray%.prototype.sort. | ||
info: | | ||
https://github.com/tc39/ecma262/pull/1433 | ||
includes: [testTypedArray.js, compareArray.js] | ||
features: [TypedArray] | ||
---*/ | ||
|
||
// Treat 0..3, 4..7, etc. as equal. | ||
const compare = (a, b) => (a / 4 | 0) - (b / 4 | 0); | ||
|
||
testWithTypedArrayConstructors((TA) => { | ||
const array = Array.from({ length: 128 }, (_, i) => i); | ||
const typedArray = new TA(array); | ||
assert(compareArray( | ||
typedArray.sort(compare), | ||
[0,1,2,3,4,5,6,7,9,8,10,11,14,13,12,15,127,126,125,124,123,122,121,120,119,118,117,116,115,114,113,112,111,110,109,108,107,106,105,104,103,102,101,100,99,98,97,96,95,94,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71,70,69,68,67,66,65,64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16] | ||
), 'sort is stable'); | ||
}); |