Skip to content

Add more test cases in Array, Object #6

@hueitan

Description

@hueitan

I understand that searchString is not accepted in RegExp. (TypeError exception)

Throwing an exception if the first argument is a RegExp is specified in order to allow future editions to define extensions that allow such argument values.

But it does accept Array and Object through the method toString under the specification.

which are

// array
['this', 'is', 'an', 'array'].toString(); // => 'this,is,an,array'

// object
({'obj': 'obj'}).toString(); // => '[object Object]'

Therefore, I would like to add more test cases

// array
assertEquals('this,is,an,array').includes(['this', 'is']), true);
assertEquals('this,is,an,array').includes(['this', 'is'], 1), false);
assertEquals('this, is, an, array').includes(['this', 'is']), false);

// object
assertEquals(String.prototype.includes.apply({ 'toString': function () { return '[object Object]'; }}, [{'obj': 'obj'}, 0]),  true);

It’s weird if someone input the array or object to the method includes, but it does support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions