mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibJS: Move tests to /Tests/LibJS
This commit is contained in:
committed by
Tim Flynn
parent
c059c6a2f5
commit
e3faa9b5ad
Notes:
github-actions[bot]
2026-02-06 11:17:48 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/e3faa9b5add Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7572 Reviewed-by: https://github.com/trflynn89 ✅
34
Tests/LibJS/Runtime/builtins/Array/Array.isArray.js
Normal file
34
Tests/LibJS/Runtime/builtins/Array/Array.isArray.js
Normal file
@@ -0,0 +1,34 @@
|
||||
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();
|
||||
expect(Array.isArray(new Proxy([], {}))).toBeTrue();
|
||||
});
|
||||
|
||||
test("Revoked Proxy as argument throws", () => {
|
||||
const revocable = Proxy.revocable([], {});
|
||||
revocable.revoke();
|
||||
expect(() => {
|
||||
Array.isArray(revocable.proxy);
|
||||
}).toThrowWithMessage(TypeError, "An operation was performed on a revoked Proxy object");
|
||||
});
|
||||
Reference in New Issue
Block a user