mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
Base+LibJS+LibWeb: Make prettier clean
Also use "// prettier-ignore" comments where necessary rather than excluding whole files (via .prettierignore).
This commit is contained in:
parent
76239f89c2
commit
5122f98198
24 changed files with 100 additions and 79 deletions
|
@ -1,3 +0,0 @@
|
||||||
classes/class-expressions.js
|
|
||||||
functions/function-strict-mode.js
|
|
||||||
new-expression.js
|
|
|
@ -13,4 +13,3 @@ test("basic arguments object", () => {
|
||||||
expect(bar("hello", "friends", ":^)")).toBe("friends");
|
expect(bar("hello", "friends", ":^)")).toBe("friends");
|
||||||
expect(bar("hello")).toBe(undefined);
|
expect(bar("hello")).toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,9 @@ describe("normal behavior", () => {
|
||||||
let value = begin - 1;
|
let value = begin - 1;
|
||||||
return {
|
return {
|
||||||
next() {
|
next() {
|
||||||
if (value < end)
|
if (value < end) {
|
||||||
value += 1;
|
value += 1;
|
||||||
|
}
|
||||||
return { value: value, done: value >= end };
|
return { value: value, done: value >= end };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,11 +42,14 @@ describe("[[Get]] trap normal behavior", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("custom receiver value", () => {
|
test("custom receiver value", () => {
|
||||||
let p = new Proxy({}, {
|
let p = new Proxy(
|
||||||
|
{},
|
||||||
|
{
|
||||||
get(target, property, receiver) {
|
get(target, property, receiver) {
|
||||||
return receiver;
|
return receiver;
|
||||||
},
|
},
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
expect(Reflect.get(p, "foo", 42)).toBe(42);
|
expect(Reflect.get(p, "foo", 42)).toBe(42);
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,7 +40,7 @@ describe("[[Set]] trap normal behavior", () => {
|
||||||
expect(p.foo).toBe(20);
|
expect(p.foo).toBe(20);
|
||||||
p.foo = 10;
|
p.foo = 10;
|
||||||
expect(p.foo).toBe(10);
|
expect(p.foo).toBe(10);
|
||||||
p[Symbol.hasInstance] = "foo"
|
p[Symbol.hasInstance] = "foo";
|
||||||
expect(p[Symbol.hasInstance]).toBe("foo");
|
expect(p[Symbol.hasInstance]).toBe("foo");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,6 @@ test("basic functionality", () => {
|
||||||
expect(/foo/s.flags).toBe("s");
|
expect(/foo/s.flags).toBe("s");
|
||||||
expect(/foo/u.flags).toBe("u");
|
expect(/foo/u.flags).toBe("u");
|
||||||
expect(/foo/y.flags).toBe("y");
|
expect(/foo/y.flags).toBe("y");
|
||||||
|
// prettier-ignore
|
||||||
expect(/foo/sgimyu.flags).toBe("gimsuy");
|
expect(/foo/sgimyu.flags).toBe("gimsuy");
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,6 +34,9 @@ test("basic functionality", () => {
|
||||||
expect(s.endsWith("", -1)).toBeTrue();
|
expect(s.endsWith("", -1)).toBeTrue();
|
||||||
expect(s.endsWith("", 42)).toBeTrue();
|
expect(s.endsWith("", 42)).toBeTrue();
|
||||||
expect("12undefined".endsWith()).toBeTrue();
|
expect("12undefined".endsWith()).toBeTrue();
|
||||||
expect(() => s.endsWith(/foobar/)).toThrowWithMessage(TypeError, "searchString is not a string, but a regular expression");
|
expect(() => s.endsWith(/foobar/)).toThrowWithMessage(
|
||||||
|
TypeError,
|
||||||
|
"searchString is not a string, but a regular expression"
|
||||||
|
);
|
||||||
expect(s.endsWith("bar", undefined)).toBeTrue();
|
expect(s.endsWith("bar", undefined)).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// This file must not be formatted by prettier. Make sure your IDE
|
|
||||||
// respects the .prettierignore file!
|
|
||||||
|
|
||||||
test("basic functionality", () => {
|
test("basic functionality", () => {
|
||||||
const A = class {
|
const A = class {
|
||||||
constructor(x) {
|
constructor(x) {
|
||||||
|
@ -16,6 +13,7 @@ test("basic functionality", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("inline instantiation", () => {
|
test("inline instantiation", () => {
|
||||||
|
// prettier-ignore
|
||||||
const a = new class {
|
const a = new class {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.x = 10;
|
this.x = 10;
|
||||||
|
@ -30,6 +28,7 @@ test("inline instantiation", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("inline instantiation with argument", () => {
|
test("inline instantiation with argument", () => {
|
||||||
|
// prettier-ignore
|
||||||
const a = new class {
|
const a = new class {
|
||||||
constructor(x) {
|
constructor(x) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
@ -53,7 +52,7 @@ test("extending class expressions", () => {
|
||||||
super(y);
|
super(y);
|
||||||
this.y = y * 2;
|
this.y = y * 2;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const a = new A(10);
|
const a = new A(10);
|
||||||
expect(a.x).toBe(10);
|
expect(a.x).toBe(10);
|
||||||
|
@ -61,9 +60,9 @@ test("extending class expressions", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("class expression name", () => {
|
test("class expression name", () => {
|
||||||
let A = class {}
|
let A = class {};
|
||||||
expect(A.name).toBe("A");
|
expect(A.name).toBe("A");
|
||||||
|
|
||||||
let B = class C {}
|
let B = class C {};
|
||||||
expect(B.name).toBe("C");
|
expect(B.name).toBe("C");
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// This file must not be formatted by prettier. Make sure your IDE
|
|
||||||
// respects the .prettierignore file!
|
|
||||||
|
|
||||||
test("non strict-mode by default", () => {
|
test("non strict-mode by default", () => {
|
||||||
expect(isStrictMode()).toBeFalse();
|
expect(isStrictMode()).toBeFalse();
|
||||||
});
|
});
|
||||||
|
@ -10,21 +7,25 @@ test("use strict with double quotes", () => {
|
||||||
expect(isStrictMode()).toBeTrue();
|
expect(isStrictMode()).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
test("use strict with single quotes", () => {
|
test("use strict with single quotes", () => {
|
||||||
'use strict';
|
'use strict';
|
||||||
expect(isStrictMode()).toBeTrue();
|
expect(isStrictMode()).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
test("use strict with backticks does not yield strict mode", () => {
|
test("use strict with backticks does not yield strict mode", () => {
|
||||||
`use strict`;
|
`use strict`;
|
||||||
expect(isStrictMode()).toBeFalse();
|
expect(isStrictMode()).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
test("use strict with single quotes after statement does not yield strict mode code", () => {
|
test("use strict with single quotes after statement does not yield strict mode code", () => {
|
||||||
;'use strict';
|
;'use strict';
|
||||||
expect(isStrictMode()).toBeFalse();
|
expect(isStrictMode()).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
test("use strict with double quotes after statement does not yield strict mode code", () => {
|
test("use strict with double quotes after statement does not yield strict mode code", () => {
|
||||||
;"use strict";
|
;"use strict";
|
||||||
expect(isStrictMode()).toBeFalse();
|
expect(isStrictMode()).toBeFalse();
|
||||||
|
|
|
@ -10,8 +10,9 @@ test("Toplevel break inside loop", () => {
|
||||||
test("break inside sub-blocks", () => {
|
test("break inside sub-blocks", () => {
|
||||||
var j = 0;
|
var j = 0;
|
||||||
for (var i = 0; i < 9; ++i) {
|
for (var i = 0; i < 9; ++i) {
|
||||||
if (j == 4)
|
if (j == 4) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
expect(j).toBe(4);
|
expect(j).toBe(4);
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
// This file must not be formatted by prettier. Make sure your IDE
|
// prettier-ignore
|
||||||
// respects the .prettierignore file!
|
|
||||||
|
|
||||||
test("new-expression parsing", () => {
|
test("new-expression parsing", () => {
|
||||||
function Foo() {
|
function Foo() {
|
||||||
this.x = 1;
|
this.x = 1;
|
||||||
|
@ -21,6 +19,7 @@ test("new-expression parsing", () => {
|
||||||
expect(foo).toBe("[object Object]2");
|
expect(foo).toBe("[object Object]2");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
test("new-expressions with object keys", () => {
|
test("new-expressions with object keys", () => {
|
||||||
let a = {
|
let a = {
|
||||||
b: function () {
|
b: function () {
|
||||||
|
|
|
@ -2,33 +2,33 @@ test("basic parseInt() functionality", () => {
|
||||||
expect(parseInt("0")).toBe(0);
|
expect(parseInt("0")).toBe(0);
|
||||||
expect(parseInt("100")).toBe(100);
|
expect(parseInt("100")).toBe(100);
|
||||||
expect(parseInt("1000", 16)).toBe(4096);
|
expect(parseInt("1000", 16)).toBe(4096);
|
||||||
expect(parseInt('0xF', 16)).toBe(15)
|
expect(parseInt("0xF", 16)).toBe(15);
|
||||||
expect(parseInt('F', 16)).toBe(15)
|
expect(parseInt("F", 16)).toBe(15);
|
||||||
expect(parseInt('17', 8)).toBe(15)
|
expect(parseInt("17", 8)).toBe(15);
|
||||||
expect(parseInt(021, 8)).toBe(15)
|
expect(parseInt(021, 8)).toBe(15);
|
||||||
expect(parseInt('015', 10)).toBe(15)
|
expect(parseInt("015", 10)).toBe(15);
|
||||||
expect(parseInt(15.99, 10)).toBe(15)
|
expect(parseInt(15.99, 10)).toBe(15);
|
||||||
expect(parseInt('15,123', 10)).toBe(15)
|
expect(parseInt("15,123", 10)).toBe(15);
|
||||||
expect(parseInt('FXX123', 16)).toBe(15)
|
expect(parseInt("FXX123", 16)).toBe(15);
|
||||||
expect(parseInt('1111', 2)).toBe(15)
|
expect(parseInt("1111", 2)).toBe(15);
|
||||||
expect(parseInt('15 * 3', 10)).toBe(15)
|
expect(parseInt("15 * 3", 10)).toBe(15);
|
||||||
expect(parseInt('15e2', 10)).toBe(15)
|
expect(parseInt("15e2", 10)).toBe(15);
|
||||||
expect(parseInt('15px', 10)).toBe(15)
|
expect(parseInt("15px", 10)).toBe(15);
|
||||||
expect(parseInt('12', 13)).toBe(15)
|
expect(parseInt("12", 13)).toBe(15);
|
||||||
expect(parseInt('Hello', 8)).toBeNaN();
|
expect(parseInt("Hello", 8)).toBeNaN();
|
||||||
expect(parseInt('546', 2)).toBeNaN();
|
expect(parseInt("546", 2)).toBeNaN();
|
||||||
expect(parseInt('-F', 16)).toBe(-15);
|
expect(parseInt("-F", 16)).toBe(-15);
|
||||||
expect(parseInt('-0F', 16)).toBe(-15);
|
expect(parseInt("-0F", 16)).toBe(-15);
|
||||||
expect(parseInt('-0XF', 16)).toBe(-15);
|
expect(parseInt("-0XF", 16)).toBe(-15);
|
||||||
expect(parseInt(-15.1, 10)).toBe(-15);
|
expect(parseInt(-15.1, 10)).toBe(-15);
|
||||||
expect(parseInt('-17', 8)).toBe(-15);
|
expect(parseInt("-17", 8)).toBe(-15);
|
||||||
expect(parseInt('-15', 10)).toBe(-15);
|
expect(parseInt("-15", 10)).toBe(-15);
|
||||||
expect(parseInt('-1111', 2)).toBe(-15);
|
expect(parseInt("-1111", 2)).toBe(-15);
|
||||||
expect(parseInt('-15e1', 10)).toBe(-15);
|
expect(parseInt("-15e1", 10)).toBe(-15);
|
||||||
expect(parseInt('-12', 13)).toBe(-15);
|
expect(parseInt("-12", 13)).toBe(-15);
|
||||||
expect(parseInt(4.7, 10)).toBe(4);
|
expect(parseInt(4.7, 10)).toBe(4);
|
||||||
expect(parseInt('0e0', 16)).toBe(224);
|
expect(parseInt("0e0", 16)).toBe(224);
|
||||||
expect(parseInt('123_456')).toBe(123);
|
expect(parseInt("123_456")).toBe(123);
|
||||||
|
|
||||||
// FIXME: expect(parseInt(4.7 * 1e22, 10)).toBe(4);
|
// FIXME: expect(parseInt(4.7 * 1e22, 10)).toBe(4);
|
||||||
// FIXME: expect(parseInt(0.00000000000434, 10)).toBe(4);
|
// FIXME: expect(parseInt(0.00000000000434, 10)).toBe(4);
|
||||||
|
@ -42,10 +42,18 @@ test("basic parseInt() functionality", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("parseInt() radix is coerced to a number", () => {
|
test("parseInt() radix is coerced to a number", () => {
|
||||||
const obj = { valueOf() { return 8; } };
|
const obj = {
|
||||||
expect(parseInt('11', obj)).toBe(9);
|
valueOf() {
|
||||||
obj.valueOf = function() { return 1; }
|
return 8;
|
||||||
expect(parseInt('11', obj)).toBeNaN();
|
},
|
||||||
obj.valueOf = function() { return Infinity; }
|
};
|
||||||
expect(parseInt('11', obj)).toBe(11);
|
expect(parseInt("11", obj)).toBe(9);
|
||||||
|
obj.valueOf = function () {
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
expect(parseInt("11", obj)).toBeNaN();
|
||||||
|
obj.valueOf = function () {
|
||||||
|
return Infinity;
|
||||||
|
};
|
||||||
|
expect(parseInt("11", obj)).toBe(11);
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,16 +2,19 @@ test("Issue #3641, strict mode should be function- or program-level, not block-l
|
||||||
function func() {
|
function func() {
|
||||||
expect(isStrictMode()).toBeFalse();
|
expect(isStrictMode()).toBeFalse();
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
{
|
{
|
||||||
"use strict";
|
"use strict";
|
||||||
expect(isStrictMode()).toBeFalse();
|
expect(isStrictMode()).toBeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
if (true) {
|
if (true) {
|
||||||
"use strict";
|
"use strict";
|
||||||
expect(isStrictMode()).toBeFalse();
|
expect(isStrictMode()).toBeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
do {
|
do {
|
||||||
"use strict";
|
"use strict";
|
||||||
expect(isStrictMode()).toBeFalse();
|
expect(isStrictMode()).toBeFalse();
|
||||||
|
|
|
@ -7,6 +7,9 @@ test("basic functionality", () => {
|
||||||
}).toThrowWithMessage(TypeError, "Cannot assign property foo to primitive value");
|
}).toThrowWithMessage(TypeError, "Cannot assign property foo to primitive value");
|
||||||
expect(() => {
|
expect(() => {
|
||||||
primitive[Symbol.hasInstance] = 123;
|
primitive[Symbol.hasInstance] = 123;
|
||||||
}).toThrowWithMessage(TypeError, "Cannot assign property Symbol(Symbol.hasInstance) to primitive value");
|
}).toThrowWithMessage(
|
||||||
|
TypeError,
|
||||||
|
"Cannot assign property Symbol(Symbol.hasInstance) to primitive value"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,7 +40,9 @@ describe("octal escapes", () => {
|
||||||
expect("\5").toBe("\u0005");
|
expect("\5").toBe("\u0005");
|
||||||
expect("\6").toBe("\u0006");
|
expect("\6").toBe("\u0006");
|
||||||
expect("\7").toBe("\u0007");
|
expect("\7").toBe("\u0007");
|
||||||
|
// prettier-ignore
|
||||||
expect("\8").toBe("8");
|
expect("\8").toBe("8");
|
||||||
|
// prettier-ignore
|
||||||
expect("\9").toBe("9");
|
expect("\9").toBe("9");
|
||||||
expect("\128").toBe("\n8");
|
expect("\128").toBe("\n8");
|
||||||
expect("\141bc").toBe("abc");
|
expect("\141bc").toBe("abc");
|
||||||
|
|
|
@ -302,7 +302,7 @@ class ExpectationError extends Error {
|
||||||
// Test for syntax errors; target must be a string
|
// Test for syntax errors; target must be a string
|
||||||
toEval() {
|
toEval() {
|
||||||
this.__expect(typeof this.target === "string");
|
this.__expect(typeof this.target === "string");
|
||||||
const success = canParseSource(this.target)
|
const success = canParseSource(this.target);
|
||||||
this.__expect(this.inverted ? !success : success);
|
this.__expect(this.inverted ? !success : success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ test("valid 'use strict; directive", () => {
|
||||||
})()
|
})()
|
||||||
).toBeTrue();
|
).toBeTrue();
|
||||||
expect(
|
expect(
|
||||||
|
// prettier-ignore
|
||||||
(() => {
|
(() => {
|
||||||
'use strict';
|
'use strict';
|
||||||
return isStrictMode();
|
return isStrictMode();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
test("basic with statement functionality", () => {
|
test("basic with statement functionality", () => {
|
||||||
var object = { "foo": 5, "bar": 6, "baz": 7 };
|
var object = { foo: 5, bar: 6, baz: 7 };
|
||||||
var qux = 1;
|
var qux = 1;
|
||||||
|
|
||||||
var bar = 99;
|
var bar = 99;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
loadPage("file:///res/html/misc/welcome.html")
|
loadPage("file:///res/html/misc/welcome.html");
|
||||||
|
|
||||||
afterInitialPageLoad(() => {
|
afterInitialPageLoad(() => {
|
||||||
test("contentEditable attribute", () => {
|
test("contentEditable attribute", () => {
|
||||||
|
|
|
@ -25,7 +25,7 @@ let __AfterInitialPageLoad__ = () => {};
|
||||||
let afterInitialPageLoad;
|
let afterInitialPageLoad;
|
||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
loadPage = (page) => __PageToLoad__ = page;
|
loadPage = page => (__PageToLoad__ = page);
|
||||||
beforeInitialPageLoad = (callback) => __BeforeInitialPageLoad__ = callback;
|
beforeInitialPageLoad = callback => (__BeforeInitialPageLoad__ = callback);
|
||||||
afterInitialPageLoad = (callback) => __AfterInitialPageLoad__ = callback;
|
afterInitialPageLoad = callback => (__AfterInitialPageLoad__ = callback);
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue