Skip to content

String#repeat called on undefined or null should throw #164

@mathiasbynens

Description

@mathiasbynens

This implementation fails the following tests taken from https://github.com/mathiasbynens/String.prototype.repeat/blob/master/tests/tests.js:

assertThrows(function() { String.prototype.repeat.call(undefined); }, TypeError);
assertThrows(function() { String.prototype.repeat.call(undefined, 4); }, TypeError);
assertThrows(function() { String.prototype.repeat.call(null); }, TypeError);
assertThrows(function() { String.prototype.repeat.call(null, 4); }, TypeError);

assertThrows(function() { String.prototype.repeat.apply(undefined); }, TypeError);
assertThrows(function() { String.prototype.repeat.apply(undefined, [4]); }, TypeError);
assertThrows(function() { String.prototype.repeat.apply(null); }, TypeError);
assertThrows(function() { String.prototype.repeat.apply(null, [4]); }, TypeError);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions