1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:17:35 +00:00

LibJS: Indent tests with 4 spaces instead of 2

This commit is contained in:
Matthew Olsson 2020-07-06 07:37:45 -07:00 committed by Andreas Kling
parent 15de2eda2b
commit 1ef573eb30
261 changed files with 8536 additions and 8497 deletions

View file

@ -1,10 +1,10 @@
test("basic functionality", () => {
var j = 0;
for (var i = 0; i < 9; ++i) {
if (i == 3) {
continue;
var j = 0;
for (var i = 0; i < 9; ++i) {
if (i == 3) {
continue;
}
++j;
}
++j;
}
expect(j).toBe(8);
expect(j).toBe(8);
});

View file

@ -1,14 +1,14 @@
test("basic functionality", () => {
let number = 0;
do {
number++;
} while (number < 9);
expect(number).toBe(9);
let number = 0;
do {
number++;
} while (number < 9);
expect(number).toBe(9);
});
test("no braces", () => {
let number = 0;
do number++;
while (number < 3);
expect(number).toBe(3);
let number = 0;
do number++;
while (number < 3);
expect(number).toBe(3);
});

View file

@ -1,15 +1,15 @@
test("basic functionality", () => {
let a = [];
for (let i = 0; i < 3; ++i) {
a.push(i);
}
expect(a).toEqual([0, 1, 2]);
let a = [];
for (let i = 0; i < 3; ++i) {
a.push(i);
}
expect(a).toEqual([0, 1, 2]);
});
test("only condition", () => {
let a = [];
for (; a.length < 3; ) {
a.push("x");
}
expect(a).toEqual(["x", "x", "x"]);
let a = [];
for (; a.length < 3; ) {
a.push("x");
}
expect(a).toEqual(["x", "x", "x"]);
});

View file

@ -1,23 +1,23 @@
test("using undefined variable in initializer", () => {
expect(() => {
for (let i = foo; i < 100; ++i) {}
}).toThrowWithMessage(ReferenceError, "'foo' is not defined");
expect(() => {
for (let i = foo; i < 100; ++i) {}
}).toThrowWithMessage(ReferenceError, "'foo' is not defined");
});
test("using undefined variable in condition", () => {
expect(() => {
for (let i = 0; i < foo; ++i) {}
}).toThrowWithMessage(ReferenceError, "'foo' is not defined");
expect(() => {
for (let i = 0; i < foo; ++i) {}
}).toThrowWithMessage(ReferenceError, "'foo' is not defined");
});
test("using undefined variable in updater", () => {
let loopCount = 0;
let loopCount = 0;
expect(() => {
for (let i = 0; i < 100; ++foo) {
loopCount++;
}
}).toThrowWithMessage(ReferenceError, "'foo' is not defined");
expect(() => {
for (let i = 0; i < 100; ++foo) {
loopCount++;
}
}).toThrowWithMessage(ReferenceError, "'foo' is not defined");
expect(loopCount).toBe(1);
expect(loopCount).toBe(1);
});

View file

@ -1,45 +1,45 @@
test("iterate through empty string", () => {
const a = [];
for (const property in "") {
a.push(property);
}
expect(a).toEqual([]);
const a = [];
for (const property in "") {
a.push(property);
}
expect(a).toEqual([]);
});
test("iterate through number", () => {
const a = [];
for (const property in 123) {
a.push(property);
}
expect(a).toEqual([]);
const a = [];
for (const property in 123) {
a.push(property);
}
expect(a).toEqual([]);
});
test("iterate through empty object", () => {
const a = [];
for (const property in {}) {
a.push(property);
}
expect(a).toEqual([]);
const a = [];
for (const property in {}) {
a.push(property);
}
expect(a).toEqual([]);
});
test("iterate through string", () => {
const a = [];
for (const property in "hello") {
a.push(property);
}
expect(a).toEqual(["0", "1", "2", "3", "4"]);
const a = [];
for (const property in "hello") {
a.push(property);
}
expect(a).toEqual(["0", "1", "2", "3", "4"]);
});
test("iterate through object", () => {
const a = [];
for (const property in { a: 1, b: 2, c: 2 }) {
a.push(property);
}
expect(a).toEqual(["a", "b", "c"]);
const a = [];
for (const property in { a: 1, b: 2, c: 2 }) {
a.push(property);
}
expect(a).toEqual(["a", "b", "c"]);
});
test("use already-declared variable", () => {
var property;
for (property in "abc");
expect(property).toBe("2");
var property;
for (property in "abc");
expect(property).toBe("2");
});

View file

@ -1,5 +1,5 @@
test("basic functionality", () => {
let number = 0;
for (let i = 0; i < 3; ++i) for (let j = 0; j < 3; ++j) number++;
expect(number).toBe(9);
let number = 0;
for (let i = 0; i < 3; ++i) for (let j = 0; j < 3; ++j) number++;
expect(number).toBe(9);
});

View file

@ -1,47 +1,47 @@
describe("correct behavior", () => {
test("iterate through array", () => {
const a = [];
for (const num of [1, 2, 3]) {
a.push(num);
}
expect(a).toEqual([1, 2, 3]);
});
test("iterate through array", () => {
const a = [];
for (const num of [1, 2, 3]) {
a.push(num);
}
expect(a).toEqual([1, 2, 3]);
});
test("iterate through string", () => {
const a = [];
for (const char of "hello") {
a.push(char);
}
expect(a).toEqual(["h", "e", "l", "l", "o"]);
});
test("iterate through string", () => {
const a = [];
for (const char of "hello") {
a.push(char);
}
expect(a).toEqual(["h", "e", "l", "l", "o"]);
});
test("iterate through string object", () => {
const a = [];
for (const char of new String("hello")) {
a.push(char);
}
expect(a).toEqual(["h", "e", "l", "l", "o"]);
});
test("iterate through string object", () => {
const a = [];
for (const char of new String("hello")) {
a.push(char);
}
expect(a).toEqual(["h", "e", "l", "l", "o"]);
});
test("use already-declared variable", () => {
var char;
for (char of "abc");
expect(char).toBe("c");
});
test("use already-declared variable", () => {
var char;
for (char of "abc");
expect(char).toBe("c");
});
});
describe("errors", () => {
test("right hand side is a primitive", () => {
expect(() => {
for (const _ of 123) {
}
}).toThrowWithMessage(TypeError, "for..of right-hand side must be iterable");
});
test("right hand side is a primitive", () => {
expect(() => {
for (const _ of 123) {
}
}).toThrowWithMessage(TypeError, "for..of right-hand side must be iterable");
});
test("right hand side is an object", () => {
expect(() => {
for (const _ of { foo: 1, bar: 2 }) {
}
}).toThrowWithMessage(TypeError, "for..of right-hand side must be iterable");
});
test("right hand side is an object", () => {
expect(() => {
for (const _ of { foo: 1, bar: 2 }) {
}
}).toThrowWithMessage(TypeError, "for..of right-hand side must be iterable");
});
});

View file

@ -1,18 +1,18 @@
test("var in for head", () => {
for (var v = 5; false; );
expect(v).toBe(5);
for (var v = 5; false; );
expect(v).toBe(5);
});
test("let in for head", () => {
for (let l = 5; false; );
expect(() => {
l;
}).toThrowWithMessage(ReferenceError, "'l' is not defined");
for (let l = 5; false; );
expect(() => {
l;
}).toThrowWithMessage(ReferenceError, "'l' is not defined");
});
test("const in for head", () => {
for (const c = 5; false; );
expect(() => {
c;
}).toThrowWithMessage(ReferenceError, "'c' is not defined");
for (const c = 5; false; );
expect(() => {
c;
}).toThrowWithMessage(ReferenceError, "'c' is not defined");
});

View file

@ -1,19 +1,19 @@
test("basic functionality", () => {
let number = 0;
while (number < 9) {
number++;
}
expect(number).toBe(9);
let number = 0;
while (number < 9) {
number++;
}
expect(number).toBe(9);
});
test("no braces", () => {
let number = 0;
while (number < 3) number++;
expect(number).toBe(3);
let number = 0;
while (number < 3) number++;
expect(number).toBe(3);
});
test("does not loop when initially false", () => {
while (false) {
expect().fail();
}
while (false) {
expect().fail();
}
});