feat: some array tests

This commit is contained in:
2024-01-06 17:49:36 +02:00
parent 0251c4689d
commit 4572db5c46
14 changed files with 195 additions and 80 deletions

View File

@@ -1,4 +1,6 @@
return new UnitTest('concat', function() { return typeof Array.prototype.concat === 'function'; })
.add('two arrays', function() { return match([1, 2, 3], [1].concat([2], [3])) })
.add('simple spread', function() { return match([1, 2, 3, 4, 5], [1].concat([2], 3, [4, 5])) })
.add('sparse concat', function() { return match([1,, 2,,, 3,,, 4, 5], [1,,2].concat([,,3,,,4], 5)) })
return new UnitTest('sort', function() { return typeof Array.prototype.sort === 'function'; })
.add('simple', function() { return match([4, 6, 2].sort(), [2, 4, 6]) })
.add('stringify', function() { return match([4, 6, 2, 10].sort(), [10, 2, 4, 6]) })
.add('undefined and empty', function() { return match([4, undefined, 6, , 2].sort(), [2, 4, 6, undefined,,]) })
.add('function ascend', function() { return match([3, 1, 2].sort(function (a, b) { return a - b; }), [1, 2, 3]) })
.add('function descend', function() { return match([3, 1, 2].sort(function (a, b) { return b - a; }), [3, 2, 1]) })