core-js
Version:
Standard library
1,875 lines (1,867 loc) • 128 kB
JavaScript
(function(){
var from, iterator, toString$ = {}.toString;
QUnit.module('$for');
from = Array.from;
iterator = Symbol.iterator;
test('$for', function(){
var set, iter;
ok(typeof $for === 'function', 'Is function');
ok(iterator in $for.prototype);
set = new Set(['1', '2', '3', '2', '1']);
iter = $for(set);
ok(iter instanceof $for);
ok(toString$.call(iter[iterator]()).slice(8, -1) === 'Set Iterator');
deepEqual(['1', '2', '3'], from(iter));
});
test('$for#filter', function(){
var set, iter, o;
ok(typeof $for.prototype.filter === 'function', 'Is function');
set = new Set(['1', '2', '3', '2', '1']);
iter = $for(set).filter((function(it){
return it % 2;
}));
ok(iter instanceof $for);
deepEqual(['1', '3'], from(iter));
deepEqual([[1, 2]], from($for([1, 2, 3].entries(), true).filter(function(k, v){
return k % 2;
})));
$for([1]).filter(function(){
return ok(this === o);
}, o = {});
});
test('$for#map', function(){
var set, iter, o;
ok(typeof $for.prototype.map === 'function', 'Is function');
set = new Set(['1', '2', '3', '2', '1']);
iter = $for(set).map((function(it){
return it * 2;
}));
ok(iter instanceof $for);
deepEqual([2, 4, 6], from(iter));
deepEqual([[0, 1], [2, 4], [4, 9]], from($for([1, 2, 3].entries(), true).map(function(k, v){
return [k * 2, v * v];
})));
$for([1]).map(function(){
return ok(this === o);
}, o = {});
});
test('$for#array', function(){
var set, o;
ok(typeof $for.prototype.array === 'function', 'Is function');
set = new Set([1, 2, 3, 2, 1]);
deepEqual([[1, 1], [2, 2], [3, 3]], $for(set.entries()).array());
deepEqual([2, 4, 6], $for(set).array((function(it){
return it * 2;
})));
deepEqual([[0, 1], [2, 4], [4, 9]], $for([1, 2, 3].entries(), true).array(function(k, v){
return [k * 2, v * v];
}));
$for([1]).array(function(){
return ok(this === o);
}, o = {});
});
test('$for#of', function(){
var set, counter1, string1, counter2, string2, o;
ok(typeof $for.prototype.of === 'function', 'Is function');
set = new Set(['1', '2', '3', '2', '1']);
counter1 = 0;
string1 = '';
$for(set).of(function(it){
counter1++;
string1 += it;
});
ok(counter1 === 3);
ok(string1 === '123');
counter2 = 0;
string2 = '';
$for(set.entries()).of(function(it){
counter2++;
string2 += it[0] + it[1];
});
ok(counter2 === 3);
ok(string2 === '112233');
$for([1].entries(), true).of(function(key, val){
ok(this === o);
ok(key === 0);
return ok(val === 1);
}, o = {});
});
test('$for chaining', function(){
deepEqual([2, 10], $for([1, 2, 3]).map((function(it){
return Math.pow(it, 2);
})).filter((function(it){
return it % 2;
})).map((function(it){
return it + 1;
})).array());
deepEqual([[1, 1], [3, 9]], $for([1, 2, 3].entries(), true).map(function(k, v){
return [k, Math.pow(v, 2)];
}).filter(function(k, v){
return v % 2;
}).map(function(k, v){
return [k + 1, v];
}).array());
});
test('$for.isIterable', function(){
var isIterable;
isIterable = $for.isIterable;
ok(typeof isIterable === 'function', 'Is function');
ok(!isIterable({}));
ok(isIterable([]));
ok(isIterable(function(){
return arguments;
}()));
});
test('$for.getIterator', function(){
var getIterator, e, iter;
getIterator = $for.getIterator;
ok(typeof getIterator === 'function', 'Is function');
try {
getIterator({});
ok(false);
} catch (e$) {
e = e$;
ok(true);
}
iter = getIterator([]);
ok('next' in iter);
iter = getIterator(function(){
return arguments;
}());
ok('next' in iter);
});
}).call(this);
(function(){
var isFunction, toString$ = {}.toString;
QUnit.module('Array');
isFunction = function(it){
return toString$.call(it).slice(8, -1) === 'Function';
};
test('#turn', function(){
var arr, obj;
ok(isFunction(Array.prototype.turn), 'Is function');
(arr = [1]).turn(function(memo, val, key, that){
deepEqual([], memo, 'Default memo is array');
ok(val === 1, 'First argumert is value');
ok(key === 0, 'Second argumert is index');
return ok(that === arr, 'Third argumert is array');
});
[1].turn(function(memo){
return ok(memo === obj, 'Can reduce to exist object');
}, obj = {});
deepEqual([3, 2, 1], [1, 2, 3].turn(function(memo, it){
return memo.unshift(it);
}), 'Reduce to object and return it');
});
}).call(this);
(function(){
var isFunction, slice, toString$ = {}.toString;
QUnit.module('Array statics');
isFunction = function(it){
return toString$.call(it).slice(8, -1) === 'Function';
};
slice = Array.prototype.slice;
test('are functions', function(){
var i$, x$, ref$, len$;
for (i$ = 0, len$ = (ref$ = ['concat', 'join', 'pop', 'push', 'reverse', 'shift', 'slice', 'sort', 'splice', 'unshift', 'indexOf', 'lastIndexOf', 'every', 'some', 'forEach', 'map', 'filter', 'reduce', 'reduceRight', 'copyWithin', 'fill', 'find', 'findIndex', 'keys', 'values', 'entries', 'turn', 'includes']).length; i$ < len$; ++i$) {
x$ = ref$[i$];
ok(isFunction(Array[x$]), "Array." + x$ + " is function");
}
});
test('.join', function(){
var join;
join = Array.join;
ok(join('123') === '1,2,3');
ok(join('123', '|') === '1|2|3');
ok(join(function(){
return arguments;
}(3, 2, 1), '|') === '3|2|1');
});
test('.pop', function(){
var pop, args;
pop = Array.pop;
ok(pop(args = function(){
return arguments;
}(1, 2, 3)) === 3);
deepEqual(args, function(){
return arguments;
}(1, 2));
});
test('.push', function(){
var push, args;
push = Array.push;
push(args = function(){
return arguments;
}(1, 2, 3), 4, 5);
deepEqual(slice.call(args), [1, 2, 3, 4, 5]);
});
test('.reverse', function(){
var reverse;
reverse = Array.reverse;
deepEqual(reverse(function(){
return arguments;
}(1, 2, 3)), function(){
return arguments;
}(3, 2, 1));
});
test('.shift', function(){
var shift, args;
shift = Array.shift;
ok(shift(args = function(){
return arguments;
}(1, 2, 3)) === 1);
deepEqual(args, function(){
return arguments;
}(2, 3));
});
test('.unshift', function(){
var unshift, args;
unshift = Array.unshift;
unshift(args = function(){
return arguments;
}(1, 2, 3), 4, 5);
deepEqual(slice.call(args), [4, 5, 1, 2, 3]);
});
test('.slice', function(){
var slice;
slice = Array.slice;
deepEqual(slice('123'), ['1', '2', '3']);
deepEqual(slice('123', 1), ['2', '3']);
deepEqual(slice('123', 1, 2), ['2']);
deepEqual(slice('123', 1, -1), ['2']);
deepEqual(slice(function(){
return arguments;
}(1, 2, 3)), [1, 2, 3]);
deepEqual(slice(function(){
return arguments;
}(1, 2, 3), 1), [2, 3]);
deepEqual(slice(function(){
return arguments;
}(1, 2, 3), 1, 2), [2]);
deepEqual(slice(function(){
return arguments;
}(1, 2, 3), 1, -1), [2]);
});
test('.splice', function(){
var splice, args;
splice = Array.splice;
splice(args = function(){
return arguments;
}(1, 2, 3), 1, 0, 4, 5);
deepEqual(slice.call(args), [1, 4, 5, 2, 3]);
splice(args = function(){
return arguments;
}(1, 2, 3), 1, 1, 4);
deepEqual(slice.call(args), [1, 4, 3]);
splice(args = function(){
return arguments;
}(1, 2, 3), 1, 1);
deepEqual(slice.call(args), [1, 3]);
});
test('.sort', function(){
var sort;
sort = Array.sort;
deepEqual(sort(function(){
return arguments;
}(2, 1, 3)), function(){
return arguments;
}(1, 2, 3));
deepEqual(sort(function(){
return arguments;
}(11, 2, 3)), function(){
return arguments;
}(11, 2, 3));
deepEqual(sort(function(){
return arguments;
}(11, 2, 3), function(a, b){
return a - b;
}), function(){
return arguments;
}(2, 3, 11));
});
test('.indexOf', function(){
var indexOf;
indexOf = Array.indexOf;
ok(indexOf('111', '1') === 0);
ok(indexOf('123', '1', 1) === -1);
ok(indexOf('123', '2', 1) === 1);
ok(indexOf(function(){
return arguments;
}(1, 1, 1), 1) === 0);
ok(indexOf(function(){
return arguments;
}(1, 2, 3), 1, 1) === -1);
ok(indexOf(function(){
return arguments;
}(1, 2, 3), 2, 1) === 1);
});
test('.lastIndexOf', function(){
var lastIndexOf;
lastIndexOf = Array.lastIndexOf;
ok(lastIndexOf('111', '1') === 2);
ok(lastIndexOf('123', '3', 1) === -1);
ok(lastIndexOf('123', '2', 1) === 1);
ok(lastIndexOf(function(){
return arguments;
}(1, 1, 1), 1) === 2);
ok(lastIndexOf(function(){
return arguments;
}(1, 2, 3), 3, 1) === -1);
ok(lastIndexOf(function(){
return arguments;
}(1, 2, 3), 2, 1) === 1);
});
test('.every', function(){
var every, al, ctx;
every = Array.every;
every(al = function(){
return arguments;
}(1), function(val, key, that){
ok(this === ctx);
ok(val === 1);
ok(key === 0);
return ok(that === al);
}, ctx = {});
ok(every('123', function(it){
return toString$.call(it).slice(8, -1) === 'String';
}));
ok(every('123', function(){
return arguments[1] < 3;
}));
ok(!every('123', function(it){
return toString$.call(it).slice(8, -1) === 'Number';
}));
ok(!every('123', function(){
return arguments[1] < 2;
}));
ok(every('123', function(){
return arguments[2] == '123';
}));
ok(every(function(){
return arguments;
}(1, 2, 3), function(it){
return toString$.call(it).slice(8, -1) === 'Number';
}));
});
test('.some', function(){
var some, al, ctx;
some = Array.some;
some(al = function(){
return arguments;
}(1), function(val, key, that){
ok(this === ctx);
ok(val === 1);
ok(key === 0);
return ok(that === al);
}, ctx = {});
ok(some('123', function(it){
return toString$.call(it).slice(8, -1) === 'String';
}));
ok(some('123', function(){
return arguments[1] > 1;
}));
ok(!some('123', function(it){
return toString$.call(it).slice(8, -1) === 'Number';
}));
ok(!some('123', function(){
return arguments[1] > 3;
}));
ok(some('123', function(){
return arguments[2] == '123';
}));
ok(some(function(){
return arguments;
}(1, 2, 3), function(it){
return toString$.call(it).slice(8, -1) === 'Number';
}));
});
test('.forEach', function(){
var forEach, al, ctx, val;
forEach = Array.forEach;
forEach(al = function(){
return arguments;
}(1), function(val, key, that){
ok(this === ctx);
ok(val === 1);
ok(key === 0);
ok(that === al);
}, ctx = {});
val = '';
forEach('123', function(v, k, t){
val += v + k + t;
});
ok(val === '101232112332123');
val = '';
forEach(function(){
return arguments;
}(1, 2, 3), function(v, k, t){
val += v + k + t['2'];
});
ok(val === '468');
val = '';
forEach('123', function(v, k, t){
val += v + k + t + this;
}, 1);
ok(val === '101231211231321231');
});
test('.map', function(){
var map, al, ctx;
map = Array.map;
map(al = function(){
return arguments;
}(1), function(val, key, that){
ok(this === ctx);
ok(val === 1);
ok(key === 0);
return ok(that === al);
}, ctx = {});
deepEqual(map('123', (function(it){
return Math.pow(it, 2);
})), [1, 4, 9]);
deepEqual(map(function(){
return arguments;
}(1, 2, 3), (function(it){
return Math.pow(it, 2);
})), [1, 4, 9]);
});
test('.filter', function(){
var filter, al, ctx;
filter = Array.filter;
filter(al = function(){
return arguments;
}(1), function(val, key, that){
ok(this === ctx);
ok(val === 1);
ok(key === 0);
return ok(that === al);
}, ctx = {});
deepEqual(filter('123', function(it){
return it > 1;
}), ['2', '3']);
deepEqual(filter(function(){
return arguments;
}(1, 2, 3), function(it){
return it < 3;
}), [1, 2]);
deepEqual(filter('123', function(){
return arguments[1] !== 1;
}), ['1', '3']);
});
test('.reduce', function(){
var reduce, al, ctx;
reduce = Array.reduce;
reduce(al = function(){
return arguments;
}(1), function(memo, val, key, that){
ok(memo === ctx);
ok(val === 1);
ok(key === 0);
return ok(that === al);
}, ctx = {});
reduce(al = function(){
return arguments;
}(1, 2), function(memo){
return ok(memo === 1);
});
ok(reduce('123', function(a, b){
a = +a;
b = +b;
return a + b;
}) === 6);
ok(reduce(function(){
return arguments;
}(1, 2, 3), function(a, b){
return '' + b * b + a;
}) === '941');
ok(reduce('123', function(a, b){
a = +a;
b = +b;
return a + b;
}, 1) === 7);
});
test('.reduceRight', function(){
var reduceRight, al, ctx;
reduceRight = Array.reduceRight;
reduceRight(al = function(){
return arguments;
}(1), function(memo, val, key, that){
ok(memo === ctx);
ok(val === 1);
ok(key === 0);
return ok(that === al);
}, ctx = {});
reduceRight(al = function(){
return arguments;
}(1, 2), function(memo){
return ok(memo === 2);
});
ok(reduceRight('123', function(a, b){
a = +a;
b = +b;
return a + b;
}) === 6);
ok(reduceRight(function(){
return arguments;
}(1, 2, 3), function(a, b){
return '' + b * b + a;
}) === '143');
ok(reduceRight('123', function(a, b){
a = +a;
b = +b;
return a + b;
}, 1) === 7);
});
test('.copyWithin', function(){
var copyWithin, a;
copyWithin = Array.copyWithin;
ok(copyWithin(a = function(){
return arguments;
}(1, 2, 3), 0) === a);
deepEqual(copyWithin(function(){
return arguments;
}(1, 2, 3), -2), function(){
return arguments;
}(1, 1, 2));
deepEqual(copyWithin(function(){
return arguments;
}(1, 2, 3), 0, 1), function(){
return arguments;
}(2, 3, 3));
deepEqual(copyWithin(function(){
return arguments;
}(1, 2, 3), 0, 1, 2), function(){
return arguments;
}(2, 2, 3));
});
test('.fill', function(){
var fill, a;
fill = Array.fill;
ok(fill(a = function(){
return arguments;
}(1, 2, 3), 0) === a);
deepEqual(fill(Array(3), 5), [5, 5, 5]);
});
test('.find', function(){
var find, al, ctx;
find = Array.find;
find(al = function(){
return arguments;
}(1), function(val, key, that){
ok(this === ctx);
ok(val === 1);
ok(key === 0);
return ok(that === al);
}, ctx = {});
ok(find(function(){
return arguments;
}(1, 3, NaN, 42, {}), (function(it){
return it === 42;
})) === 42);
ok(find('123', (function(it){
return it === '2';
})) === '2');
ok(find('123', (function(it){
return it === '4';
})) === void 8);
});
test('.findIndex', function(){
var findIndex, al, ctx;
findIndex = Array.findIndex;
findIndex(al = function(){
return arguments;
}(1), function(val, key, that){
ok(this === ctx);
ok(val === 1);
ok(key === 0);
return ok(that === al);
}, ctx = {});
ok(findIndex(function(){
return arguments;
}(1, 3, NaN, 42, {}), (function(it){
return it === 42;
})) === 3);
ok(findIndex('123', (function(it){
return it === '2';
})) === 1);
ok(findIndex('123', (function(it){
return it === '4';
})) === -1);
});
test('.keys', function(){
var keys, iter1, iter2;
keys = Array.keys;
ok(typeof keys === 'function', 'Is function');
iter1 = keys(function(){
return arguments;
}('q', 'w', 'e'));
ok(typeof iter1 === 'object', 'Iterator is object');
ok(typeof iter1.next === 'function', 'Iterator has .next method');
deepEqual(iter1.next(), {
value: 0,
done: false
});
deepEqual(iter1.next(), {
value: 1,
done: false
});
deepEqual(iter1.next(), {
value: 2,
done: false
});
deepEqual(iter1.next(), {
value: void 8,
done: true
});
iter2 = keys('qwe');
deepEqual(iter2.next(), {
value: 0,
done: false
});
deepEqual(iter2.next(), {
value: 1,
done: false
});
deepEqual(iter2.next(), {
value: 2,
done: false
});
deepEqual(iter2.next(), {
value: void 8,
done: true
});
});
test('.values', function(){
var values, iter1, iter2;
values = Array.values;
ok(typeof values === 'function', 'Is function');
iter1 = values(function(){
return arguments;
}('q', 'w', 'e'));
ok(typeof iter1 === 'object', 'Iterator is object');
ok(typeof iter1.next === 'function', 'Iterator has .next method');
deepEqual(iter1.next(), {
value: 'q',
done: false
});
deepEqual(iter1.next(), {
value: 'w',
done: false
});
deepEqual(iter1.next(), {
value: 'e',
done: false
});
deepEqual(iter1.next(), {
value: void 8,
done: true
});
iter2 = values('qwe');
deepEqual(iter2.next(), {
value: 'q',
done: false
});
deepEqual(iter2.next(), {
value: 'w',
done: false
});
deepEqual(iter2.next(), {
value: 'e',
done: false
});
deepEqual(iter2.next(), {
value: void 8,
done: true
});
});
test('.entries', function(){
var entries, iter1, iter2;
entries = Array.entries;
ok(typeof entries === 'function', 'Is function');
iter1 = entries(function(){
return arguments;
}('q', 'w', 'e'));
ok(typeof iter1 === 'object', 'Iterator is object');
ok(typeof iter1.next === 'function', 'Iterator has .next method');
deepEqual(iter1.next(), {
value: [0, 'q'],
done: false
});
deepEqual(iter1.next(), {
value: [1, 'w'],
done: false
});
deepEqual(iter1.next(), {
value: [2, 'e'],
done: false
});
deepEqual(iter1.next(), {
value: void 8,
done: true
});
iter2 = entries('qwe');
deepEqual(iter2.next(), {
value: [0, 'q'],
done: false
});
deepEqual(iter2.next(), {
value: [1, 'w'],
done: false
});
deepEqual(iter2.next(), {
value: [2, 'e'],
done: false
});
deepEqual(iter2.next(), {
value: void 8,
done: true
});
});
test('.turn', function(){
var turn, al, obj;
turn = Array.turn;
turn(al = function(){
return arguments;
}(1), function(memo, val, key, that){
deepEqual([], memo);
ok(val === 1);
ok(key === 0);
return ok(that === al);
});
turn(al = '1', function(memo, val, key, that){
deepEqual([], memo);
ok(val === '1');
ok(key === 0);
return ok(that == al);
});
turn(function(){
return arguments;
}(1), function(it){
return ok(it === obj);
}, obj = {});
deepEqual([3, 2, 1], turn(function(){
return arguments;
}(1, 2, 3), function(memo, it){
return memo.unshift(it);
}));
deepEqual(['3', '2', '1'], turn('123', function(memo, it){
return memo.unshift(it);
}));
});
test('.includes', function(){
var includes, args, o, str;
includes = Array.includes;
ok(isFunction(includes), 'Is function');
args = function(){
return arguments;
}(1, 2, 3, -0, NaN, o = {});
ok(includes(args, 1));
ok(includes(args, -0));
ok(includes(args, 0));
ok(includes(args, NaN));
ok(includes(args, o));
ok(!includes(args, 4));
ok(!includes(args, -0.5));
ok(!includes(args, {}));
str = 'qwe';
ok(includes(str, 'q'));
ok(!includes(str, 'r'));
});
}).call(this);
(function(){
var isFunction, DESC, slice, toString$ = {}.toString, slice$ = [].slice;
QUnit.module('Binding');
isFunction = function(it){
return toString$.call(it).slice(8, -1) === 'Function';
};
DESC = /\[native code\]\s*\}\s*$/.test(Object.defineProperty);
slice = Array.prototype.slice;
test('Function#by', function(){
var $, array, push, foo, bar, o, fn;
$ = _;
ok(isFunction(Function.prototype.by), 'Is function');
array = [1, 2, 3];
push = array.push.by(array);
ok(isFunction(push));
ok(push(4) === 4);
deepEqual(array, [1, 2, 3, 4]);
foo = {
bar: function(a, b, c, d){
ok(this === foo);
return deepEqual(slice.call(arguments), [1, 2, 3, 4]);
}
};
bar = foo.bar.by(foo, 1, $, 3);
bar(2, 4);
o = {
a: '1'
};
fn = function(b, c){
return this.a + b + c;
};
ok(fn.by(o, '2')('3') === '123');
ok(fn.by($)(o, '2', '3') === '123');
ok(fn.by($, '2')(o, '3') === '123');
});
test('Function#part', function(){
var obj, $, fn, part;
ok(isFunction(Function.prototype.part), 'Is function');
ok(function(it){
return toString$.call(it).slice(8, -1) === 'String';
}.part('qwe')());
obj = {
a: 42
};
obj.fn = function(it){
return this.a + it;
}.part(21);
ok(obj.fn() === 63);
$ = _;
fn = function(){
return Array.prototype.map.call(arguments, String).join(' ');
};
part = fn.part($, 'Саша', $, 'шоссе', $, 'сосала');
ok(isFunction(part), '.part with placeholders return function');
ok(part('Шла', 'по') === 'Шла Саша по шоссе undefined сосала', '.part with placeholders: args < placeholders');
ok(part('Шла', 'по', 'и') === 'Шла Саша по шоссе и сосала', '.part with placeholders: args == placeholders');
ok(part('Шла', 'по', 'и', 'сушку') === 'Шла Саша по шоссе и сосала сушку', '.part with placeholders: args > placeholders');
});
test('Function#only', function(){
var fn, f, that, o, c;
ok(isFunction(Function.prototype.only), 'Is function');
fn = function(){
var args;
args = slice$.call(arguments);
return args.reduce(curry$(function(x$, y$){
return x$ + y$;
}));
};
f = fn.only(2);
ok(f(1, 2, 3) === 3);
ok(f(1) === 1);
that = function(){
return this;
};
o = {
f: that.only(1)
};
ok(o.f() === o);
o = {
f: that.only(1, c = {})
};
ok(o.f() === c);
});
test('#[_]', function(){
var $, fn, ctx, array, push, foo, bar;
$ = _;
ok(isFunction(Object.prototype[_]), 'Object::[_] is function');
fn = function(it){
ok(this === ctx);
return ok(it === 1);
}[_]('call');
fn(ctx = {}, 1);
array = [1, 2, 3];
push = array[_]('push');
ok(isFunction(push));
push(4, 5);
deepEqual(array, [1, 2, 3, 4, 5]);
ok([1, 2].every(/\d/[_]('test')));
ok(![1, 'q'].every(/\d/[_]('test')));
foo = {
bar: function(a, b){
ok(this === foo);
return deepEqual(slice.call(arguments), [1, 2]);
}
};
bar = foo[_]('bar');
bar(1, 2);
});
function curry$(f, bound){
var context,
_curry = function(args) {
return f.length > 1 ? function(){
var params = args ? args.concat() : [];
context = bound ? context || this : this;
return params.push.apply(params, arguments) <
f.length && arguments.length ?
_curry.call(context, params) : f.apply(context, params);
} : f;
};
return _curry();
}
}).call(this);
(function(){
var isFunction, isObject, methods, toString$ = {}.toString;
QUnit.module('Console');
isFunction = function(it){
return toString$.call(it).slice(8, -1) === 'Function';
};
isObject = function(it){
return it === Object(it);
};
methods = ['assert', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupEnd', 'groupCollapsed', 'groupEnd', 'info', 'log', 'table', 'trace', 'warn', 'markTimeline', 'profile', 'profileEnd', 'time', 'timeEnd', 'timeStamp'];
test('is object', function(){
ok(isObject(((typeof global != 'undefined' && global !== null) && global || window).console), 'global.console is object');
});
test('console.{..} are functions', function(){
var i$, x$, ref$, len$;
for (i$ = 0, len$ = (ref$ = methods).length; i$ < len$; ++i$) {
x$ = ref$[i$];
ok(isFunction(console[x$]), "console." + x$ + " is function");
}
});
test('call console.{..}', function(){
var i$, x$, ref$, len$;
for (i$ = 0, len$ = (ref$ = methods).length; i$ < len$; ++i$) {
x$ = ref$[i$];
ok((fn$()), "call console." + x$);
}
function fn$(){
try {
console[x$]('foo');
return true;
} catch (e$) {}
}
});
test('call unbound console.#{..}', function(){
var i$, x$, ref$, len$;
for (i$ = 0, len$ = (ref$ = methods).length; i$ < len$; ++i$) {
x$ = ref$[i$];
ok((fn$()), "call unbound console." + x$);
}
function fn$(){
try {
console[x$].call(void 8, 'foo');
return true;
} catch (e$) {}
}
});
test('console as console.log shortcut', function(){
ok(isFunction(console), 'console is function');
ok(console === console.log, 'console is console.log shortcut');
ok((function(){
try {
console('console');
return true;
} catch (e$) {}
}()), 'call console');
});
test('console.{enable, disable}', function(){
var enable, disable;
enable = console.enable, disable = console.disable;
ok(isFunction(enable), 'console.enable is function');
ok(isFunction(disable), 'console.disable is function');
ok((function(){
try {
disable();
return true;
} catch (e$) {}
}()), 'disable console');
ok((function(){
try {
return console('call disabled console') === void 8;
} catch (e$) {}
}()), 'call disabled console');
ok((function(){
try {
enable();
return true;
} catch (e$) {}
}()), 'enable console');
});
}).call(this);
(function(){
var isFunction, toString$ = {}.toString;
QUnit.module('Date');
isFunction = function(it){
return toString$.call(it).slice(8, -1) === 'Function';
};
test('.locale', function(){
var locale;
locale = core.locale;
ok(isFunction(locale), 'Is function');
locale('en');
ok(locale() === 'en', '.locale() is "en"');
ok(locale('ru') === 'ru', '.locale("ru") is "ru"');
ok(locale() === 'ru', '.locale() is "ru"');
ok(locale('xx') === 'ru', '.locale("xx") is "ru"');
});
test('.addLocale', function(){
var locale, addLocale;
locale = core.locale, addLocale = core.addLocale;
ok(isFunction(locale), 'Is function');
ok(locale('en') === 'en');
ok(locale('zz') === 'en');
addLocale('zz', {
weekdays: 'Воскресенье,Понедельник,Вторник,Среда,Четверг,Пятница,Суббота',
months: 'Январ:я|ь,Феврал:я|ь,Март:а|,Апрел:я|ь,Ма:я|й,Июн:я|ь,Июл:я|ь,Август:а|,Сентябр:я|ь,Октябр:я|ь,Ноябр:я|ь,Декабр:я|ь'
});
ok(locale('zz') === 'zz');
ok(new Date(1, 2, 3, 4, 5, 6, 7).format('W, D MM Y') === 'Воскресенье, 3 Марта 1901');
});
test('#format', function(){
var locale, date;
locale = core.locale;
ok(isFunction(Date.prototype.format), 'Is function');
date = new Date(1, 2, 3, 4, 5, 6, 7);
ok(date.format('DD.NN.Y') === '03.03.1901', 'Works basic');
locale('en');
ok(date.format('s ss m mm h hh D DD W N NN M MM YY foo Y') === '6 06 5 05 4 04 3 03 Sunday 3 03 March March 01 foo 1901', 'Works with defaut locale');
locale('ru');
ok(date.format('s ss m mm h hh D DD W N NN M MM YY foo Y') === '6 06 5 05 4 04 3 03 Воскресенье 3 03 Март Марта 01 foo 1901', 'Works with set in Date.locale locale');
});
test('#formatUTC', function(){
var date;
ok(isFunction(Date.prototype.formatUTC), 'Is function');
date = new Date(1, 2, 3, 4, 5, 6, 7);
ok(date.formatUTC('h') === '' + date.getUTCHours(), 'Works');
});
}).call(this);
(function(){
var isFunction, keys, create, assign, from, toStringTag, toString$ = {}.toString;
QUnit.module('Dict');
isFunction = function(it){
return toString$.call(it).slice(8, -1) === 'Function';
};
keys = Object.keys, create = Object.create, assign = Object.assign;
from = Array.from;
toStringTag = Symbol.toStringTag;
test('Dict', function(){
var dict1, dict2, dict3;
ok(isFunction(global.Dict), 'Is function');
dict1 = Dict();
ok(!(dict1 instanceof Object));
deepEqual(keys(dict1), []);
dict2 = Dict({
q: 1,
w: 2
});
ok(!(dict2 instanceof Object));
deepEqual(keys(dict2), ['q', 'w']);
ok(dict2.q === 1);
ok(dict2.w === 2);
dict3 = Dict(new Set([1, 2]).entries());
ok(!(dict3 instanceof Object));
deepEqual(keys(dict3), ['1', '2']);
ok(dict3[1] === 1);
ok(dict3[2] === 2);
});
test('.every', function(){
var every, obj, ctx;
every = Dict.every;
ok(isFunction(every), 'Is function');
every(obj = {
q: 1
}, function(val, key, that){
ok(val === 1);
ok(key === 'q');
ok(that === obj);
return ok(this === ctx);
}, ctx = {});
ok(every({
q: 1,
w: 2,
e: 3
}, function(it){
return toString$.call(it).slice(8, -1) === 'Number';
}));
ok(!every({
q: 1,
w: '2',
e: 3
}, function(it){
return toString$.call(it).slice(8, -1) === 'Number';
}));
});
test('.filter', function(){
var filter, obj, ctx;
filter = Dict.filter;
ok(isFunction(filter), 'Is function');
filter(obj = {
q: 1
}, function(val, key, that){
ok(val === 1);
ok(key === 'q');
ok(that === obj);
return ok(this === ctx);
}, ctx = {});
deepEqual(filter({
q: 1,
w: 2,
e: 3
}, function(it){
return it % 2;
}), Dict({
q: 1,
e: 3
}));
});
test('.find', function(){
var find, obj, ctx;
find = Dict.find;
ok(isFunction(find), 'Is function');
find(obj = {
q: 1
}, function(val, key, that){
ok(val === 1);
ok(key === 'q');
ok(that === obj);
return ok(this === ctx);
}, ctx = {});
ok(find({
q: 1,
w: 2,
e: 3
}, function(it){
return !(it % 2);
}) === 2);
});
test('.findKey', function(){
var findKey, obj, ctx;
findKey = Dict.findKey;
ok(isFunction(findKey), 'Is function');
findKey(obj = {
q: 1
}, function(val, key, that){
ok(val === 1);
ok(key === 'q');
ok(that === obj);
return ok(this === ctx);
}, ctx = {});
ok(findKey({
q: 1,
w: 2,
e: 3
}, function(it){
return it === 2;
}) === 'w');
});
test('.forEach', function(){
var forEach, obj, ctx, rez;
forEach = Dict.forEach;
ok(isFunction(forEach), 'Is function');
forEach(obj = {
q: 1
}, function(val, key, that){
ok(val === 1);
ok(key === 'q');
ok(that === obj);
ok(this === ctx);
}, ctx = {});
rez = {};
forEach({
q: 1,
w: 2
}, function(){
rez[arguments[1]] = arguments[0] + this;
}, '_');
deepEqual(rez, {
q: '1_',
w: '2_'
});
rez = true;
forEach(obj = {
q: 1,
w: 2
}, function(){
var rez;
rez && (rez = obj === arguments[2]);
});
ok(rez);
rez = {};
forEach(Object.make({
e: 3
}, {
q: 1,
w: 2
}), function(){
rez[arguments[1]] = arguments[0];
});
ok(!('e' in rez));
rez = {};
forEach([1, 2], function(){
rez[arguments[1]] = arguments[0];
});
ok(!('length' in rez));
rez = {};
forEach('123', function(){
rez[arguments[1]] = arguments[0];
});
ok('2' in rez);
});
test('.keyOf', function(){
var keyOf;
keyOf = Dict.keyOf;
ok(isFunction(keyOf), 'Is function');
ok(keyOf({
q: 1,
w: 2,
e: 3
}, 2) === 'w');
ok(keyOf({
q: 1,
w: 2,
e: 3
}, 4) === void 8);
ok(keyOf({
q: 1,
w: 2,
e: NaN
}, NaN) === void 8);
});
test('.map', function(){
var map, obj, ctx;
map = Dict.map;
ok(isFunction(map), 'Is function');
map(obj = {
q: 1
}, function(val, key, that){
ok(val === 1);
ok(key === 'q');
ok(that === obj);
return ok(this === ctx);
}, ctx = {});
deepEqual(map({
q: 1,
w: 2,
e: 3
}, (function(it){
return Math.pow(it, 2);
})), Dict({
q: 1,
w: 4,
e: 9
}));
});
test('.mapPairs', function(){
var mapPairs, obj, ctx;
mapPairs = Dict.mapPairs;
ok(isFunction(mapPairs), 'Is function');
mapPairs(obj = {
q: 1
}, function(val, key, that){
ok(val === 1);
ok(key === 'q');
ok(that === obj);
return ok(this === ctx);
}, ctx = {});
deepEqual(mapPairs({
q: 1,
w: 2,
e: 3
}, function(v, k){
return v !== 2 && [k + k, v * v];
}), Dict({
qq: 1,
ee: 9
}));
});
test('.reduce', function(){
var reduce, obj, foo, memo;
reduce = Dict.reduce;
ok(isFunction(reduce), 'Is function');
reduce(obj = {
a: 1
}, function(memo, val, key, that){
ok(memo === foo);
ok(val === 1);
ok(key === 'a');
return ok(that === obj);
}, foo = {});
reduce({
a: 1,
b: 2
}, function(memo, val, key){
ok(memo === 1);
ok(val === 2);
return ok(key === 'b');
});
reduce({
q: 1,
w: 2,
e: 3
}, function(that, it){
that[it] = it;
return that;
}, memo = {});
deepEqual(memo, {
1: 1,
2: 2,
3: 3
});
});
test('.some', function(){
var some, obj, ctx;
some = Dict.some;
ok(isFunction(some), 'Is function');
some(obj = {
q: 1
}, function(val, key, that){
ok(val === 1);
ok(key === 'q');
ok(that === obj);
return ok(this === ctx);
}, ctx = {});
ok(!some({
q: 1,
w: 2,
e: 3
}, function(it){
return toString$.call(it).slice(8, -1) === 'String';
}));
ok(some({
q: 1,
w: '2',
e: 3
}, function(it){
return toString$.call(it).slice(8, -1) === 'String';
}));
});
test('.turn', function(){
var turn, obj;
turn = Dict.turn;
ok(isFunction(turn), 'Is function');
turn(obj = {
q: 1
}, function(memo, val, key, that){
deepEqual(memo, Dict());
ok(val === 1);
ok(key === 'q');
return ok(that === obj);
});
turn({
q: 1
}, function(it){
return ok(it === obj);
}, obj = {});
deepEqual(turn({
q: 1,
w: 2,
e: 3
}, function(memo, it){
return memo[it] = it;
}), Dict({
1: 1,
2: 2,
3: 3
}));
});
test('.includes', function(){
var includes, dict, o;
includes = Dict.includes;
ok(isFunction(includes), 'Is function');
dict = {
q: 1,
w: NaN,
e: -0,
r: o = {}
};
ok(includes(dict, 1));
ok(includes(dict, -0));
ok(includes(dict, 0));
ok(includes(dict, NaN));
ok(includes(dict, o));
ok(!includes(dict, 4));
ok(!includes(dict, -0.5));
ok(!includes(dict, {}));
});
test('.has', function(){
var has;
has = Dict.has;
ok(isFunction(has), 'Is function');
ok(has({
q: 1
}, 'q'));
ok(!has({
q: 1
}, 'w'));
ok(has([1], 0));
ok(!has([], 0));
ok(!has(clone$({
q: 1
}), 'q'));
ok(!has({}, 'toString'));
});
test('.get', function(){
var get;
get = Dict.get;
ok(isFunction(get), 'Is function');
ok(get({
q: 1
}, 'q') === 1);
ok(get({
q: 1
}, 'w') === void 8);
ok(get([1], 0) === 1);
ok(get([], 0) === void 8);
ok(get(clone$({
q: 1
}), 'q') === void 8);
ok(get({}, 'toString') === void 8);
});
test('.values', function(){
var values, iter;
values = Dict.values;
ok(isFunction(values), 'Is function');
iter = values({});
ok(iter[toStringTag] === 'Dict Iterator');
ok('next' in iter);
deepEqual(from(values({
q: 1,
w: 2,
e: 3
})), [1, 2, 3]);
deepEqual(from(values(new String('qwe'))), ['q', 'w', 'e']);
deepEqual(from(values(assign(create({
q: 1,
w: 2,
e: 3
}), {
a: 4,
s: 5,
d: 6
}))), [4, 5, 6]);
});
test('.keys', function(){
var keys, iter;
keys = Dict.keys;
ok(isFunction(keys), 'Is function');
iter = keys({});
ok(iter[toStringTag] === 'Dict Iterator');
ok('next' in iter);
deepEqual(from(keys({
q: 1,
w: 2,
e: 3
})), ['q', 'w', 'e']);
deepEqual(from(keys(new String('qwe'))), ['0', '1', '2']);
deepEqual(from(keys(assign(create({
q: 1,
w: 2,
e: 3
}), {
a: 4,
s: 5,
d: 6
}))), ['a', 's', 'd']);
});
test('.entries', function(){
var entries, iter;
entries = Dict.entries;
ok(isFunction(entries), 'Is function');
iter = entries({});
ok(iter[toStringTag] === 'Dict Iterator');
ok('next' in iter);
deepEqual(from(entries({
q: 1,
w: 2,
e: 3
})), [['q', 1], ['w', 2], ['e', 3]]);
deepEqual(from(entries(new String('qwe'))), [['0', 'q'], ['1', 'w'], ['2', 'e']]);
deepEqual(from(entries(assign(create({
q: 1,
w: 2,
e: 3
}), {
a: 4,
s: 5,
d: 6
}))), [['a', 4], ['s', 5], ['d', 6]]);
});
function clone$(it){
function fun(){} fun.prototype = it;
return new fun;
}
}).call(this);
(function(){
var isFunction, toString$ = {}.toString;
QUnit.module('ES5');
isFunction = function(it){
return toString$.call(it).slice(8, -1) === 'Function';
};
test('Object.getOwnPropertyDescriptor', function(){
var getOwnPropertyDescriptor;
getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
ok(isFunction(getOwnPropertyDescriptor), 'Is function');
deepEqual(getOwnPropertyDescriptor({
q: 42
}, 'q'), {
writable: true,
enumerable: true,
configurable: true,
value: 42
});
ok(getOwnPropertyDescriptor({}, 'toString') === void 8);
});
test('Object.defineProperty', function(){
var defineProperty, rez, src;
defineProperty = Object.defineProperty;
ok(isFunction(defineProperty), 'Is function');
ok((rez = defineProperty(src = {}, 'q', {
value: 42
})) === src);
ok(rez.q === 42);
});
test('Object.defineProperties', function(){
var defineProperties, rez, src;
defineProperties = Object.defineProperties;
ok(isFunction(defineProperties), 'Is function');
ok((rez = defineProperties(src = {}, {
q: {
value: 42
},
w: {
value: 33
}
})) === src);
ok(rez.q === 42) && rez.w === 33;
});
test('Object.getPrototypeOf', function(){
var create, getPrototypeOf, fn, obj;
create = Object.create, getPrototypeOf = Object.getPrototypeOf;
ok(isFunction(getPrototypeOf), 'Is function');
ok(getPrototypeOf({}) === Object.prototype);
ok(getPrototypeOf([]) === Array.prototype);
ok(getPrototypeOf(new (fn = (function(){
fn.displayName = 'fn';
var prototype = fn.prototype, constructor = fn;
function fn(){}
return fn;
}()))) === fn.prototype);
ok(getPrototypeOf(create(obj = {
q: 1
})) === obj);
ok(getPrototypeOf(create(null)) === null);
ok(getPrototypeOf(getPrototypeOf({})) === null);
});
test('Object.getOwnPropertyNames', function(){
var getOwnPropertyNames, fn1, fn2;
getOwnPropertyNames = Object.getOwnPropertyNames;
ok(isFunction(getOwnPropertyNames), 'Is function');
fn1 = function(w){
this.w = w != null ? w : 2;
};
fn2 = function(toString){
this.toString = toString != null ? toString : 2;
};
fn1.prototype.q = fn2.prototype.q = 1;
deepEqual(getOwnPropertyNames([1, 2, 3]), ['0', '1', '2', 'length']);
deepEqual(getOwnPropertyNames(new fn1(1)), ['w']);
deepEqual(getOwnPropertyNames(new fn2(1)), ['toString']);
ok(in$('toString', getOwnPropertyNames(Array.prototype)));
ok(in$('toString', getOwnPropertyNames(Object.prototype)));
ok(in$('constructor', getOwnPropertyNames(Object.prototype)));
});
test('Object.create', function(){
var create, getPrototypeOf, getOwnPropertyNames, isObject, isPrototype, getPropertyNames, obj, fn;
create = Object.create, getPrototypeOf = Object.getPrototypeOf, getOwnPropertyNames = Object.getOwnPropertyNames;
isObject = function(it){
return it === Object(it);
};
isPrototype = function(a, b){
return {}.isPrototypeOf.call(a, b);
};
getPropertyNames = function(object){
var result, i$, x$, ref$, len$;
result = getOwnPropertyNames(object);
while (object = getPrototypeOf(object)) {
for (i$ = 0, len$ = (ref$ = getOwnPropertyNames(object)).length; i$ < len$; ++i$) {
x$ = ref$[i$];
in$(x$, result) || result.push(x$);
}
}
return result;
};
ok(isFunction(create), 'Is function');
ok(isPrototype(obj = {
q: 1
}, create(obj)));
ok(create(obj).q === 1);
fn = function(){
return this.a = 1;
};
ok(create(new fn) instanceof fn);
ok(fn.prototype === getPrototypeOf(getPrototypeOf(create(new fn))));
ok(create(new fn).a === 1);
ok(create({}, {
a: {
value: 42
}
}).a === 42);
ok(isObject(obj = create(null, {
w: {
value: 2
}
})));
ok(!('toString' in obj));
ok(obj.w === 2);
deepEqual(getPropertyNames(create(null)), []);
});
test('Object.keys', function(){
var keys, fn1, fn2;
keys = Object.keys;
ok(isFunction(keys), 'Is function');
fn1 = function(w){
this.w = w != null ? w : 2;
};
fn2 = function(toString){
this.toString = toString != null ? toString : 2;
};
fn1.prototype.q = fn2.prototype.q = 1;
deepEqual(keys([1, 2, 3]), ['0', '1', '2']);
deepEqual(keys(new fn1(1)), ['w']);
deepEqual(keys(new fn2(1)), ['toString']);
ok(!in$('push', keys(Array.prototype)));
});
test('Function#bind', function(){
var obj;
ok(isFunction(Function.prototype.bind), 'Is function');
obj = {
a: 42
};
ok(42 === function(){
return this.a;
}.bind(obj)());
ok(void 8 === new (function(){}.bind(obj))().a);
ok(42 === function(it){
return it;
}.bind(null, 42)());
});
test('Array.isArray', function(){
var isArray;
isArray = Array.isArray;
ok(isFunction(isArray), 'Is function');
ok(!isArray({}));
ok(!isArray(function(){
return arguments;
}()));
ok(isArray([]));
});
test('ES5 Array prototype methods are functions', function(){
var i$, x$, ref$, len$;
for (i$ = 0, len$ = (ref$ = ['indexOf', 'lastIndexOf', 'every', 'some', 'forEach', 'map', 'filter', 'reduce', 'reduceRight']).length; i$ < len$; ++i$) {
x$ = ref$[i$];
ok(isFunction(Array.prototype[x$]), "Array::" + x$ + " is function");
}
});
test('Array#indexOf', function(){
ok(0 === [1, 1, 1].indexOf(1));
ok(-1 === [1, 2, 3].indexOf(1, 1));
ok(1 === [1, 2, 3].indexOf(2, 1));
ok(-1 === [NaN].indexOf(NaN));
ok(3 === Array(2).concat([1, 2, 3]).indexOf(2));
ok(-1 === Array(1).indexOf(void 8));
});
test('Array#lastIndexOf', function(){
ok(2 === [1, 1, 1].lastIndexOf(1));
ok(-1 === [1, 2, 3].lastIndexOf(3, 1));
ok(1 === [1, 2, 3].lastIndexOf(2, 1));
ok(-1 === [NaN].lastIndexOf(NaN));
ok(1 === [1, 2, 3].concat(Array(2)).lastIndexOf(2));
});
test('Array#every', function(){
var a, ctx, rez, arr;
(a = [1]).every(function(val, key, that){
ok(val === 1);
ok(key === 0);
ok(that === a);
return ok(this === ctx);
}, ctx = {});
ok([1, 2, 3].every(function(it){
return toString$.call(it).slice(8, -1) === 'Number';
}));
ok([1, 2, 3].every((function(it){
return it < 4;
})));
ok(![1, 2, 3].every((function(it){
return it < 3;
})));
ok(![1, 2, 3].every(function(it){
return toString$.call(it).slice(8, -1) === 'String';
}));
ok([1, 2, 3].every(function(){
return +this === 1;
}, 1));
rez = '';
[1, 2, 3].every(function(){
return rez += arguments[1];
});
ok(rez === '012');
ok((arr = [1, 2, 3]).every(function(){
return arguments[2] === arr;
}));
});
test('Array#some', function(){
var a, ctx, rez, arr;
(a = [1]).some(function(val, key, that){
ok(val === 1);
ok(key === 0);
ok(that === a);
return ok(this === ctx);
}, ctx = {});
ok([1, '2', 3].some(function(it){
return toString$.call(it).slice(8, -1) === 'Number';
}));
ok([1, 2, 3].some((function(it){
return it < 3;
})));
ok(![1, 2, 3].some((function(it){
return it < 0;
})));
ok(![1, 2, 3].some(function(it){
return toString$.call(it).slice(8, -1) === 'String';
}));
ok(![1, 2, 3].some(function(){
return +this !== 1;
}, 1));
rez = '';
[1, 2, 3].some(function(){
rez += arguments[1];
return false;
});
ok(rez === '012');
ok(!(arr = [1, 2, 3]).some(function(){
return arguments[2] !== arr;
}));
});
test('Array#forEach', function(){
var a, ctx, rez, arr;
(a = [1]).forEach(function(val, key, that){
ok(val === 1);
ok(key === 0);
ok(that === a);
ok(this === ctx);
}, ctx = {});
rez = '';
[1, 2, 3].forEach(function(it){
rez += it;
});
ok(rez === '123');
rez = '';
[1, 2, 3].forEach(function(){
rez += arguments[1];
});
ok(rez === '012');
rez = '';
[1, 2, 3].forEach(function(){
rez += arguments[2];
});
ok(rez === '1,2,31,2,31,2,3');
rez = '';
[1, 2, 3].forEach(function(){
rez += this;
}, 1);
ok(rez === '111');
rez = '';
arr = [];
arr[5] = '';
arr.forEach(function(arg$, k){
rez += k;
});
ok(rez === '5');
});
test('Array#map', function(){
var a, ctx;
(a = [1]).map(function(val, key, that){
ok(val === 1);
ok(key === 0);
ok(that === a);
return ok(this === ctx);
}, ctx = {});
deepEqual([2, 3, 4], [1, 2, 3].map((function(it){
return it + 1;
})));
deepEqual([1, 3, 5], [1, 2, 3].map(curry$(function(x$, y$){
return x$ + y$;
})));
deepEqual([2, 2, 2], [1, 2, 3].map(function(){
return +this;
}, 2));
});
test('Array#filter', function(){
var a, ctx;
(a = [1]).filter(function(val, key, that){
ok(val === 1);
ok(key === 0);
ok(that === a);
return ok(this === ctx);
}, ctx = {});
deepEqual([1, 2, 3, 4, 5], [1, 2, 3, 'q', {}, 4, true, 5].filter(function(it){
return toString$.call(it).slice(8, -1) === 'Number';
}));
});
test('Array#reduce', function(){
var a;
ok(-5 === [5, 4, 3, 2, 1].reduce(curry$(function(x$, y$){
return x$ - y$;
})));
(a = [1]).reduce(function(memo, val, key, that){
ok(memo === 42);
ok(val === 1);
ok(key === 0);
return ok(that === a);
}, 42);
[42, 43].reduce(function(it){
return ok(it === 42);
});
});
test('Array#reduceRight', function(){
var a;
ok(-5 === [1, 2, 3, 4, 5].reduceRight(curry$(function(x$, y$){
return x$ - y$;
})));
(a = [1]).reduceRight(function(memo, val, key, that){
ok(memo === 42);
ok(val === 1);
ok(key === 0);
return ok(that === a);
}, 42);
[42, 43].reduceRight(function(it){
return ok(it === 43);
});
});
test('String#trim', function(){
ok(isFunction(String.prototype.trim), 'Is function');
ok(' q w e \n '.trim() === 'q w e', 'Remove whitespaces at left & right side of string');
});
test('Date.now', function(){
var now;
now = Date.now;
ok(isFunction(now), 'Is function');
ok(+new Date - now() < 10, 'Date.now() ~ +new Date');
});
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
function curry$(f, bound){
var context,
_curry = function(args) {
return f.length > 1 ? function(){
var params = args ? args.concat() : [];
context = bound ? context || this : this;
return params.push.apply(params, arguments) <
f.length && arguments.length ?
_curry.call(context, params) : f.apply(context, params);
} : f;
};
return _curry();
}
}).call(this);
(function(){
'use strict';
var eq, deq, sameEq, strict, isFunction, isNative, getOwnPropertyDescriptor, defineProperty, create, epsilon, toString$ = {}.toString;
QUnit.module('ES6');
eq = strictEqual;
deq = deepEqual;
sameEq = function(a, b, c){
return ok(Object.is(a, b), c);
};
strict = typeof function(){
return this;
}.call(void 8) === 'undefined';
isFunction = function(it){
return toString$.call(it).slice(8, -1) === 'Function';
};
isNative = function(it){
return /\[native code\]\s*\}\s*$/