mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
LibJS: Indent tests with 4 spaces instead of 2
This commit is contained in:
parent
15de2eda2b
commit
1ef573eb30
261 changed files with 8536 additions and 8497 deletions
|
@ -7,7 +7,7 @@
|
|||
"quoteProps": "as-needed",
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"tabWidth": 2,
|
||||
"tabWidth": 4,
|
||||
"trailingComma": "es5",
|
||||
"useTabs": false
|
||||
}
|
||||
|
|
|
@ -44,10 +44,13 @@ try {
|
|||
assert(Array.prototype.join.call({ length: "foo" }) === "");
|
||||
assert(Array.prototype.join.call({ length: 3 }) === ",,");
|
||||
assert(Array.prototype.join.call({ length: 2, 0: "foo", 1: "bar" }) === "foo,bar");
|
||||
assert(Array.prototype.join.call({ length: 2, 0: "foo", 1: "bar", 2: "baz" }) === "foo,bar");
|
||||
assert(
|
||||
Array.prototype.join.call({ length: 2, 0: "foo", 1: "bar", 2: "baz" }) === "foo,bar"
|
||||
);
|
||||
assert(Array.prototype.join.call({ length: 3, 1: "bar" }, "~") === "~bar~");
|
||||
assert(
|
||||
Array.prototype.join.call({ length: 3, 0: "foo", 1: "bar", 2: "baz" }, "~") === "foo~bar~baz"
|
||||
Array.prototype.join.call({ length: 3, 0: "foo", 1: "bar", 2: "baz" }, "~") ===
|
||||
"foo~bar~baz"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -73,7 +76,9 @@ try {
|
|||
assert(Array.prototype.lastIndexOf.call({ length: 1, 2: "foo" }, "foo") === -1);
|
||||
assert(Array.prototype.lastIndexOf.call({ length: 5, 2: "foo" }, "foo") === 2);
|
||||
assert(Array.prototype.lastIndexOf.call({ length: 5, 2: "foo", 4: "foo" }, "foo") === 4);
|
||||
assert(Array.prototype.lastIndexOf.call({ length: 5, 2: "foo", 4: "foo" }, "foo", -2) === 2);
|
||||
assert(
|
||||
Array.prototype.lastIndexOf.call({ length: 5, 2: "foo", 4: "foo" }, "foo", -2) === 2
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -21,7 +21,9 @@ describe("correct behavior", () => {
|
|||
expect(new Function("foo", "bar", "return foo + bar")(1, 2)).toBe(3);
|
||||
expect(new Function("foo", "bar,baz", "return foo + bar + baz")(1, 2, 3)).toBe(6);
|
||||
expect(new Function("foo", "bar", "baz", "return foo + bar + baz")(1, 2, 3)).toBe(6);
|
||||
expect(new Function("foo", "if (foo) { return 42; } else { return 'bar'; }")(true)).toBe(42);
|
||||
expect(new Function("foo", "if (foo) { return 42; } else { return 'bar'; }")(true)).toBe(
|
||||
42
|
||||
);
|
||||
expect(new Function("foo", "if (foo) { return 42; } else { return 'bar'; }")(false)).toBe(
|
||||
"bar"
|
||||
);
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
test("basic functionality", () => {
|
||||
let string = `{"var1":10,"var2":"hello","var3":{"nested":5}}`;
|
||||
|
||||
let object = JSON.parse(string, (key, value) => (typeof value === "number" ? value * 2 : value));
|
||||
let object = JSON.parse(string, (key, value) =>
|
||||
typeof value === "number" ? value * 2 : value
|
||||
);
|
||||
expect(object).toEqual({ var1: 20, var2: "hello", var3: { nested: 10 } });
|
||||
|
||||
object = JSON.parse(string, (key, value) => (typeof value === "number" ? undefined : value));
|
||||
|
|
|
@ -81,7 +81,10 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
Object.defineProperty(o, "foo", { value: 2, writable: false, enumerable: true });
|
||||
}).toThrowWithMessage(TypeError, "Cannot change attributes of non-configurable property 'foo'");
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Cannot change attributes of non-configurable property 'foo'"
|
||||
);
|
||||
});
|
||||
|
||||
test("cannot define 'value' and 'get' in the same descriptor", () => {
|
||||
|
@ -132,6 +135,9 @@ describe("errors", () => {
|
|||
return this.secret_foo + 2;
|
||||
},
|
||||
});
|
||||
}).toThrowWithMessage(TypeError, "Cannot change attributes of non-configurable property 'foo'");
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Cannot change attributes of non-configurable property 'foo'"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,7 +4,10 @@ describe("[Call][GetOwnProperty]] trap normal behavior", () => {
|
|||
Object.getOwnPropertyDescriptor(new Proxy({}, { getOwnPropertyDescriptor: null }), "a")
|
||||
).toBeUndefined();
|
||||
expect(
|
||||
Object.getOwnPropertyDescriptor(new Proxy({}, { getOwnPropertyDescriptor: undefined }), "a")
|
||||
Object.getOwnPropertyDescriptor(
|
||||
new Proxy({}, { getOwnPropertyDescriptor: undefined }),
|
||||
"a"
|
||||
)
|
||||
).toBeUndefined();
|
||||
expect(Object.getOwnPropertyDescriptor(new Proxy({}, {}), "a")).toBeUndefined();
|
||||
});
|
||||
|
@ -33,7 +36,12 @@ describe("[Call][GetOwnProperty]] trap normal behavior", () => {
|
|||
let p = new Proxy(o, {
|
||||
getOwnPropertyDescriptor(target, property) {
|
||||
if (property === "baz") return Object.getOwnPropertyDescriptor(target, "baz");
|
||||
return { value: target[property], enumerable: false, configurable: true, writable: true };
|
||||
return {
|
||||
value: target[property],
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,10 @@ describe("errors", () => {
|
|||
[null, undefined, "foo", 123, NaN, Infinity, {}].forEach(value => {
|
||||
expect(() => {
|
||||
Reflect.apply(value);
|
||||
}).toThrowWithMessage(TypeError, "First argument of Reflect.apply() must be a function");
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"First argument of Reflect.apply() must be a function"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -23,7 +26,9 @@ describe("errors", () => {
|
|||
describe("normal behavior", () => {
|
||||
test("calling built-in functions", () => {
|
||||
expect(Reflect.apply(String.prototype.charAt, "foo", [0])).toBe("f");
|
||||
expect(Reflect.apply(Array.prototype.indexOf, ["hello", 123, "foo", "bar"], ["foo"])).toBe(2);
|
||||
expect(Reflect.apply(Array.prototype.indexOf, ["hello", 123, "foo", "bar"], ["foo"])).toBe(
|
||||
2
|
||||
);
|
||||
});
|
||||
|
||||
test("|this| argument is forwarded to called function", () => {
|
||||
|
|
|
@ -7,7 +7,10 @@ describe("errors", () => {
|
|||
[null, undefined, "foo", 123, NaN, Infinity, {}].forEach(value => {
|
||||
expect(() => {
|
||||
Reflect.construct(value);
|
||||
}).toThrowWithMessage(TypeError, "First argument of Reflect.construct() must be a function");
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"First argument of Reflect.construct() must be a function"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,10 @@ describe("errors", () => {
|
|||
[null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
|
||||
expect(() => {
|
||||
Reflect.ownKeys(value);
|
||||
}).toThrowWithMessage(TypeError, "First argument of Reflect.ownKeys() must be an object");
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"First argument of Reflect.ownKeys() must be an object"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,7 +22,10 @@ test("calling undefined object key", () => {
|
|||
test("calling object", () => {
|
||||
expect(() => {
|
||||
Math();
|
||||
}).toThrowWithMessage(TypeError, "[object MathObject] is not a function (evaluated from 'Math')");
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"[object MathObject] is not a function (evaluated from 'Math')"
|
||||
);
|
||||
});
|
||||
|
||||
test("constructing object", () => {
|
||||
|
|
|
@ -86,7 +86,9 @@ describe("tagged template literal functionality", () => {
|
|||
}
|
||||
var name = "SerenityOS";
|
||||
var rating = "great";
|
||||
expect(review`${name} is a ${rating} project!`).toBe("**SerenityOS** is a _great_ project!");
|
||||
expect(review`${name} is a ${rating} project!`).toBe(
|
||||
"**SerenityOS** is a _great_ project!"
|
||||
);
|
||||
});
|
||||
|
||||
test("template object structure", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue