Files
NapCatQQ/.pnpm-store/v3/files/55/36c3e873fe067992b821e7923b93c0328da6d962ddcacc7ea532166cd493fb66d58a2ac60c1219d2aa7ca640f5f9765d79689752cd4d96faca32b1686d1926
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

45 lines
1.4 KiB
Plaintext

'use strict';
module.exports = function(repeat, t) {
t.test('cast count argument', function(st) {
st.equal(repeat('abc'), '');
st.equal(repeat('abc', undefined), '');
st.equal(repeat('abc', null), '');
st.equal(repeat('abc', false), '');
st.equal(repeat('abc', NaN), '');
st.equal(repeat('abc', 'abc'), '');
st.end();
});
t.test('invalid numeric count', function(st) {
st['throws'](function() { repeat('abc', -Infinity); }, RangeError);
st['throws'](function() { repeat('abc', -1); }, RangeError);
st['throws'](function() { repeat('abc', +Infinity); }, RangeError);
st.end();
});
t.test('valid numeric count', function(st) {
st.equal(repeat('abc', -0), '');
st.equal(repeat('abc', +0), '');
st.equal(repeat('abc', 1), 'abc');
st.equal(repeat('abc', 2), 'abcabc');
st.equal(repeat('abc', 3), 'abcabcabc');
st.equal(repeat('abc', 4), 'abcabcabcabc');
st.end();
});
t.test('nullish this object', function(st) {
st['throws'](function() { repeat(undefined); }, TypeError);
st['throws'](function() { repeat(undefined, 4); }, TypeError);
st['throws'](function() { repeat(null); }, TypeError);
st['throws'](function() { repeat(null, 4); }, TypeError);
st.end();
});
t.test('cast this object', function(st) {
st.equal(repeat(42, 4), '42424242');
st.equal(repeat({ 'toString': function() { return 'abc'; } }, 2), 'abcabc');
st.end();
});
};