forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes.array.push.js
22 lines (17 loc) · 912 Bytes
/
es.array.push.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants';
import push from 'core-js-pure/es/array/virtual/push';
import defineProperty from 'core-js-pure/es/object/define-property';
QUnit.test('Array#push', assert => {
assert.isFunction(push);
const object = { length: 0x100000000 };
assert.same(push.call(object, 1), 0x100000001, 'proper ToLength #1');
assert.same(object[0x100000000], 1, 'proper ToLength #2');
if (STRICT) {
if (REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR) {
assert.throws(() => push.call(defineProperty([], 'length', { writable: false }), 1), TypeError, 'non-writable length, with arg');
assert.throws(() => push.call(defineProperty([], 'length', { writable: false })), TypeError, 'non-writable length, without arg');
}
assert.throws(() => push.call(null), TypeError);
assert.throws(() => push.call(undefined), TypeError);
}
});