forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes.iterator.some.js
32 lines (26 loc) · 1.32 KB
/
es.iterator.some.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
31
32
import { createIterator } from '../helpers/helpers.js';
import { STRICT, STRICT_THIS } from '../helpers/constants.js';
import Iterator from 'core-js-pure/es/iterator';
QUnit.test('Iterator#some', assert => {
const { some } = Iterator.prototype;
assert.isFunction(some);
assert.arity(some, 1);
assert.nonEnumerable(Iterator.prototype, 'some');
assert.true(some.call(createIterator([1, 2, 3]), it => it % 2), 'basic functionality #1');
assert.false(some.call(createIterator([1, 2, 3]), it => typeof it == 'string'), 'basic functionality #2');
some.call(createIterator([1]), function (arg, counter) {
assert.same(this, STRICT_THIS, 'this');
assert.same(arguments.length, 2, 'arguments length');
assert.same(arg, 1, 'argument');
assert.same(counter, 0, 'counter');
});
if (STRICT) {
assert.throws(() => some.call(undefined, () => { /* empty */ }), TypeError);
assert.throws(() => some.call(null, () => { /* empty */ }), TypeError);
}
assert.throws(() => some.call({}, () => { /* empty */ }), TypeError);
assert.throws(() => some.call([], () => { /* empty */ }), TypeError);
assert.throws(() => some.call(createIterator([1]), undefined), TypeError);
assert.throws(() => some.call(createIterator([1]), null), TypeError);
assert.throws(() => some.call(createIterator([1]), {}), TypeError);
});