forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes.array.at.js
30 lines (29 loc) · 999 Bytes
/
es.array.at.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { STRICT } from '../helpers/constants';
QUnit.test('Array#at', assert => {
const { at } = Array.prototype;
assert.isFunction(at);
assert.arity(at, 1);
assert.name(at, 'at');
assert.looksNative(at);
assert.nonEnumerable(Array.prototype, 'at');
assert.same(1, [1, 2, 3].at(0));
assert.same(2, [1, 2, 3].at(1));
assert.same(3, [1, 2, 3].at(2));
assert.same(undefined, [1, 2, 3].at(3));
assert.same(3, [1, 2, 3].at(-1));
assert.same(2, [1, 2, 3].at(-2));
assert.same(1, [1, 2, 3].at(-3));
assert.same(undefined, [1, 2, 3].at(-4));
assert.same(1, [1, 2, 3].at(0.4));
assert.same(1, [1, 2, 3].at(0.5));
assert.same(1, [1, 2, 3].at(0.6));
assert.same(1, [1].at(NaN));
assert.same(1, [1].at());
assert.same(1, [1, 2, 3].at(-0));
assert.same(undefined, Array(1).at(0));
assert.same(1, at.call({ 0: 1, length: 1 }, 0));
if (STRICT) {
assert.throws(() => at.call(null, 0), TypeError);
assert.throws(() => at.call(undefined, 0), TypeError);
}
});