ladybird/Userland/Libraries/LibJS/Tests/builtins/Array/Array.isArray.js
Linus Groh a72276407b LibJS: Make ArrayPrototype an Array object
https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object

The Array prototype object: [...] is an Array exotic object and has the
internal methods specified for such objects.

NOTE: The Array prototype object is specified to be an Array exotic
object to ensure compatibility with ECMAScript code that was created
prior to the ECMAScript 2015 specification.
2021-02-24 10:22:17 +01:00

25 lines
947 B
JavaScript

test("length is 1", () => {
expect(Array.isArray).toHaveLength(1);
});
test("arguments that evaluate to false", () => {
expect(Array.isArray()).toBeFalse();
expect(Array.isArray("1")).toBeFalse();
expect(Array.isArray("foo")).toBeFalse();
expect(Array.isArray(1)).toBeFalse();
expect(Array.isArray(1, 2, 3)).toBeFalse();
expect(Array.isArray(undefined)).toBeFalse();
expect(Array.isArray(null)).toBeFalse();
expect(Array.isArray(Infinity)).toBeFalse();
expect(Array.isArray({})).toBeFalse();
});
test("arguments that evaluate to true", () => {
expect(Array.isArray([])).toBeTrue();
expect(Array.isArray([1])).toBeTrue();
expect(Array.isArray([1, 2, 3])).toBeTrue();
expect(Array.isArray(new Array())).toBeTrue();
expect(Array.isArray(new Array(10))).toBeTrue();
expect(Array.isArray(new Array("a", "b", "c"))).toBeTrue();
expect(Array.isArray(Array.prototype)).toBeTrue();
});