mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
Meta: Increase the line length enforced by prettier to 120
This matches our coding style recommendation in CodingStyle.md, and matches our python formatting.
This commit is contained in:
parent
b7ecdad685
commit
019c529c07
|
|
@ -3,7 +3,7 @@
|
|||
"bracketSpacing": true,
|
||||
"endOfLine": "lf",
|
||||
"insertPragma": false,
|
||||
"printWidth": 100,
|
||||
"printWidth": 120,
|
||||
"quoteProps": "as-needed",
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="color-scheme" content="light dark" />
|
||||
<title>About URLs</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta charset="UTF-8" />
|
||||
<title>New Tab</title>
|
||||
<style>
|
||||
html {
|
||||
|
|
|
|||
|
|
@ -300,10 +300,7 @@
|
|||
<body>
|
||||
<header>
|
||||
<picture>
|
||||
<source
|
||||
srcset="resource://icons/128x128/app-browser.png"
|
||||
media="(prefers-color-scheme: dark)"
|
||||
/>
|
||||
<source srcset="resource://icons/128x128/app-browser.png" media="(prefers-color-scheme: dark)" />
|
||||
<img src="resource://icons/128x128/app-browser-dark.png" />
|
||||
</picture>
|
||||
<h1>Ladybird Settings</h1>
|
||||
|
|
@ -350,9 +347,7 @@
|
|||
|
||||
<div class="card-group">
|
||||
<label for="autocomplete-engine">Search Suggestions</label>
|
||||
<p class="description">
|
||||
Select the engine that will provide search suggestions.
|
||||
</p>
|
||||
<p class="description">Select the engine that will provide search suggestions.</p>
|
||||
<select id="autocomplete-engine">
|
||||
<option value="">Disable search suggestions</option>
|
||||
<hr />
|
||||
|
|
@ -379,9 +374,7 @@
|
|||
<div class="card-body">
|
||||
<div class="card-group">
|
||||
<div class="inline-container">
|
||||
<label for="global-privacy-control-toggle">
|
||||
Enable Global Privacy Control
|
||||
</label>
|
||||
<label for="global-privacy-control-toggle">Enable Global Privacy Control</label>
|
||||
<input id="global-privacy-control-toggle" type="checkbox" switch />
|
||||
</div>
|
||||
<p class="description">Tell websites not to sell or share your data.</p>
|
||||
|
|
@ -471,11 +464,7 @@
|
|||
<div class="form-group">
|
||||
<label for="search-custom-url">Search URL</label>
|
||||
<p class="description">Use %s as a placeholder for the search query</p>
|
||||
<input
|
||||
id="search-custom-url"
|
||||
type="url"
|
||||
placeholder="https://example.com/search?q=%s"
|
||||
/>
|
||||
<input id="search-custom-url" type="url" placeholder="https://example.com/search?q=%s" />
|
||||
</div>
|
||||
<div class="dialog-controls">
|
||||
<button id="search-custom-add" class="primary-button">Add Engine</button>
|
||||
|
|
@ -502,9 +491,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="dialog-footer">
|
||||
<button id="site-settings-remove-all" class="secondary-button">
|
||||
Remove All Sites
|
||||
</button>
|
||||
<button id="site-settings-remove-all" class="secondary-button">Remove All Sites</button>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,6 @@
|
|||
const defaultZoomLevelDropdown = document.querySelector("#default-zoom-level");
|
||||
|
||||
const zoomLevelFactors = [
|
||||
1 / 3.0,
|
||||
0.5,
|
||||
2 / 3.0,
|
||||
0.75,
|
||||
0.8,
|
||||
0.9,
|
||||
1.0,
|
||||
1.1,
|
||||
1.25,
|
||||
1.5,
|
||||
1.75,
|
||||
2.0,
|
||||
2.5,
|
||||
3.0,
|
||||
4.0,
|
||||
5.0,
|
||||
];
|
||||
const zoomLevelFactors = [1 / 3.0, 0.5, 2 / 3.0, 0.75, 0.8, 0.9, 1.0, 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 5.0];
|
||||
|
||||
const zoomLevelFactorMap = zoomLevelFactors.map(factor => ({
|
||||
factor,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta charset="UTF-8" />
|
||||
<title>Index of %path%</title>
|
||||
<style>
|
||||
html {
|
||||
|
|
@ -40,26 +40,28 @@
|
|||
}
|
||||
|
||||
.folder {
|
||||
background-image: url('resource://icons/32x32/filetype-folder.png');
|
||||
background-image: url("resource://icons/32x32/filetype-folder.png");
|
||||
}
|
||||
|
||||
.file {
|
||||
background-image: url('resource://icons/32x32/filetype-unknown.png');
|
||||
background-image: url("resource://icons/32x32/filetype-unknown.png");
|
||||
}
|
||||
|
||||
.open-parent {
|
||||
background-image: url('resource://icons/16x16/open-parent-directory.png');
|
||||
background-image: url("resource://icons/16x16/open-parent-directory.png");
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<span class="folder" style="width: 24px; height: 24px;"></span>
|
||||
<span class="folder" style="width: 24px; height: 24px"></span>
|
||||
<h1>Index of %path%</h1>
|
||||
</header>
|
||||
<p><a href="%parent_url%"><span class="open-parent"></span>Open Parent Directory</a></p>
|
||||
<hr>
|
||||
<p>
|
||||
<a href="%parent_url%"><span class="open-parent"></span>Open Parent Directory</a>
|
||||
</p>
|
||||
<hr />
|
||||
%contents%
|
||||
<hr>
|
||||
<hr />
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta charset="UTF-8" />
|
||||
<title>Error!</title>
|
||||
<style>
|
||||
:root {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta charset="UTF-8" />
|
||||
<title>About %browser_name%</title>
|
||||
<style>
|
||||
html {
|
||||
|
|
@ -23,8 +23,8 @@
|
|||
<body>
|
||||
<header>
|
||||
<picture>
|
||||
<source srcset="resource://icons/128x128/app-browser.png" media="(prefers-color-scheme: dark)">
|
||||
<img src="resource://icons/128x128/app-browser-dark.png">
|
||||
<source srcset="resource://icons/128x128/app-browser.png" media="(prefers-color-scheme: dark)" />
|
||||
<img src="resource://icons/128x128/app-browser-dark.png" />
|
||||
</picture>
|
||||
<h1>About %browser_name%</h1>
|
||||
</header>
|
||||
|
|
|
|||
|
|
@ -53,21 +53,9 @@ describe("ability to work with generic non-array objects", () => {
|
|||
}
|
||||
{
|
||||
const o = { length: 5, 0: "foo", 1: "bar", 3: "baz" };
|
||||
expect(Array.prototype.slice.call(o)).toEqual([
|
||||
"foo",
|
||||
"bar",
|
||||
undefined,
|
||||
"baz",
|
||||
undefined,
|
||||
]);
|
||||
expect(Array.prototype.slice.call(o)).toEqual(["foo", "bar", undefined, "baz", undefined]);
|
||||
expect(Array.prototype.slice.call(o, 0, 3)).toEqual(["foo", "bar", undefined]);
|
||||
expect(Array.prototype.slice.call(o, 0, 15)).toEqual([
|
||||
"foo",
|
||||
"bar",
|
||||
undefined,
|
||||
"baz",
|
||||
undefined,
|
||||
]);
|
||||
expect(Array.prototype.slice.call(o, 0, 15)).toEqual(["foo", "bar", undefined, "baz", undefined]);
|
||||
|
||||
expect(Array.prototype.slice.call(o, 1)).toEqual(["bar", undefined, "baz", undefined]);
|
||||
expect(Array.prototype.slice.call(o, 15)).toEqual([]);
|
||||
|
|
@ -89,13 +77,9 @@ describe("ability to work with generic non-array objects", () => {
|
|||
expect(Array.prototype.join.call({ length: "foo" })).toBe("");
|
||||
expect(Array.prototype.join.call({ length: 3 })).toBe(",,");
|
||||
expect(Array.prototype.join.call({ length: 2, 0: "foo", 1: "bar" })).toBe("foo,bar");
|
||||
expect(Array.prototype.join.call({ length: 2, 0: "foo", 1: "bar", 2: "baz" })).toBe(
|
||||
"foo,bar"
|
||||
);
|
||||
expect(Array.prototype.join.call({ length: 2, 0: "foo", 1: "bar", 2: "baz" })).toBe("foo,bar");
|
||||
expect(Array.prototype.join.call({ length: 3, 1: "bar" }, "~")).toBe("~bar~");
|
||||
expect(Array.prototype.join.call({ length: 3, 0: "foo", 1: "bar", 2: "baz" }, "~")).toBe(
|
||||
"foo~bar~baz"
|
||||
);
|
||||
expect(Array.prototype.join.call({ length: 3, 0: "foo", 1: "bar", 2: "baz" }, "~")).toBe("foo~bar~baz");
|
||||
});
|
||||
|
||||
test("toString", () => {
|
||||
|
|
@ -120,9 +104,7 @@ describe("ability to work with generic non-array objects", () => {
|
|||
expect(Array.prototype.lastIndexOf.call({ length: 1, 2: "foo" }, "foo")).toBe(-1);
|
||||
expect(Array.prototype.lastIndexOf.call({ length: 5, 2: "foo" }, "foo")).toBe(2);
|
||||
expect(Array.prototype.lastIndexOf.call({ length: 5, 2: "foo", 4: "foo" }, "foo")).toBe(4);
|
||||
expect(Array.prototype.lastIndexOf.call({ length: 5, 2: "foo", 4: "foo" }, "foo", -2)).toBe(
|
||||
2
|
||||
);
|
||||
expect(Array.prototype.lastIndexOf.call({ length: 5, 2: "foo", 4: "foo" }, "foo", -2)).toBe(2);
|
||||
});
|
||||
|
||||
test("includes", () => {
|
||||
|
|
@ -279,13 +261,7 @@ describe("ability to work with generic non-array objects", () => {
|
|||
3: "baz",
|
||||
[Symbol.isConcatSpreadable]: true,
|
||||
};
|
||||
expect(Array.prototype.concat.call(spreadable)).toEqual([
|
||||
"foo",
|
||||
"bar",
|
||||
undefined,
|
||||
"baz",
|
||||
undefined,
|
||||
]);
|
||||
expect(Array.prototype.concat.call(spreadable)).toEqual(["foo", "bar", undefined, "baz", undefined]);
|
||||
expect(Array.prototype.concat.call(spreadable, [1, 2])).toEqual([
|
||||
"foo",
|
||||
"bar",
|
||||
|
|
|
|||
|
|
@ -51,12 +51,6 @@ describe("normal behavior", () => {
|
|||
return arr.filter(el => el.toLowerCase().indexOf(query.toLowerCase()) !== -1);
|
||||
};
|
||||
expect(filterItems(fruits, "Berry")).toEqual(["Blueberry", "Raspberry"]);
|
||||
expect(filterItems(fruits, "P")).toEqual([
|
||||
"Apple",
|
||||
"Grape",
|
||||
"Peach",
|
||||
"Pineapple",
|
||||
"Raspberry",
|
||||
]);
|
||||
expect(filterItems(fruits, "P")).toEqual(["Apple", "Grape", "Peach", "Pineapple", "Raspberry"]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -32,11 +32,7 @@ describe("normal behavior", () => {
|
|||
});
|
||||
|
||||
test("can map based on callback return value", () => {
|
||||
expect(
|
||||
[undefined, null, true, "foo", 42, {}].map(
|
||||
(value, index) => "" + index + " -> " + value
|
||||
)
|
||||
).toEqual([
|
||||
expect([undefined, null, true, "foo", 42, {}].map((value, index) => "" + index + " -> " + value)).toEqual([
|
||||
"0 -> undefined",
|
||||
"1 -> null",
|
||||
"2 -> true",
|
||||
|
|
|
|||
|
|
@ -20,38 +20,12 @@ describe("Array.prototype.sort", () => {
|
|||
|
||||
// mix of data, including empty slots and undefined
|
||||
arr = ["2", Infinity, null, null, , undefined, 5, , undefined, null, 54, "5"];
|
||||
expect(arr.sort()).toEqual([
|
||||
"2",
|
||||
5,
|
||||
"5",
|
||||
54,
|
||||
Infinity,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
undefined,
|
||||
undefined,
|
||||
,
|
||||
,
|
||||
]);
|
||||
expect(arr.sort()).toEqual(["2", 5, "5", 54, Infinity, null, null, null, undefined, undefined, , ,]);
|
||||
expect(arr.length).toEqual(12);
|
||||
|
||||
// undefined compare function
|
||||
arr = ["2", Infinity, null, null, , undefined, 5n, , undefined, null, 54, "5"];
|
||||
expect(arr.sort(undefined)).toEqual([
|
||||
"2",
|
||||
5n,
|
||||
"5",
|
||||
54,
|
||||
Infinity,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
undefined,
|
||||
undefined,
|
||||
,
|
||||
,
|
||||
]);
|
||||
expect(arr.sort(undefined)).toEqual(["2", 5n, "5", 54, Infinity, null, null, null, undefined, undefined, , ,]);
|
||||
expect(arr.length).toEqual(12);
|
||||
|
||||
// numeric data with compare function to sort numerically
|
||||
|
|
@ -123,10 +97,7 @@ describe("Array.prototype.sort", () => {
|
|||
expect([].sort(expectNoCallCompareFunction)).toEqual([]);
|
||||
expect([1].sort(expectNoCallCompareFunction)).toEqual([1]);
|
||||
expect([1, undefined].sort(expectNoCallCompareFunction)).toEqual([1, undefined]);
|
||||
expect([undefined, undefined].sort(expectNoCallCompareFunction)).toEqual([
|
||||
undefined,
|
||||
undefined,
|
||||
]);
|
||||
expect([undefined, undefined].sort(expectNoCallCompareFunction)).toEqual([undefined, undefined]);
|
||||
expect([, , 1, ,].sort(expectNoCallCompareFunction)).toEqual([1, , , ,]);
|
||||
expect([undefined, , 1, , undefined, ,].sort(expectNoCallCompareFunction)).toEqual([
|
||||
1,
|
||||
|
|
|
|||
|
|
@ -65,8 +65,6 @@ describe("normal behavior", () => {
|
|||
expect([12, 34].toLocaleString("ar-u-nu-arab")).toBe("\u0661\u0662,\u0663\u0664");
|
||||
|
||||
expect([0.234].toLocaleString("en", { style: "percent" })).toBe("23%");
|
||||
expect([0.234].toLocaleString("ar-u-nu-arab", { style: "percent" })).toBe(
|
||||
"\u0662\u0663\u066a\u061c"
|
||||
);
|
||||
expect([0.234].toLocaleString("ar-u-nu-arab", { style: "percent" })).toBe("\u0662\u0663\u066a\u061c");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,8 +27,5 @@ test("invalid ArrayBuffer maximum size option", () => {
|
|||
test("ArrayBuffer size exceeds maximum size", () => {
|
||||
expect(() => {
|
||||
new ArrayBuffer(10, { maxByteLength: 5 });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"ArrayBuffer byte length of 10 exceeds the max byte length of 5"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "ArrayBuffer byte length of 10 exceeds the max byte length of 5");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,10 +36,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
buffer.resize(11);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"ArrayBuffer byte length of 11 exceeds the max byte length of 10"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "ArrayBuffer byte length of 11 exceeds the max byte length of 10");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,7 @@ describe("errors", () => {
|
|||
test("called without new", () => {
|
||||
expect(() => {
|
||||
AsyncDisposableStack();
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"AsyncDisposableStack constructor must be called with 'new'"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "AsyncDisposableStack constructor must be called with 'new'");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,5 @@ test("length is 0", () => {
|
|||
});
|
||||
|
||||
test("is the same as disposeAsync", () => {
|
||||
expect(AsyncDisposableStack.prototype[Symbol.asyncDispose]).toBe(
|
||||
AsyncDisposableStack.prototype.disposeAsync
|
||||
);
|
||||
expect(AsyncDisposableStack.prototype[Symbol.asyncDispose]).toBe(AsyncDisposableStack.prototype.disposeAsync);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -80,9 +80,6 @@ describe("basic functionality", () => {
|
|||
},
|
||||
});
|
||||
|
||||
expect(async () => await stack.disposeAsync()).toThrowWithMessage(
|
||||
ExpectationError,
|
||||
"fail in dispose"
|
||||
);
|
||||
expect(async () => await stack.disposeAsync()).toThrowWithMessage(ExpectationError, "fail in dispose");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -54,9 +54,6 @@ describe("throws errors", () => {
|
|||
await stack.disposeAsync();
|
||||
expect(stack.disposed).toBeTrue();
|
||||
|
||||
expect(() => stack.move()).toThrowWithMessage(
|
||||
ReferenceError,
|
||||
"AsyncDisposableStack already disposed values"
|
||||
);
|
||||
expect(() => stack.move()).toThrowWithMessage(ReferenceError, "AsyncDisposableStack already disposed values");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -53,10 +53,7 @@ describe("throws errors", () => {
|
|||
test("if added object does not have a dispose method throws type error", () => {
|
||||
const stack = new AsyncDisposableStack();
|
||||
[{}, [], { f() {} }].forEach(value => {
|
||||
expect(() => stack.use(value)).toThrowWithMessage(
|
||||
TypeError,
|
||||
"does not have dispose method"
|
||||
);
|
||||
expect(() => stack.use(value)).toThrowWithMessage(TypeError, "does not have dispose method");
|
||||
});
|
||||
|
||||
expect(stack.disposed).toBeFalse();
|
||||
|
|
|
|||
|
|
@ -105,9 +105,7 @@ describe("correct behaviour", () => {
|
|||
unhandledExceptionGenerator
|
||||
.next("bad10")
|
||||
.then(() => {
|
||||
expect().fail(
|
||||
"Unhandled exception generator did NOT throw an unhandled exception."
|
||||
);
|
||||
expect().fail("Unhandled exception generator did NOT throw an unhandled exception.");
|
||||
})
|
||||
.catch(e => {
|
||||
expect(e).toBe(1337);
|
||||
|
|
@ -123,9 +121,7 @@ describe("correct behaviour", () => {
|
|||
expect(iteratorResult.done).toBeTrue();
|
||||
})
|
||||
.catch(e => {
|
||||
expect().fail(
|
||||
"Unhandled exception generator threw an unhandled exception in Completed state."
|
||||
);
|
||||
expect().fail("Unhandled exception generator threw an unhandled exception in Completed state.");
|
||||
});
|
||||
runQueuedPromiseJobs();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,10 +21,7 @@ describe("errors", () => {
|
|||
expect(() => {
|
||||
const typedArray = new Float32Array(4);
|
||||
Atomics.notify(typedArray, 0, 0);
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Typed array Float32Array element type is not Int32 or BigInt64"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Typed array Float32Array element type is not Int32 or BigInt64");
|
||||
});
|
||||
|
||||
test("invalid index", () => {
|
||||
|
|
|
|||
|
|
@ -21,10 +21,7 @@ describe("errors", () => {
|
|||
expect(() => {
|
||||
const typedArray = new Float32Array(4);
|
||||
Atomics.wait(typedArray, 0, 0, 0);
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Typed array Float32Array element type is not Int32 or BigInt64"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Typed array Float32Array element type is not Int32 or BigInt64");
|
||||
});
|
||||
|
||||
test("non-shared ArrayBuffer", () => {
|
||||
|
|
|
|||
|
|
@ -21,10 +21,7 @@ describe("errors", () => {
|
|||
expect(() => {
|
||||
const typedArray = new Float32Array(4);
|
||||
Atomics.waitAsync(typedArray, 0, 0, 0);
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Typed array Float32Array element type is not Int32 or BigInt64"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Typed array Float32Array element type is not Int32 or BigInt64");
|
||||
});
|
||||
|
||||
test("non-shared ArrayBuffer", () => {
|
||||
|
|
|
|||
|
|
@ -33,36 +33,22 @@ test("integer digits", () => {
|
|||
|
||||
expect(1n.toLocaleString("ar-u-nu-arab", { minimumIntegerDigits: 2 })).toBe("\u0660\u0661");
|
||||
expect(12n.toLocaleString("ar-u-nu-arab", { minimumIntegerDigits: 2 })).toBe("\u0661\u0662");
|
||||
expect(123n.toLocaleString("ar-u-nu-arab", { minimumIntegerDigits: 2 })).toBe(
|
||||
"\u0661\u0662\u0663"
|
||||
);
|
||||
expect(123n.toLocaleString("ar-u-nu-arab", { minimumIntegerDigits: 2 })).toBe("\u0661\u0662\u0663");
|
||||
});
|
||||
|
||||
test("significant digits", () => {
|
||||
expect(
|
||||
1n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })
|
||||
).toBe("1.000");
|
||||
expect(
|
||||
12n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })
|
||||
).toBe("12.00");
|
||||
expect(
|
||||
123n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })
|
||||
).toBe("123.0");
|
||||
expect(
|
||||
1234n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })
|
||||
).toBe("1,234");
|
||||
expect(
|
||||
12345n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })
|
||||
).toBe("12,345");
|
||||
expect(
|
||||
123456n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })
|
||||
).toBe("123,456");
|
||||
expect(
|
||||
1234567n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })
|
||||
).toBe("1,234,570");
|
||||
expect(
|
||||
1234561n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })
|
||||
).toBe("1,234,560");
|
||||
expect(1n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })).toBe("1.000");
|
||||
expect(12n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })).toBe("12.00");
|
||||
expect(123n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })).toBe("123.0");
|
||||
expect(1234n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })).toBe("1,234");
|
||||
expect(12345n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })).toBe("12,345");
|
||||
expect(123456n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })).toBe("123,456");
|
||||
expect(1234567n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })).toBe(
|
||||
"1,234,570"
|
||||
);
|
||||
expect(1234561n.toLocaleString("en", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 })).toBe(
|
||||
"1,234,560"
|
||||
);
|
||||
|
||||
expect(
|
||||
1n.toLocaleString("ar-u-nu-arab", {
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ describe("correct behavior", () => {
|
|||
expect(2n ** 3n).toBe(8n);
|
||||
expect(5n % 3n).toBe(2n);
|
||||
expect(
|
||||
45977665298704210987n +
|
||||
(714320987142450987412098743217984576n / 4598741987421098765327980n) * 987498743n
|
||||
45977665298704210987n + (714320987142450987412098743217984576n / 4598741987421098765327980n) * 987498743n
|
||||
).toBe(199365500239020623962n);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,7 @@ const doTest = (operatorName, executeOperation) => {
|
|||
|
||||
expect(() => {
|
||||
executeOperation(1n, value);
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
`Cannot use ${operatorName} operator with BigInt${messageSuffix}`
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, `Cannot use ${operatorName} operator with BigInt${messageSuffix}`);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,28 +2,19 @@ test("Issue #9336, integer overflow in get_view_value", () => {
|
|||
const dataView = new DataView(new ArrayBuffer(16));
|
||||
expect(() => {
|
||||
dataView.getUint32(0xfffffffc);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Data view byte offset 4294967292 is out of range for buffer with length 16"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "Data view byte offset 4294967292 is out of range for buffer with length 16");
|
||||
});
|
||||
|
||||
test("Issue #9338, integer overflow in set_view_value", () => {
|
||||
const dataView = new DataView(new ArrayBuffer(16));
|
||||
expect(() => {
|
||||
dataView.setUint32(0xfffffffc, 0);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Data view byte offset 4294967292 is out of range for buffer with length 16"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "Data view byte offset 4294967292 is out of range for buffer with length 16");
|
||||
});
|
||||
|
||||
test("Issue #9338, integer overflow in set_view_value - zero-length DataView", () => {
|
||||
const dataView = new DataView(new ArrayBuffer(4), 4);
|
||||
expect(() => {
|
||||
dataView.setUint32(0xfffffffc, 0);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Data view byte offset 4294967292 is out of range for buffer with length 0"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "Data view byte offset 4294967292 is out of range for buffer with length 0");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,9 +25,7 @@ test("basic functionality", () => {
|
|||
expect(Date.parse("2024-01-08 9:00Z")).toBe(1704704400000);
|
||||
expect(Date.parse("Wed, 17 Jan 2024 11:36:34 +0000")).toBe(1705491394000);
|
||||
expect(Date.parse("Thu, 09 Jan 2025 23:00:00")).toBe(1736485200000);
|
||||
expect(Date.parse("Sun Jan 21 2024 21:11:31 GMT +0100 (Central European Standard Time)")).toBe(
|
||||
1705867891000
|
||||
);
|
||||
expect(Date.parse("Sun Jan 21 2024 21:11:31 GMT +0100 (Central European Standard Time)")).toBe(1705867891000);
|
||||
expect(Date.parse("05 Jul 2024 00:00")).toBe(1720155600000);
|
||||
expect(Date.parse("05 Jul 2024")).toBe(1720155600000);
|
||||
expect(Date.parse("05 July 2024")).toBe(1720155600000);
|
||||
|
|
|
|||
|
|
@ -73,9 +73,7 @@ test("canonical format: ECMA date time string format", () => {
|
|||
expect("1980-10-01T10:34:56.789Z").toBe(new Date("1980-10T12:34:56.789+0200").toISOString());
|
||||
expect("1980-10-11T10:34:56.789Z").toBe(new Date("1980-10-11T12:34:56.789+0200").toISOString());
|
||||
|
||||
expect("1980-10-11T10:34:54.789Z").toBe(
|
||||
new Date("1980-10-11T12:34:56.789+020002").toISOString()
|
||||
);
|
||||
expect("1980-10-11T10:34:54.789Z").toBe(new Date("1980-10-11T12:34:56.789+020002").toISOString());
|
||||
|
||||
// Timezone offset HH:MM
|
||||
expect("1980-01-01T10:34:00.000Z").toBe(new Date("1980T12:34+02:00").toISOString());
|
||||
|
|
@ -88,9 +86,7 @@ test("canonical format: ECMA date time string format", () => {
|
|||
|
||||
expect("1980-01-01T10:34:56.789Z").toBe(new Date("1980T12:34:56.789+02:00").toISOString());
|
||||
expect("1980-10-01T10:34:56.789Z").toBe(new Date("1980-10T12:34:56.789+02:00").toISOString());
|
||||
expect("1980-10-11T10:34:56.789Z").toBe(
|
||||
new Date("1980-10-11T12:34:56.789+02:00").toISOString()
|
||||
);
|
||||
expect("1980-10-11T10:34:56.789Z").toBe(new Date("1980-10-11T12:34:56.789+02:00").toISOString());
|
||||
|
||||
setTimeZone(originalTimeZone);
|
||||
});
|
||||
|
|
@ -109,12 +105,8 @@ test('canonical format: ECMA + ISO8601 extensions ("simplified" ISO8601)', () =>
|
|||
expect("1980-10-11T10:34:11.000Z").toBe(new Date("1980-10-11T12:34:56+02:00:45").toISOString());
|
||||
|
||||
expect("1980-01-01T10:34:11.789Z").toBe(new Date("1980T12:34:56.789+02:00:45").toISOString());
|
||||
expect("1980-10-01T10:34:11.789Z").toBe(
|
||||
new Date("1980-10T12:34:56.789+02:00:45").toISOString()
|
||||
);
|
||||
expect("1980-10-11T10:34:11.789Z").toBe(
|
||||
new Date("1980-10-11T12:34:56.789+02:00:45").toISOString()
|
||||
);
|
||||
expect("1980-10-01T10:34:11.789Z").toBe(new Date("1980-10T12:34:56.789+02:00:45").toISOString());
|
||||
expect("1980-10-11T10:34:11.789Z").toBe(new Date("1980-10-11T12:34:56.789+02:00:45").toISOString());
|
||||
|
||||
// The ECMA date-time string format requires literal uppercase 'T' and 'Z'.
|
||||
// Chrome also accepts lowercase.
|
||||
|
|
@ -126,37 +118,19 @@ test('canonical format: ECMA + ISO8601 extensions ("simplified" ISO8601)', () =>
|
|||
// Timezone offset HH:MM:SS.Ns
|
||||
expect("1980-01-01T10:33:14.322Z").toBe(new Date("1980T12:34+02:00:45.678").toISOString());
|
||||
expect("1980-10-01T10:33:14.322Z").toBe(new Date("1980-10T12:34+02:00:45.678").toISOString());
|
||||
expect("1980-10-11T10:33:14.322Z").toBe(
|
||||
new Date("1980-10-11T12:34+02:00:45.678").toISOString()
|
||||
);
|
||||
expect("1980-10-11T10:33:14.322Z").toBe(new Date("1980-10-11T12:34+02:00:45.678").toISOString());
|
||||
|
||||
expect("1980-01-01T10:34:10.322Z").toBe(new Date("1980T12:34:56+02:00:45.678").toISOString());
|
||||
expect("1980-10-01T10:34:10.322Z").toBe(
|
||||
new Date("1980-10T12:34:56+02:00:45.678").toISOString()
|
||||
);
|
||||
expect("1980-10-11T10:34:10.322Z").toBe(
|
||||
new Date("1980-10-11T12:34:56+02:00:45.678").toISOString()
|
||||
);
|
||||
expect("1980-10-01T10:34:10.322Z").toBe(new Date("1980-10T12:34:56+02:00:45.678").toISOString());
|
||||
expect("1980-10-11T10:34:10.322Z").toBe(new Date("1980-10-11T12:34:56+02:00:45.678").toISOString());
|
||||
|
||||
expect("1980-01-01T10:34:11.111Z").toBe(
|
||||
new Date("1980T12:34:56.789+02:00:45.678").toISOString()
|
||||
);
|
||||
expect("1980-10-01T10:34:11.111Z").toBe(
|
||||
new Date("1980-10T12:34:56.789+02:00:45.678").toISOString()
|
||||
);
|
||||
expect("1980-10-11T10:34:11.111Z").toBe(
|
||||
new Date("1980-10-11T12:34:56.789+02:00:45.678").toISOString()
|
||||
);
|
||||
expect("1980-01-01T10:34:11.111Z").toBe(new Date("1980T12:34:56.789+02:00:45.678").toISOString());
|
||||
expect("1980-10-01T10:34:11.111Z").toBe(new Date("1980-10T12:34:56.789+02:00:45.678").toISOString());
|
||||
expect("1980-10-11T10:34:11.111Z").toBe(new Date("1980-10-11T12:34:56.789+02:00:45.678").toISOString());
|
||||
|
||||
expect("1980-01-01T10:34:11.666Z").toBe(
|
||||
new Date("1980T12:34:56.789+02:00:45.123456879").toISOString()
|
||||
);
|
||||
expect("1980-10-01T10:34:11.666Z").toBe(
|
||||
new Date("1980-10T12:34:56.789+02:00:45.123456879").toISOString()
|
||||
);
|
||||
expect("1980-10-11T10:34:11.666Z").toBe(
|
||||
new Date("1980-10-11T12:34:56.789+02:00:45.123456879").toISOString()
|
||||
);
|
||||
expect("1980-01-01T10:34:11.666Z").toBe(new Date("1980T12:34:56.789+02:00:45.123456879").toISOString());
|
||||
expect("1980-10-01T10:34:11.666Z").toBe(new Date("1980-10T12:34:56.789+02:00:45.123456879").toISOString());
|
||||
expect("1980-10-11T10:34:11.666Z").toBe(new Date("1980-10-11T12:34:56.789+02:00:45.123456879").toISOString());
|
||||
|
||||
// Expanded years https://tc39.es/ecma262/#sec-expanded-years
|
||||
expect("2023-01-01T00:00:00.000Z").toBe(new Date("+002023").toISOString());
|
||||
|
|
@ -168,40 +142,20 @@ test('canonical format: ECMA + ISO8601 extensions ("simplified" ISO8601)', () =>
|
|||
expect("2023-10-11T19:34:56.789Z").toBe(new Date("+002023-10-11T12:34:56.789").toISOString());
|
||||
expect("2023-10-11T12:34:56.000Z").toBe(new Date("+002023-10-11T12:34:56Z").toISOString());
|
||||
expect("2023-10-11T12:34:56.789Z").toBe(new Date("+002023-10-11T12:34:56.789Z").toISOString());
|
||||
expect("2023-10-11T10:34:56.789Z").toBe(
|
||||
new Date("+002023-10-11T12:34:56.789+0200").toISOString()
|
||||
);
|
||||
expect("2023-10-11T10:34:56.789Z").toBe(
|
||||
new Date("+002023-10-11T12:34:56.789+02:00").toISOString()
|
||||
);
|
||||
expect("2023-10-11T10:34:11.666Z").toBe(
|
||||
new Date("+002023-10-11T12:34:56.789+02:00:45.123").toISOString()
|
||||
);
|
||||
expect("2023-10-11T10:34:11.666Z").toBe(
|
||||
new Date("+002023-10-11T12:34:56.789+02:00:45.123456789").toISOString()
|
||||
);
|
||||
expect("2023-10-11T10:34:56.789Z").toBe(new Date("+002023-10-11T12:34:56.789+0200").toISOString());
|
||||
expect("2023-10-11T10:34:56.789Z").toBe(new Date("+002023-10-11T12:34:56.789+02:00").toISOString());
|
||||
expect("2023-10-11T10:34:11.666Z").toBe(new Date("+002023-10-11T12:34:56.789+02:00:45.123").toISOString());
|
||||
expect("2023-10-11T10:34:11.666Z").toBe(new Date("+002023-10-11T12:34:56.789+02:00:45.123456789").toISOString());
|
||||
|
||||
expect("-002023-10-11T00:00:00.000Z").toBe(new Date("-002023-10-11").toISOString());
|
||||
expect("-002023-10-11T20:46:28.000Z").toBe(new Date("-002023-10-11T12:34").toISOString());
|
||||
expect("-002023-10-11T20:47:24.000Z").toBe(new Date("-002023-10-11T12:34:56").toISOString());
|
||||
expect("-002023-10-11T20:47:24.789Z").toBe(
|
||||
new Date("-002023-10-11T12:34:56.789").toISOString()
|
||||
);
|
||||
expect("-002023-10-11T10:34:56.789Z").toBe(
|
||||
new Date("-002023-10-11T12:34:56.789+0200").toISOString()
|
||||
);
|
||||
expect("-002023-10-11T10:34:56.789Z").toBe(
|
||||
new Date("-002023-10-11T12:34:56.789+02:00").toISOString()
|
||||
);
|
||||
expect("-002023-10-11T10:34:11.789Z").toBe(
|
||||
new Date("-002023-10-11T12:34:56.789+02:00:45").toISOString()
|
||||
);
|
||||
expect("-002023-10-11T10:34:11.666Z").toBe(
|
||||
new Date("-002023-10-11T12:34:56.789+02:00:45.123").toISOString()
|
||||
);
|
||||
expect("-002023-10-11T10:34:11.666Z").toBe(
|
||||
new Date("-002023-10-11T12:34:56.789+02:00:45.123456789").toISOString()
|
||||
);
|
||||
expect("-002023-10-11T20:47:24.789Z").toBe(new Date("-002023-10-11T12:34:56.789").toISOString());
|
||||
expect("-002023-10-11T10:34:56.789Z").toBe(new Date("-002023-10-11T12:34:56.789+0200").toISOString());
|
||||
expect("-002023-10-11T10:34:56.789Z").toBe(new Date("-002023-10-11T12:34:56.789+02:00").toISOString());
|
||||
expect("-002023-10-11T10:34:11.789Z").toBe(new Date("-002023-10-11T12:34:56.789+02:00:45").toISOString());
|
||||
expect("-002023-10-11T10:34:11.666Z").toBe(new Date("-002023-10-11T12:34:56.789+02:00:45.123").toISOString());
|
||||
expect("-002023-10-11T10:34:11.666Z").toBe(new Date("-002023-10-11T12:34:56.789+02:00:45.123456789").toISOString());
|
||||
|
||||
expect("0000-02-03T12:34:56.789Z").toBe(new Date("+000000-02-03T12:34:56.789Z").toISOString());
|
||||
|
||||
|
|
@ -219,9 +173,7 @@ test("canonical format: Date.toString", () => {
|
|||
const originalTimeZone = setTimeZone("America/Vancouver");
|
||||
|
||||
expect("1999-12-08T12:34:56.000Z").toBe(new Date("Wed Dec 08 1999 12:34:56 GMT").toISOString()); // Clint Eastwood elected mayor of Carmel
|
||||
expect("1999-12-08T20:34:56.000Z").toBe(
|
||||
new Date("Wed Dec 08 1999 12:34:56 GMT-0800").toISOString()
|
||||
);
|
||||
expect("1999-12-08T20:34:56.000Z").toBe(new Date("Wed Dec 08 1999 12:34:56 GMT-0800").toISOString());
|
||||
expect("1999-12-08T20:34:56.000Z").toBe(
|
||||
new Date("Wed Dec 08 1999 12:34:56 GMT-0800 (Pacific Standard Time)").toISOString()
|
||||
);
|
||||
|
|
@ -234,12 +186,8 @@ test("canonical format: Date.toString", () => {
|
|||
});
|
||||
|
||||
test("canonical format: Date.toUTCString", () => {
|
||||
expect("1999-12-08T08:00:00.000Z").toBe(
|
||||
new Date("Wed, 08 Dec 1999 08:00:00 GMT").toISOString()
|
||||
);
|
||||
expect("1999-12-08T08:00:00.000Z").toBe(
|
||||
new Date("Thu, 08 Dec 1999 08:00:00 GMT").toISOString()
|
||||
); // Wrong weekday is ignored
|
||||
expect("1999-12-08T08:00:00.000Z").toBe(new Date("Wed, 08 Dec 1999 08:00:00 GMT").toISOString());
|
||||
expect("1999-12-08T08:00:00.000Z").toBe(new Date("Thu, 08 Dec 1999 08:00:00 GMT").toISOString()); // Wrong weekday is ignored
|
||||
});
|
||||
|
||||
test("ambiguous date: 1 number", () => {
|
||||
|
|
@ -573,12 +521,8 @@ test("timezone offset", () => {
|
|||
expect("2019-07-18T08:01:00.000Z").toBe(new Date("07/18/2019 11:22 +3:21").toISOString());
|
||||
|
||||
expect("2019-07-18T08:00:51.000Z").toBe(new Date("07/18/2019 11:22 +03:21:09").toISOString()); // Chrome and Firefox do not support seconds in timezone offset
|
||||
expect("2019-07-18T08:00:50.877Z").toBe(
|
||||
new Date("07/18/2019 11:22 +03:21:09.123").toISOString()
|
||||
);
|
||||
expect("2019-07-18T08:00:50.877Z").toBe(
|
||||
new Date("07/18/2019 11:22 +03:21:09.12345678").toISOString()
|
||||
); // Truncate to milliseconds
|
||||
expect("2019-07-18T08:00:50.877Z").toBe(new Date("07/18/2019 11:22 +03:21:09.123").toISOString());
|
||||
expect("2019-07-18T08:00:50.877Z").toBe(new Date("07/18/2019 11:22 +03:21:09.12345678").toISOString()); // Truncate to milliseconds
|
||||
|
||||
expect("2019-07-18T08:22:00.000Z").toBe(new Date("07/18/2019 11:22 GMT+03").toISOString());
|
||||
expect("2019-07-18T08:22:00.000Z").toBe(new Date("07/18/2019 11:22 UTC+03").toISOString());
|
||||
|
|
@ -654,9 +598,7 @@ test("us timezones", () => {
|
|||
expect("2025-02-23T12:34:00.000Z").toBe(new Date("23 feb 2025 12:34 UTC").toISOString());
|
||||
expect("2025-02-23T12:34:00.000Z").toBe(new Date("23 feb 2025 12:34 Z").toISOString());
|
||||
|
||||
expect("2025-02-23T18:34:00.000Z").toBe(
|
||||
new Date("23 EST feb PDT 2025 CST 12:34").toISOString()
|
||||
); // For multiple occurrences, the last one wins
|
||||
expect("2025-02-23T18:34:00.000Z").toBe(new Date("23 EST feb PDT 2025 CST 12:34").toISOString()); // For multiple occurrences, the last one wins
|
||||
expect("2022-02-12T20:34:00.000Z").toBe(new Date("2/12/22 12:34 +0100 PST").toISOString()); // Timezone name wins after timezone offset.
|
||||
|
||||
expect(Date.parse("12-Dec-2024 15:30:00 PT")).toBeNaN(); // Non-qualified timezone names ("PT"="Pacific Time"; no S/D) are not recognized
|
||||
|
|
@ -682,9 +624,7 @@ test("weekdays", () => {
|
|||
expect("2024-12-05T08:00:00.000Z").toBe(new Date("Thurnip Dec 5 2024").toISOString());
|
||||
expect("2024-12-05T08:00:00.000Z").toBe(new Date("Mon Dec 5 2024").toISOString()); // Incorrect weekday is ignored.
|
||||
expect("2024-12-05T08:00:00.000Z").toBe(new Date("Theater Dec 5 2024").toISOString()); // Anything before the first number is ignored.
|
||||
expect("2024-12-05T08:00:00.000Z").toBe(
|
||||
new Date("Mon Tue Wed Dec Thu YMCA 5 2024").toISOString()
|
||||
);
|
||||
expect("2024-12-05T08:00:00.000Z").toBe(new Date("Mon Tue Wed Dec Thu YMCA 5 2024").toISOString());
|
||||
|
||||
expect(Date.parse("Mon Dec Tue 5 Wed 2024")).toBeNaN(); // Weekday names (or any other word) fail after the first number
|
||||
expect(Date.parse("Mon Dec Tue 5 Wed 2024 Thu")).toBeNaN();
|
||||
|
|
@ -696,15 +636,9 @@ test("timezone name", () => {
|
|||
// Compatible with Chrome and Firefox. Anything that is not a closing bracket following an open bracket is ignored.
|
||||
const originalTimeZone = setTimeZone("America/Vancouver");
|
||||
|
||||
expect("2020-12-05T20:23:00.000Z").toBe(
|
||||
new Date("Thu Dec 5 2020 12:23 -0800 (America/Vancouver)").toISOString()
|
||||
);
|
||||
expect("2020-12-05T20:23:00.000Z").toBe(
|
||||
new Date("Thu Dec 5 2020 12:23 -0800 (America/Chicago)").toISOString()
|
||||
); // Incorrect time zone name.
|
||||
expect("2020-12-05T20:23:00.000Z").toBe(
|
||||
new Date("Thu Dec 5 2020 12:23 (America/Chicago)").toISOString()
|
||||
); // Missing timezone offset makes it local time. Timezone name is ignored.
|
||||
expect("2020-12-05T20:23:00.000Z").toBe(new Date("Thu Dec 5 2020 12:23 -0800 (America/Vancouver)").toISOString());
|
||||
expect("2020-12-05T20:23:00.000Z").toBe(new Date("Thu Dec 5 2020 12:23 -0800 (America/Chicago)").toISOString()); // Incorrect time zone name.
|
||||
expect("2020-12-05T20:23:00.000Z").toBe(new Date("Thu Dec 5 2020 12:23 (America/Chicago)").toISOString()); // Missing timezone offset makes it local time. Timezone name is ignored.
|
||||
expect("2020-12-05T20:23:00.000Z").toBe(
|
||||
new Date(
|
||||
"Thu Dec 5 2020 12:23 -0800 (Whatever alpha 123 numerics or punctuation $# ({}[] works )"
|
||||
|
|
@ -731,9 +665,7 @@ test("garbage", () => {
|
|||
// Accept punctuation at any point before time.
|
||||
// Firefox fails in some conditions before time.
|
||||
// Chrome is finnicky on interior punctuation.
|
||||
expect("2204-01-20T02:32:00.000Z").toBe(
|
||||
new Date("2204 //. -/, Jan ./- 20 ..- 10:32 GMT+08:00").toISOString()
|
||||
);
|
||||
expect("2204-01-20T02:32:00.000Z").toBe(new Date("2204 //. -/, Jan ./- 20 ..- 10:32 GMT+08:00").toISOString());
|
||||
|
||||
// Chrome does not accept punctuation after time. Firefox accepts some. We accept punctuation.
|
||||
expect("2204-01-29T18:30:00.000Z").toBe(new Date("2204 Jan 29 10:30 /--/").toISOString());
|
||||
|
|
@ -756,18 +688,10 @@ test("multiple month names", () => {
|
|||
const originalTimeZone = setTimeZone("America/Vancouver");
|
||||
|
||||
// Multiple month names are accepted. Last one wins.
|
||||
expect("1981-03-23T22:56:00.000Z").toBe(
|
||||
new Date("March 23, 1981 14:56 GMT-08:00").toISOString()
|
||||
);
|
||||
expect("1981-04-23T22:56:00.000Z").toBe(
|
||||
new Date("March 23, Apr 1981 14:56 GMT-08:00").toISOString()
|
||||
);
|
||||
expect("1981-05-23T22:56:00.000Z").toBe(
|
||||
new Date("March 23, Apron 1981 mAY 14:56 GMT-08:00").toISOString()
|
||||
);
|
||||
expect("1981-06-23T22:56:00.000Z").toBe(
|
||||
new Date("March 23, Apron 1981 mAY 14:56 junuary GMT-08:00").toISOString()
|
||||
);
|
||||
expect("1981-03-23T22:56:00.000Z").toBe(new Date("March 23, 1981 14:56 GMT-08:00").toISOString());
|
||||
expect("1981-04-23T22:56:00.000Z").toBe(new Date("March 23, Apr 1981 14:56 GMT-08:00").toISOString());
|
||||
expect("1981-05-23T22:56:00.000Z").toBe(new Date("March 23, Apron 1981 mAY 14:56 GMT-08:00").toISOString());
|
||||
expect("1981-06-23T22:56:00.000Z").toBe(new Date("March 23, Apron 1981 mAY 14:56 junuary GMT-08:00").toISOString());
|
||||
expect("1981-07-23T22:56:00.000Z").toBe(
|
||||
new Date("March 23, Apron 1981 mAY 14:56 junuary GMT-08:00 Julie").toISOString()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -45,12 +45,8 @@ describe("correct behavior", () => {
|
|||
});
|
||||
|
||||
test("dateStyle may be set", () => {
|
||||
expect(d0.toLocaleDateString("en", { dateStyle: "full", timeZone: "UTC" })).toBe(
|
||||
"Tuesday, December 7, 2021"
|
||||
);
|
||||
expect(d1.toLocaleDateString("en", { dateStyle: "full", timeZone: "UTC" })).toBe(
|
||||
"Monday, January 23, 1989"
|
||||
);
|
||||
expect(d0.toLocaleDateString("en", { dateStyle: "full", timeZone: "UTC" })).toBe("Tuesday, December 7, 2021");
|
||||
expect(d1.toLocaleDateString("en", { dateStyle: "full", timeZone: "UTC" })).toBe("Monday, January 23, 1989");
|
||||
|
||||
expect(d0.toLocaleDateString("ar-u-nu-arab", { dateStyle: "full", timeZone: "UTC" })).toBe(
|
||||
"الثلاثاء، ٧ ديسمبر ٢٠٢١"
|
||||
|
|
|
|||
|
|
@ -34,35 +34,23 @@ describe("correct behavior", () => {
|
|||
expect(d0.toLocaleString("en", { timeZone: "UTC" })).toBe("12/7/2021, 5:40:50 PM");
|
||||
expect(d1.toLocaleString("en", { timeZone: "UTC" })).toBe("1/23/1989, 7:08:09 AM");
|
||||
|
||||
expect(d0.toLocaleString("ar-u-nu-arab", { timeZone: "UTC" })).toBe(
|
||||
"٧/١٢/٢٠٢١، ٥:٤٠:٥٠ م"
|
||||
);
|
||||
expect(d1.toLocaleString("ar-u-nu-arab", { timeZone: "UTC" })).toBe(
|
||||
"٢٣/١/١٩٨٩، ٧:٠٨:٠٩ ص"
|
||||
);
|
||||
expect(d0.toLocaleString("ar-u-nu-arab", { timeZone: "UTC" })).toBe("٧/١٢/٢٠٢١، ٥:٤٠:٥٠ م");
|
||||
expect(d1.toLocaleString("ar-u-nu-arab", { timeZone: "UTC" })).toBe("٢٣/١/١٩٨٩، ٧:٠٨:٠٩ ص");
|
||||
});
|
||||
|
||||
test("dateStyle may be set", () => {
|
||||
expect(d0.toLocaleString("en", { dateStyle: "short", timeZone: "UTC" })).toBe("12/7/21");
|
||||
expect(d1.toLocaleString("en", { dateStyle: "short", timeZone: "UTC" })).toBe("1/23/89");
|
||||
|
||||
expect(d0.toLocaleString("ar-u-nu-arab", { dateStyle: "short", timeZone: "UTC" })).toBe(
|
||||
"٧/١٢/٢٠٢١"
|
||||
);
|
||||
expect(d1.toLocaleString("ar-u-nu-arab", { dateStyle: "short", timeZone: "UTC" })).toBe(
|
||||
"٢٣/١/١٩٨٩"
|
||||
);
|
||||
expect(d0.toLocaleString("ar-u-nu-arab", { dateStyle: "short", timeZone: "UTC" })).toBe("٧/١٢/٢٠٢١");
|
||||
expect(d1.toLocaleString("ar-u-nu-arab", { dateStyle: "short", timeZone: "UTC" })).toBe("٢٣/١/١٩٨٩");
|
||||
});
|
||||
|
||||
test("timeStyle may be set", () => {
|
||||
expect(d0.toLocaleString("en", { timeStyle: "short", timeZone: "UTC" })).toBe("5:40 PM");
|
||||
expect(d1.toLocaleString("en", { timeStyle: "short", timeZone: "UTC" })).toBe("7:08 AM");
|
||||
|
||||
expect(d0.toLocaleString("ar-u-nu-arab", { timeStyle: "short", timeZone: "UTC" })).toBe(
|
||||
"٥:٤٠ م"
|
||||
);
|
||||
expect(d1.toLocaleString("ar-u-nu-arab", { timeStyle: "short", timeZone: "UTC" })).toBe(
|
||||
"٧:٠٨ ص"
|
||||
);
|
||||
expect(d0.toLocaleString("ar-u-nu-arab", { timeStyle: "short", timeZone: "UTC" })).toBe("٥:٤٠ م");
|
||||
expect(d1.toLocaleString("ar-u-nu-arab", { timeStyle: "short", timeZone: "UTC" })).toBe("٧:٠٨ ص");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -45,18 +45,10 @@ describe("correct behavior", () => {
|
|||
});
|
||||
|
||||
test("timeStyle may be set", () => {
|
||||
expect(d0.toLocaleTimeString("en", { timeStyle: "long", timeZone: "UTC" })).toBe(
|
||||
"5:40:50 PM UTC"
|
||||
);
|
||||
expect(d1.toLocaleTimeString("en", { timeStyle: "long", timeZone: "UTC" })).toBe(
|
||||
"7:08:09 AM UTC"
|
||||
);
|
||||
expect(d0.toLocaleTimeString("en", { timeStyle: "long", timeZone: "UTC" })).toBe("5:40:50 PM UTC");
|
||||
expect(d1.toLocaleTimeString("en", { timeStyle: "long", timeZone: "UTC" })).toBe("7:08:09 AM UTC");
|
||||
|
||||
expect(d0.toLocaleTimeString("ar-u-nu-arab", { timeStyle: "long", timeZone: "UTC" })).toBe(
|
||||
"٥:٤٠:٥٠ م UTC"
|
||||
);
|
||||
expect(d1.toLocaleTimeString("ar-u-nu-arab", { timeStyle: "long", timeZone: "UTC" })).toBe(
|
||||
"٧:٠٨:٠٩ ص UTC"
|
||||
);
|
||||
expect(d0.toLocaleTimeString("ar-u-nu-arab", { timeStyle: "long", timeZone: "UTC" })).toBe("٥:٤٠:٥٠ م UTC");
|
||||
expect(d1.toLocaleTimeString("ar-u-nu-arab", { timeStyle: "long", timeZone: "UTC" })).toBe("٧:٠٨:٠٩ ص UTC");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -54,9 +54,6 @@ describe("throws errors", () => {
|
|||
stack.dispose();
|
||||
expect(stack.disposed).toBeTrue();
|
||||
|
||||
expect(() => stack.move()).toThrowWithMessage(
|
||||
ReferenceError,
|
||||
"DisposableStack already disposed values"
|
||||
);
|
||||
expect(() => stack.move()).toThrowWithMessage(ReferenceError, "DisposableStack already disposed values");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -53,10 +53,7 @@ describe("throws errors", () => {
|
|||
test("if added object does not have a dispose method throws type error", () => {
|
||||
const stack = new DisposableStack();
|
||||
[{}, [], { f() {} }].forEach(value => {
|
||||
expect(() => stack.use(value)).toThrowWithMessage(
|
||||
TypeError,
|
||||
"does not have dispose method"
|
||||
);
|
||||
expect(() => stack.use(value)).toThrowWithMessage(TypeError, "does not have dispose method");
|
||||
});
|
||||
|
||||
expect(stack.disposed).toBeFalse();
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@ describe("errors", () => {
|
|||
test("called without new", () => {
|
||||
expect(() => {
|
||||
FinalizationRegistry();
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"FinalizationRegistry constructor must be called with 'new'"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "FinalizationRegistry constructor must be called with 'new'");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -21,12 +21,8 @@ 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'; }")(false)).toBe(
|
||||
"bar"
|
||||
);
|
||||
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");
|
||||
expect(new Function("return typeof Function()")()).toBe("function");
|
||||
expect(new Function("x", "return function (y) { return x + y };")(1)(2)).toBe(3);
|
||||
|
||||
|
|
@ -49,10 +45,7 @@ describe("errors", () => {
|
|||
// FIXME: The position is odd though, I'd expect `line: 2, column: 2` and `line: 3, column: 1`...
|
||||
// > eval("\n[") // Uncaught exception: [SyntaxError] Unexpected token Eof. Expected BracketClose (line: 2, column: 2)
|
||||
// > eval("\n[\n") // Uncaught exception: [SyntaxError] Unexpected token Eof. Expected BracketClose (line: 2, column: 3)
|
||||
.toThrowWithMessage(
|
||||
SyntaxError,
|
||||
"Unexpected token Eof. Expected BracketClose (line: 2, column: 3)"
|
||||
);
|
||||
.toThrowWithMessage(SyntaxError, "Unexpected token Eof. Expected BracketClose (line: 2, column: 3)");
|
||||
});
|
||||
|
||||
test("parameters and body must be valid standalone", () => {
|
||||
|
|
|
|||
|
|
@ -39,12 +39,8 @@ describe("correct behavior", () => {
|
|||
expect({ *foo() {} }.foo.toString()).toBe("*foo() {}");
|
||||
expect({ async foo() {} }.foo.toString()).toBe("async foo() {}");
|
||||
expect({ async *foo() {} }.foo.toString()).toBe("async *foo() {}");
|
||||
expect(Object.getOwnPropertyDescriptor({ get foo() {} }, "foo").get.toString()).toBe(
|
||||
"get foo() {}"
|
||||
);
|
||||
expect(Object.getOwnPropertyDescriptor({ set foo(x) {} }, "foo").set.toString()).toBe(
|
||||
"set foo(x) {}"
|
||||
);
|
||||
expect(Object.getOwnPropertyDescriptor({ get foo() {} }, "foo").get.toString()).toBe("get foo() {}");
|
||||
expect(Object.getOwnPropertyDescriptor({ set foo(x) {} }, "foo").set.toString()).toBe("set foo(x) {}");
|
||||
});
|
||||
|
||||
test("arrow function", () => {
|
||||
|
|
@ -127,9 +123,9 @@ describe("correct behavior", () => {
|
|||
// Built-in functions
|
||||
expect(console.debug.toString()).toBe("function debug() { [native code] }");
|
||||
expect(Function.toString()).toBe("function Function() { [native code] }");
|
||||
expect(
|
||||
Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format").get.toString()
|
||||
).toBe("function get format() { [native code] }");
|
||||
expect(Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format").get.toString()).toBe(
|
||||
"function get format() { [native code] }"
|
||||
);
|
||||
|
||||
const values = [
|
||||
// Callable Proxy
|
||||
|
|
|
|||
|
|
@ -51,10 +51,7 @@ describe("errors", () => {
|
|||
["hello!", "+1", "+1:02", "+01:02:03"].forEach(timeZone => {
|
||||
expect(() => {
|
||||
new Intl.DateTimeFormat("en", { timeZone: timeZone });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
`${timeZone} is not a valid value for option timeZone`
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, `${timeZone} is not a valid value for option timeZone`);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -65,10 +62,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.DateTimeFormat("en", { era: "narrow", dateStyle: "long" });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Option era cannot be set when also providing dateStyle or timeStyle"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Option era cannot be set when also providing dateStyle or timeStyle");
|
||||
});
|
||||
|
||||
test("year option is invalid", () => {
|
||||
|
|
@ -78,10 +72,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.DateTimeFormat("en", { year: "numeric", dateStyle: "long" });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Option year cannot be set when also providing dateStyle or timeStyle"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Option year cannot be set when also providing dateStyle or timeStyle");
|
||||
});
|
||||
|
||||
test("month option is invalid", () => {
|
||||
|
|
@ -91,10 +82,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.DateTimeFormat("en", { month: "numeric", dateStyle: "long" });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Option month cannot be set when also providing dateStyle or timeStyle"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Option month cannot be set when also providing dateStyle or timeStyle");
|
||||
});
|
||||
|
||||
test("weekday option is invalid", () => {
|
||||
|
|
@ -104,10 +92,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.DateTimeFormat("en", { weekday: "narrow", dateStyle: "long" });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Option weekday cannot be set when also providing dateStyle or timeStyle"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Option weekday cannot be set when also providing dateStyle or timeStyle");
|
||||
});
|
||||
|
||||
test("day option is invalid", () => {
|
||||
|
|
@ -117,10 +102,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.DateTimeFormat("en", { day: "numeric", dateStyle: "long" });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Option day cannot be set when also providing dateStyle or timeStyle"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Option day cannot be set when also providing dateStyle or timeStyle");
|
||||
});
|
||||
|
||||
test("dayPeriod option is invalid", () => {
|
||||
|
|
@ -130,10 +112,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.DateTimeFormat("en", { dayPeriod: "narrow", dateStyle: "long" });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Option dayPeriod cannot be set when also providing dateStyle or timeStyle"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Option dayPeriod cannot be set when also providing dateStyle or timeStyle");
|
||||
});
|
||||
|
||||
test("hour option is invalid", () => {
|
||||
|
|
@ -143,10 +122,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.DateTimeFormat("en", { hour: "numeric", dateStyle: "long" });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Option hour cannot be set when also providing dateStyle or timeStyle"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Option hour cannot be set when also providing dateStyle or timeStyle");
|
||||
});
|
||||
|
||||
test("minute option is invalid", () => {
|
||||
|
|
@ -156,10 +132,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.DateTimeFormat("en", { minute: "numeric", dateStyle: "long" });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Option minute cannot be set when also providing dateStyle or timeStyle"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Option minute cannot be set when also providing dateStyle or timeStyle");
|
||||
});
|
||||
|
||||
test("second option is invalid", () => {
|
||||
|
|
@ -169,10 +142,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.DateTimeFormat("en", { second: "numeric", dateStyle: "long" });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Option second cannot be set when also providing dateStyle or timeStyle"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Option second cannot be set when also providing dateStyle or timeStyle");
|
||||
});
|
||||
|
||||
test("fractionalSecondDigits option is invalid", () => {
|
||||
|
|
@ -366,13 +336,11 @@ describe("normal behavior", () => {
|
|||
});
|
||||
|
||||
test("all valid timeZoneName options", () => {
|
||||
["short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"].forEach(
|
||||
timeZoneName => {
|
||||
["short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"].forEach(timeZoneName => {
|
||||
expect(() => {
|
||||
new Intl.DateTimeFormat("en", { timeZoneName: timeZoneName });
|
||||
}).not.toThrow();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("all valid formatMatcher options", () => {
|
||||
|
|
|
|||
|
|
@ -58,9 +58,7 @@ describe("errors", () => {
|
|||
);
|
||||
|
||||
expect(() => {
|
||||
formatter.format(
|
||||
new Temporal.PlainDateTime(1972, 1, 1, 8, 45, 56, 123, 345, 789, "gregory")
|
||||
);
|
||||
formatter.format(new Temporal.PlainDateTime(1972, 1, 1, 8, 45, 56, 123, 345, 789, "gregory"));
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Cannot format Temporal.PlainDateTime with calendar 'gregory' in locale with calendar 'iso8601'"
|
||||
|
|
|
|||
|
|
@ -65,18 +65,7 @@ describe("errors", () => {
|
|||
);
|
||||
|
||||
expect(() => {
|
||||
const plainDateTime = new Temporal.PlainDateTime(
|
||||
1972,
|
||||
1,
|
||||
1,
|
||||
8,
|
||||
45,
|
||||
56,
|
||||
123,
|
||||
345,
|
||||
789,
|
||||
"gregory"
|
||||
);
|
||||
const plainDateTime = new Temporal.PlainDateTime(1972, 1, 1, 8, 45, 56, 123, 345, 789, "gregory");
|
||||
formatter.formatRange(plainDateTime, plainDateTime);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
|
|
@ -98,19 +87,13 @@ describe("errors", () => {
|
|||
expect(() => {
|
||||
const plainDate = new Temporal.PlainDate(1972, 1, 1, "gregory");
|
||||
new Intl.DateTimeFormat().formatRange(plainDate, 0);
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Cannot format a date-time range with different date-time types"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Cannot format a date-time range with different date-time types");
|
||||
|
||||
expect(() => {
|
||||
const plainYearMonth = new Temporal.PlainYearMonth(1972, 1, "gregory");
|
||||
const plainMonthDay = new Temporal.PlainMonthDay(1, 1, "gregory");
|
||||
new Intl.DateTimeFormat().formatRange(plainYearMonth, plainMonthDay);
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Cannot format a date-time range with different date-time types"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Cannot format a date-time range with different date-time types");
|
||||
});
|
||||
|
||||
test("Temporal fields must overlap formatter", () => {
|
||||
|
|
@ -346,8 +329,6 @@ describe("Temporal objects", () => {
|
|||
test("Temporal.Instant", () => {
|
||||
const instant1 = new Temporal.Instant(601546251000000000n);
|
||||
const instant2 = new Temporal.Instant(1732740069000000000n);
|
||||
expect(formatter.formatRange(instant1, instant2)).toBe(
|
||||
"1989-01-23, 8:10:51 AM – 2024-11-27, 8:41:09 PM"
|
||||
);
|
||||
expect(formatter.formatRange(instant1, instant2)).toBe("1989-01-23, 8:10:51 AM – 2024-11-27, 8:41:09 PM");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -65,18 +65,7 @@ describe("errors", () => {
|
|||
);
|
||||
|
||||
expect(() => {
|
||||
const plainDateTime = new Temporal.PlainDateTime(
|
||||
1972,
|
||||
1,
|
||||
1,
|
||||
8,
|
||||
45,
|
||||
56,
|
||||
123,
|
||||
345,
|
||||
789,
|
||||
"gregory"
|
||||
);
|
||||
const plainDateTime = new Temporal.PlainDateTime(1972, 1, 1, 8, 45, 56, 123, 345, 789, "gregory");
|
||||
formatter.formatRangeToParts(plainDateTime, plainDateTime);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
|
|
@ -98,19 +87,13 @@ describe("errors", () => {
|
|||
expect(() => {
|
||||
const plainDate = new Temporal.PlainDate(1972, 1, 1, "gregory");
|
||||
new Intl.DateTimeFormat().formatRangeToParts(plainDate, 0);
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Cannot format a date-time range with different date-time types"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Cannot format a date-time range with different date-time types");
|
||||
|
||||
expect(() => {
|
||||
const plainYearMonth = new Temporal.PlainYearMonth(1972, 1, "gregory");
|
||||
const plainMonthDay = new Temporal.PlainMonthDay(1, 1, "gregory");
|
||||
new Intl.DateTimeFormat().formatRangeToParts(plainYearMonth, plainMonthDay);
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Cannot format a date-time range with different date-time types"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Cannot format a date-time range with different date-time types");
|
||||
});
|
||||
|
||||
test("Temporal fields must overlap formatter", () => {
|
||||
|
|
|
|||
|
|
@ -54,9 +54,7 @@ describe("errors", () => {
|
|||
);
|
||||
|
||||
expect(() => {
|
||||
formatter.formatToParts(
|
||||
new Temporal.PlainDateTime(1972, 1, 1, 8, 45, 56, 123, 345, 789, "gregory")
|
||||
);
|
||||
formatter.formatToParts(new Temporal.PlainDateTime(1972, 1, 1, 8, 45, 56, 123, 345, 789, "gregory"));
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Cannot format Temporal.PlainDateTime with calendar 'gregory' in locale with calendar 'iso8601'"
|
||||
|
|
|
|||
|
|
@ -232,11 +232,9 @@ describe("correct behavior", () => {
|
|||
});
|
||||
|
||||
test("timeZoneName", () => {
|
||||
["short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"].forEach(
|
||||
timeZoneName => {
|
||||
["short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"].forEach(timeZoneName => {
|
||||
const en = new Intl.DateTimeFormat("en", { timeZoneName: timeZoneName });
|
||||
expect(en.resolvedOptions().timeZoneName).toBe(timeZoneName);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ describe("correct behavior", () => {
|
|||
for (const [input, expected] of values) {
|
||||
expect(Intl.DateTimeFormat.supportedLocalesOf(input)).toEqual(expected);
|
||||
// "best fit" (implementation defined) just uses the same implementation as "lookup" at the moment
|
||||
expect(
|
||||
Intl.DateTimeFormat.supportedLocalesOf(input, { localeMatcher: "best fit" })
|
||||
).toEqual(Intl.DateTimeFormat.supportedLocalesOf(input, { localeMatcher: "lookup" }));
|
||||
expect(Intl.DateTimeFormat.supportedLocalesOf(input, { localeMatcher: "best fit" })).toEqual(
|
||||
Intl.DateTimeFormat.supportedLocalesOf(input, { localeMatcher: "lookup" })
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ describe("correct behavior", () => {
|
|||
for (const [input, expected] of values) {
|
||||
expect(Intl.DisplayNames.supportedLocalesOf(input)).toEqual(expected);
|
||||
// "best fit" (implementation defined) just uses the same implementation as "lookup" at the moment
|
||||
expect(
|
||||
Intl.DisplayNames.supportedLocalesOf(input, { localeMatcher: "best fit" })
|
||||
).toEqual(Intl.DisplayNames.supportedLocalesOf(input, { localeMatcher: "lookup" }));
|
||||
expect(Intl.DisplayNames.supportedLocalesOf(input, { localeMatcher: "best fit" })).toEqual(
|
||||
Intl.DisplayNames.supportedLocalesOf(input, { localeMatcher: "lookup" })
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ describe("errors", () => {
|
|||
test("called without new", () => {
|
||||
expect(() => {
|
||||
Intl.DurationFormat();
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Intl.DurationFormat constructor must be called with 'new'"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Intl.DurationFormat constructor must be called with 'new'");
|
||||
});
|
||||
|
||||
test("structurally invalid tag", () => {
|
||||
|
|
@ -137,10 +134,7 @@ describe("errors", () => {
|
|||
test("millisecondsDisplay option is invalid", () => {
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { millisecondsDisplay: "hello!" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"hello! is not a valid value for option millisecondsDisplay"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option millisecondsDisplay");
|
||||
});
|
||||
|
||||
test("microseconds option is invalid", () => {
|
||||
|
|
@ -152,10 +146,7 @@ describe("errors", () => {
|
|||
test("microsecondsDisplay option is invalid", () => {
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { microsecondsDisplay: "hello!" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"hello! is not a valid value for option microsecondsDisplay"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option microsecondsDisplay");
|
||||
});
|
||||
|
||||
test("nanoseconds option is invalid", () => {
|
||||
|
|
@ -167,10 +158,7 @@ describe("errors", () => {
|
|||
test("nanosecondsDisplay option is invalid", () => {
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { nanosecondsDisplay: "hello!" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"hello! is not a valid value for option nanosecondsDisplay"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option nanosecondsDisplay");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -211,8 +211,7 @@ describe("correct behavior", () => {
|
|||
{ type: "integer", value: "9", unit: "nanosecond" },
|
||||
{ type: "unit", value: "ns", unit: "nanosecond" },
|
||||
]);
|
||||
expect(new Intl.DurationFormat("en", { style: "digital" }).formatToParts(duration)).toEqual(
|
||||
[
|
||||
expect(new Intl.DurationFormat("en", { style: "digital" }).formatToParts(duration)).toEqual([
|
||||
{ type: "integer", value: "1", unit: "year" },
|
||||
{ type: "literal", value: " ", unit: "year" },
|
||||
{ type: "unit", value: "yr", unit: "year" },
|
||||
|
|
@ -236,8 +235,7 @@ describe("correct behavior", () => {
|
|||
{ type: "integer", value: "06", unit: "second" },
|
||||
{ type: "decimal", value: ".", unit: "second" },
|
||||
{ type: "fraction", value: "007008009", unit: "second" },
|
||||
]
|
||||
);
|
||||
]);
|
||||
expect(
|
||||
new Intl.DurationFormat("en", {
|
||||
style: "narrow",
|
||||
|
|
@ -398,8 +396,7 @@ describe("correct behavior", () => {
|
|||
{ type: "literal", value: " ", unit: "nanosecond" },
|
||||
{ type: "unit", value: "ns", unit: "nanosecond" },
|
||||
]);
|
||||
expect(new Intl.DurationFormat("de", { style: "digital" }).formatToParts(duration)).toEqual(
|
||||
[
|
||||
expect(new Intl.DurationFormat("de", { style: "digital" }).formatToParts(duration)).toEqual([
|
||||
{ type: "integer", value: "1", unit: "year" },
|
||||
{ type: "literal", value: " ", unit: "year" },
|
||||
{ type: "unit", value: "J", unit: "year" },
|
||||
|
|
@ -423,8 +420,7 @@ describe("correct behavior", () => {
|
|||
{ type: "integer", value: "06", unit: "second" },
|
||||
{ type: "decimal", value: ",", unit: "second" },
|
||||
{ type: "fraction", value: "007008009", unit: "second" },
|
||||
]
|
||||
);
|
||||
]);
|
||||
expect(
|
||||
new Intl.DurationFormat("de", {
|
||||
style: "narrow",
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ describe("correct behavior", () => {
|
|||
for (const [input, expected] of values) {
|
||||
expect(Intl.DurationFormat.supportedLocalesOf(input)).toEqual(expected);
|
||||
// "best fit" (implementation defined) just uses the same implementation as "lookup" at the moment
|
||||
expect(
|
||||
Intl.DurationFormat.supportedLocalesOf(input, { localeMatcher: "best fit" })
|
||||
).toEqual(Intl.DurationFormat.supportedLocalesOf(input, { localeMatcher: "lookup" }));
|
||||
expect(Intl.DurationFormat.supportedLocalesOf(input, { localeMatcher: "best fit" })).toEqual(
|
||||
Intl.DurationFormat.supportedLocalesOf(input, { localeMatcher: "lookup" })
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,17 +20,11 @@ describe("errors", () => {
|
|||
test("duplicate variant subtags", () => {
|
||||
expect(() => {
|
||||
Intl.getCanonicalLocales("en-posix-POSIX");
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"en-posix-POSIX is not a structurally valid language tag"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "en-posix-POSIX is not a structurally valid language tag");
|
||||
|
||||
expect(() => {
|
||||
Intl.getCanonicalLocales("en-POSIX-POSIX");
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"en-POSIX-POSIX is not a structurally valid language tag"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "en-POSIX-POSIX is not a structurally valid language tag");
|
||||
});
|
||||
|
||||
test("improperly placed separator", () => {
|
||||
|
|
@ -70,10 +64,7 @@ describe("errors", () => {
|
|||
test("duplicate transformed extension variant subtags", () => {
|
||||
expect(() => {
|
||||
Intl.getCanonicalLocales("en-t-en-POSIX-POSIX");
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"en-t-en-POSIX-POSIX is not a structurally valid language tag"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "en-t-en-POSIX-POSIX is not a structurally valid language tag");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -111,9 +102,7 @@ describe("normal behavior", () => {
|
|||
|
||||
test("duplicate Unicode locale extension keywords", () => {
|
||||
expect(Intl.getCanonicalLocales("en-us-u-1k-aaa-1k-bbb")).toEqual(["en-US-u-1k-aaa"]);
|
||||
expect(Intl.getCanonicalLocales("en-us-u-1k-aaa-2k-ccc-1k-bbb")).toEqual([
|
||||
"en-US-u-1k-aaa-2k-ccc",
|
||||
]);
|
||||
expect(Intl.getCanonicalLocales("en-us-u-1k-aaa-2k-ccc-1k-bbb")).toEqual(["en-US-u-1k-aaa-2k-ccc"]);
|
||||
});
|
||||
|
||||
test("canonicalize locale objects", () => {
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ describe("correct behavior", () => {
|
|||
for (const [input, expected] of values) {
|
||||
expect(Intl.ListFormat.supportedLocalesOf(input)).toEqual(expected);
|
||||
// "best fit" (implementation defined) just uses the same implementation as "lookup" at the moment
|
||||
expect(
|
||||
Intl.ListFormat.supportedLocalesOf(input, { localeMatcher: "best fit" })
|
||||
).toEqual(Intl.ListFormat.supportedLocalesOf(input, { localeMatcher: "lookup" }));
|
||||
expect(Intl.ListFormat.supportedLocalesOf(input, { localeMatcher: "best fit" })).toEqual(
|
||||
Intl.ListFormat.supportedLocalesOf(input, { localeMatcher: "lookup" })
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,10 +9,7 @@ describe("errors", () => {
|
|||
[123456789, "a", "longerthan8chars"].forEach(value => {
|
||||
expect(() => {
|
||||
new Intl.Locale("en", { firstDayOfWeek: value }).firstDayOfWeek;
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
`${value} is not a valid value for option firstDayOfWeek`
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, `${value} is not a valid value for option firstDayOfWeek`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -27,20 +24,14 @@ describe("normal behavior", () => {
|
|||
expect(new Intl.Locale("en", { firstDayOfWeek: day }).firstDayOfWeek).toBe(day);
|
||||
expect(new Intl.Locale("en", { firstDayOfWeek: index }).firstDayOfWeek).toBe(day);
|
||||
|
||||
expect(new Intl.Locale("en-u-fw-mon", { firstDayOfWeek: day }).firstDayOfWeek).toBe(
|
||||
day
|
||||
);
|
||||
expect(new Intl.Locale("en-u-fw-mon", { firstDayOfWeek: index }).firstDayOfWeek).toBe(
|
||||
day
|
||||
);
|
||||
expect(new Intl.Locale("en-u-fw-mon", { firstDayOfWeek: day }).firstDayOfWeek).toBe(day);
|
||||
expect(new Intl.Locale("en-u-fw-mon", { firstDayOfWeek: index }).firstDayOfWeek).toBe(day);
|
||||
});
|
||||
});
|
||||
|
||||
test("non-standard options", () => {
|
||||
[100, Infinity, NaN, "hello", 152n, true].forEach(value => {
|
||||
expect(new Intl.Locale("en", { firstDayOfWeek: value }).firstDayOfWeek).toBe(
|
||||
value.toString()
|
||||
);
|
||||
expect(new Intl.Locale("en", { firstDayOfWeek: value }).firstDayOfWeek).toBe(value.toString());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,7 +26,5 @@ test("normal behavior", () => {
|
|||
|
||||
test("keywords are preserved", () => {
|
||||
expect(new Intl.Locale("en-u-ca-abc").maximize().toString()).toBe("en-Latn-US-u-ca-abc");
|
||||
expect(new Intl.Locale("en", { calendar: "abc" }).maximize().toString()).toBe(
|
||||
"en-Latn-US-u-ca-abc"
|
||||
);
|
||||
expect(new Intl.Locale("en", { calendar: "abc" }).maximize().toString()).toBe("en-Latn-US-u-ca-abc");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,7 +28,5 @@ test("normal behavior", () => {
|
|||
|
||||
test("keywords are preserved", () => {
|
||||
expect(new Intl.Locale("en-Latn-US-u-ca-abc").minimize().toString()).toBe("en-u-ca-abc");
|
||||
expect(new Intl.Locale("en-Latn-US", { calendar: "abc" }).minimize().toString()).toBe(
|
||||
"en-u-ca-abc"
|
||||
);
|
||||
expect(new Intl.Locale("en-Latn-US", { calendar: "abc" }).minimize().toString()).toBe("en-u-ca-abc");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ describe("normal behavior", () => {
|
|||
expect(new Intl.Locale("en").numberingSystem).toBeUndefined();
|
||||
expect(new Intl.Locale("en-u-nu-abc").numberingSystem).toBe("abc");
|
||||
expect(new Intl.Locale("en", { numberingSystem: "abc" }).numberingSystem).toBe("abc");
|
||||
expect(new Intl.Locale("en-u-nu-abc", { numberingSystem: "def" }).numberingSystem).toBe(
|
||||
"def"
|
||||
);
|
||||
expect(new Intl.Locale("en-u-nu-abc", { numberingSystem: "def" }).numberingSystem).toBe("def");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,10 +8,7 @@ describe("errors", () => {
|
|||
test("duplicate variants", () => {
|
||||
expect(() => {
|
||||
new Intl.Locale("en-abcde-abcde");
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"en-abcde-abcde is not a structurally valid language tag"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "en-abcde-abcde is not a structurally valid language tag");
|
||||
|
||||
expect(() => {
|
||||
new Intl.Locale("en", { variants: "abcde-abcde" });
|
||||
|
|
|
|||
|
|
@ -44,10 +44,7 @@ describe("errors", () => {
|
|||
test("currency option is undefined when required ", () => {
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { style: "currency" });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Option currency must be defined when option style is currency"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Option currency must be defined when option style is currency");
|
||||
});
|
||||
|
||||
test("currency option is invalid ", () => {
|
||||
|
|
@ -85,10 +82,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { unit: "acre-per-bit-per-byte" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"acre-per-bit-per-byte is not a valid value for option unit"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "acre-per-bit-per-byte is not a valid value for option unit");
|
||||
});
|
||||
|
||||
test("unitDisplay option is invalid ", () => {
|
||||
|
|
@ -218,10 +212,7 @@ describe("errors", () => {
|
|||
test("roundingPriority option is invalid", () => {
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { roundingPriority: "hello!" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"hello! is not a valid value for option roundingPriority"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option roundingPriority");
|
||||
});
|
||||
|
||||
test("roundingMode option is invalid", () => {
|
||||
|
|
@ -249,10 +240,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { roundingIncrement: 5, minimumSignificantDigits: 1 });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"5 is not a valid rounding increment for rounding type significantDigits"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "5 is not a valid rounding increment for rounding type significantDigits");
|
||||
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", {
|
||||
|
|
@ -260,19 +248,13 @@ describe("errors", () => {
|
|||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 3,
|
||||
});
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"5 is not a valid rounding increment for inequal min/max fraction digits"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "5 is not a valid rounding increment for inequal min/max fraction digits");
|
||||
});
|
||||
|
||||
test("trailingZeroDisplay option is invalid", () => {
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { trailingZeroDisplay: "hello!" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"hello! is not a valid value for option trailingZeroDisplay"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option trailingZeroDisplay");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -434,31 +416,21 @@ describe("normal behavior", () => {
|
|||
});
|
||||
|
||||
test("all valid roundingMode options", () => {
|
||||
[
|
||||
"ceil",
|
||||
"floor",
|
||||
"expand",
|
||||
"trunc",
|
||||
"halfCeil",
|
||||
"halfFloor",
|
||||
"halfExpand",
|
||||
"halfTrunc",
|
||||
"halfEven",
|
||||
].forEach(roundingMode => {
|
||||
["ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven"].forEach(
|
||||
roundingMode => {
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { roundingMode: roundingMode });
|
||||
}).not.toThrow();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test("all valid roundingIncrement options", () => {
|
||||
[1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000].forEach(
|
||||
roundingIncrement => {
|
||||
[1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000].forEach(roundingIncrement => {
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { roundingIncrement: roundingIncrement });
|
||||
}).not.toThrow();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("all valid trailingZeroDisplay options", () => {
|
||||
|
|
|
|||
|
|
@ -82,21 +82,11 @@ describe("style=decimal", () => {
|
|||
expect(en.format(12.3456)).toBe("12.3456");
|
||||
expect(en.format(12.34567)).toBe("12.3457");
|
||||
expect(en.format(12.34561)).toBe("12.3456");
|
||||
expect(en.format(0.00000000000000000000000000000123)).toBe(
|
||||
"0.000000000000000000000000000001230"
|
||||
);
|
||||
expect(en.format(-0.00000000000000000000000000000123)).toBe(
|
||||
"-0.000000000000000000000000000001230"
|
||||
);
|
||||
expect(en.format(12344501000000000000000000000000000)).toBe(
|
||||
"12,344,500,000,000,000,000,000,000,000,000,000"
|
||||
);
|
||||
expect(en.format(-12344501000000000000000000000000000)).toBe(
|
||||
"-12,344,500,000,000,000,000,000,000,000,000,000"
|
||||
);
|
||||
expect(en.format(12344501000000000000000000000000000n)).toBe(
|
||||
"12,344,500,000,000,000,000,000,000,000,000,000"
|
||||
);
|
||||
expect(en.format(0.00000000000000000000000000000123)).toBe("0.000000000000000000000000000001230");
|
||||
expect(en.format(-0.00000000000000000000000000000123)).toBe("-0.000000000000000000000000000001230");
|
||||
expect(en.format(12344501000000000000000000000000000)).toBe("12,344,500,000,000,000,000,000,000,000,000,000");
|
||||
expect(en.format(-12344501000000000000000000000000000)).toBe("-12,344,500,000,000,000,000,000,000,000,000,000");
|
||||
expect(en.format(12344501000000000000000000000000000n)).toBe("12,344,500,000,000,000,000,000,000,000,000,000");
|
||||
expect(en.format(-12344501000000000000000000000000000n)).toBe(
|
||||
"-12,344,500,000,000,000,000,000,000,000,000,000"
|
||||
);
|
||||
|
|
@ -211,9 +201,7 @@ describe("style=decimal", () => {
|
|||
expect(ar.format(123)).toBe("\u0661\u0662\u0663\u0623\u0633\u0660");
|
||||
expect(ar.format(1234)).toBe("\u0661\u066b\u0662\u0663\u0664\u0623\u0633\u0663");
|
||||
expect(ar.format(12345)).toBe("\u0661\u0662\u066b\u0663\u0664\u0665\u0623\u0633\u0663");
|
||||
expect(ar.format(123456)).toBe(
|
||||
"\u0661\u0662\u0663\u066b\u0664\u0665\u0666\u0623\u0633\u0663"
|
||||
);
|
||||
expect(ar.format(123456)).toBe("\u0661\u0662\u0663\u066b\u0664\u0665\u0666\u0623\u0633\u0663");
|
||||
expect(ar.format(1234567)).toBe("\u0661\u066b\u0662\u0663\u0665\u0623\u0633\u0666");
|
||||
expect(ar.format(0.1)).toBe("\u0661\u0660\u0660\u0623\u0633\u061c-\u0663");
|
||||
expect(ar.format(0.12)).toBe("\u0661\u0662\u0660\u0623\u0633\u061c-\u0663");
|
||||
|
|
@ -563,16 +551,10 @@ describe("style=decimal", () => {
|
|||
expect(nf("en", undefined, 2, undefined, 2).format(1.23)).toBe("1.2");
|
||||
expect(nf("en", undefined, 3, undefined, 1).format(1.23)).toBe("1.2");
|
||||
|
||||
expect(nf("ar-u-nu-arab", 2, undefined, 2, undefined).format(1)).toBe(
|
||||
"\u0661\u066b\u0660\u0660"
|
||||
);
|
||||
expect(nf("ar-u-nu-arab", 2, undefined, 2, undefined).format(1)).toBe("\u0661\u066b\u0660\u0660");
|
||||
expect(nf("ar-u-nu-arab", 3, undefined, 1, undefined).format(1)).toBe("\u0661\u066b\u0660");
|
||||
expect(nf("ar-u-nu-arab", undefined, 2, undefined, 2).format(1.23)).toBe(
|
||||
"\u0661\u066b\u0662"
|
||||
);
|
||||
expect(nf("ar-u-nu-arab", undefined, 3, undefined, 1).format(1.23)).toBe(
|
||||
"\u0661\u066b\u0662"
|
||||
);
|
||||
expect(nf("ar-u-nu-arab", undefined, 2, undefined, 2).format(1.23)).toBe("\u0661\u066b\u0662");
|
||||
expect(nf("ar-u-nu-arab", undefined, 3, undefined, 1).format(1.23)).toBe("\u0661\u066b\u0662");
|
||||
});
|
||||
|
||||
test("roundingPriority=morePrecision", () => {
|
||||
|
|
@ -592,15 +574,9 @@ describe("style=decimal", () => {
|
|||
expect(nf("en", undefined, 3, undefined, 1).format(1.23)).toBe("1.23");
|
||||
|
||||
expect(nf("ar-u-nu-arab", 2, undefined, 2, undefined).format(1)).toBe("\u0661\u066b\u0660");
|
||||
expect(nf("ar-u-nu-arab", 3, undefined, 1, undefined).format(1)).toBe(
|
||||
"\u0661\u066b\u0660\u0660"
|
||||
);
|
||||
expect(nf("ar-u-nu-arab", undefined, 2, undefined, 2).format(1.23)).toBe(
|
||||
"\u0661\u066b\u0662\u0663"
|
||||
);
|
||||
expect(nf("ar-u-nu-arab", undefined, 3, undefined, 1).format(1.23)).toBe(
|
||||
"\u0661\u066b\u0662\u0663"
|
||||
);
|
||||
expect(nf("ar-u-nu-arab", 3, undefined, 1, undefined).format(1)).toBe("\u0661\u066b\u0660\u0660");
|
||||
expect(nf("ar-u-nu-arab", undefined, 2, undefined, 2).format(1.23)).toBe("\u0661\u066b\u0662\u0663");
|
||||
expect(nf("ar-u-nu-arab", undefined, 3, undefined, 1).format(1.23)).toBe("\u0661\u066b\u0662\u0663");
|
||||
});
|
||||
|
||||
test("roundingMode=ceil", () => {
|
||||
|
|
|
|||
|
|
@ -301,9 +301,7 @@ describe("style=decimal", () => {
|
|||
expect(enIn.formatToParts(1234567)).toEqual([{ type: "integer", value: "1234567" }]);
|
||||
|
||||
const ar = new Intl.NumberFormat("ar-u-nu-arab", { useGrouping: false });
|
||||
expect(ar.formatToParts(123456)).toEqual([
|
||||
{ type: "integer", value: "\u0661\u0662\u0663\u0664\u0665\u0666" },
|
||||
]);
|
||||
expect(ar.formatToParts(123456)).toEqual([{ type: "integer", value: "\u0661\u0662\u0663\u0664\u0665\u0666" }]);
|
||||
expect(ar.formatToParts(1234567)).toEqual([
|
||||
{ type: "integer", value: "\u0661\u0662\u0663\u0664\u0665\u0666\u0667" },
|
||||
]);
|
||||
|
|
@ -1623,9 +1621,7 @@ describe("bigint", () => {
|
|||
expect(en.formatToParts(123456n)).toEqual([{ type: "integer", value: "123456" }]);
|
||||
|
||||
const ar = new Intl.NumberFormat("ar-u-nu-arab", { useGrouping: false });
|
||||
expect(ar.formatToParts(123456n)).toEqual([
|
||||
{ type: "integer", value: "\u0661\u0662\u0663\u0664\u0665\u0666" },
|
||||
]);
|
||||
expect(ar.formatToParts(123456n)).toEqual([{ type: "integer", value: "\u0661\u0662\u0663\u0664\u0665\u0666" }]);
|
||||
});
|
||||
|
||||
test("significant digits", () => {
|
||||
|
|
|
|||
|
|
@ -346,32 +346,22 @@ describe("correct behavior", () => {
|
|||
const en1 = new Intl.NumberFormat("en");
|
||||
expect(en1.resolvedOptions().roundingMode).toBe("halfExpand");
|
||||
|
||||
[
|
||||
"ceil",
|
||||
"floor",
|
||||
"expand",
|
||||
"trunc",
|
||||
"halfCeil",
|
||||
"halfFloor",
|
||||
"halfExpand",
|
||||
"halfTrunc",
|
||||
"halfEven",
|
||||
].forEach(roundingMode => {
|
||||
["ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven"].forEach(
|
||||
roundingMode => {
|
||||
const en2 = new Intl.NumberFormat("en", { roundingMode: roundingMode });
|
||||
expect(en2.resolvedOptions().roundingMode).toBe(roundingMode);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test("rounding increment", () => {
|
||||
const en1 = new Intl.NumberFormat("en");
|
||||
expect(en1.resolvedOptions().roundingIncrement).toBe(1);
|
||||
|
||||
[1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000].forEach(
|
||||
roundingIncrement => {
|
||||
[1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000].forEach(roundingIncrement => {
|
||||
const en2 = new Intl.NumberFormat("en", { roundingIncrement: roundingIncrement });
|
||||
expect(en2.resolvedOptions().roundingIncrement).toBe(roundingIncrement);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("trailing zero display", () => {
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ describe("correct behavior", () => {
|
|||
for (const [input, expected] of values) {
|
||||
expect(Intl.NumberFormat.supportedLocalesOf(input)).toEqual(expected);
|
||||
// "best fit" (implementation defined) just uses the same implementation as "lookup" at the moment
|
||||
expect(
|
||||
Intl.NumberFormat.supportedLocalesOf(input, { localeMatcher: "best fit" })
|
||||
).toEqual(Intl.NumberFormat.supportedLocalesOf(input, { localeMatcher: "lookup" }));
|
||||
expect(Intl.NumberFormat.supportedLocalesOf(input, { localeMatcher: "best fit" })).toEqual(
|
||||
Intl.NumberFormat.supportedLocalesOf(input, { localeMatcher: "lookup" })
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -126,10 +126,7 @@ describe("errors", () => {
|
|||
test("roundingPriority option is invalid", () => {
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { roundingPriority: "hello!" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"hello! is not a valid value for option roundingPriority"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option roundingPriority");
|
||||
});
|
||||
|
||||
test("roundingMode option is invalid", () => {
|
||||
|
|
@ -157,10 +154,7 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { roundingIncrement: 5, minimumSignificantDigits: 1 });
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"5 is not a valid rounding increment for rounding type significantDigits"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "5 is not a valid rounding increment for rounding type significantDigits");
|
||||
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", {
|
||||
|
|
@ -168,19 +162,13 @@ describe("errors", () => {
|
|||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 3,
|
||||
});
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"5 is not a valid rounding increment for inequal min/max fraction digits"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "5 is not a valid rounding increment for inequal min/max fraction digits");
|
||||
});
|
||||
|
||||
test("trailingZeroDisplay option is invalid", () => {
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { trailingZeroDisplay: "hello!" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"hello! is not a valid value for option trailingZeroDisplay"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option trailingZeroDisplay");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -262,31 +250,21 @@ describe("normal behavior", () => {
|
|||
});
|
||||
|
||||
test("all valid roundingMode options", () => {
|
||||
[
|
||||
"ceil",
|
||||
"floor",
|
||||
"expand",
|
||||
"trunc",
|
||||
"halfCeil",
|
||||
"halfFloor",
|
||||
"halfExpand",
|
||||
"halfTrunc",
|
||||
"halfEven",
|
||||
].forEach(roundingMode => {
|
||||
["ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven"].forEach(
|
||||
roundingMode => {
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { roundingMode: roundingMode });
|
||||
}).not.toThrow();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test("all valid roundingIncrement options", () => {
|
||||
[1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000].forEach(
|
||||
roundingIncrement => {
|
||||
[1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000].forEach(roundingIncrement => {
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { roundingIncrement: roundingIncrement });
|
||||
}).not.toThrow();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("all valid trailingZeroDisplay options", () => {
|
||||
|
|
|
|||
|
|
@ -116,32 +116,22 @@ describe("correct behavior", () => {
|
|||
const en1 = new Intl.PluralRules("en");
|
||||
expect(en1.resolvedOptions().roundingMode).toBe("halfExpand");
|
||||
|
||||
[
|
||||
"ceil",
|
||||
"floor",
|
||||
"expand",
|
||||
"trunc",
|
||||
"halfCeil",
|
||||
"halfFloor",
|
||||
"halfExpand",
|
||||
"halfTrunc",
|
||||
"halfEven",
|
||||
].forEach(roundingMode => {
|
||||
["ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven"].forEach(
|
||||
roundingMode => {
|
||||
const en2 = new Intl.PluralRules("en", { roundingMode: roundingMode });
|
||||
expect(en2.resolvedOptions().roundingMode).toBe(roundingMode);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test("rounding increment", () => {
|
||||
const en1 = new Intl.PluralRules("en");
|
||||
expect(en1.resolvedOptions().roundingIncrement).toBe(1);
|
||||
|
||||
[1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000].forEach(
|
||||
roundingIncrement => {
|
||||
[1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000].forEach(roundingIncrement => {
|
||||
const en2 = new Intl.PluralRules("en", { roundingIncrement: roundingIncrement });
|
||||
expect(en2.resolvedOptions().roundingIncrement).toBe(roundingIncrement);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("trailing zero display", () => {
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ describe("correct behavior", () => {
|
|||
for (const [input, expected] of values) {
|
||||
expect(Intl.PluralRules.supportedLocalesOf(input)).toEqual(expected);
|
||||
// "best fit" (implementation defined) just uses the same implementation as "lookup" at the moment
|
||||
expect(
|
||||
Intl.PluralRules.supportedLocalesOf(input, { localeMatcher: "best fit" })
|
||||
).toEqual(Intl.PluralRules.supportedLocalesOf(input, { localeMatcher: "lookup" }));
|
||||
expect(Intl.PluralRules.supportedLocalesOf(input, { localeMatcher: "best fit" })).toEqual(
|
||||
Intl.PluralRules.supportedLocalesOf(input, { localeMatcher: "lookup" })
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ describe("errors", () => {
|
|||
test("called without new", () => {
|
||||
expect(() => {
|
||||
Intl.RelativeTimeFormat();
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Intl.RelativeTimeFormat constructor must be called with 'new'"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Intl.RelativeTimeFormat constructor must be called with 'new'");
|
||||
});
|
||||
|
||||
test("structurally invalid tag", () => {
|
||||
|
|
|
|||
|
|
@ -61,9 +61,7 @@ describe("correct behavior", () => {
|
|||
{ type: "literal", value: " seconds" },
|
||||
]);
|
||||
|
||||
expect(ar.formatToParts(-1, "second")).toEqual([
|
||||
{ type: "literal", value: "قبل ثانية واحدة" },
|
||||
]);
|
||||
expect(ar.formatToParts(-1, "second")).toEqual([{ type: "literal", value: "قبل ثانية واحدة" }]);
|
||||
});
|
||||
|
||||
test("minute", () => {
|
||||
|
|
@ -73,9 +71,7 @@ describe("correct behavior", () => {
|
|||
{ type: "literal", value: " minutes" },
|
||||
]);
|
||||
|
||||
expect(ar.formatToParts(-1, "minute")).toEqual([
|
||||
{ type: "literal", value: "قبل دقيقة واحدة" },
|
||||
]);
|
||||
expect(ar.formatToParts(-1, "minute")).toEqual([{ type: "literal", value: "قبل دقيقة واحدة" }]);
|
||||
});
|
||||
|
||||
test("hour", () => {
|
||||
|
|
@ -85,9 +81,7 @@ describe("correct behavior", () => {
|
|||
{ type: "literal", value: " hours" },
|
||||
]);
|
||||
|
||||
expect(ar.formatToParts(-1, "hour")).toEqual([
|
||||
{ type: "literal", value: "قبل ساعة واحدة" },
|
||||
]);
|
||||
expect(ar.formatToParts(-1, "hour")).toEqual([{ type: "literal", value: "قبل ساعة واحدة" }]);
|
||||
});
|
||||
|
||||
test("day", () => {
|
||||
|
|
@ -107,9 +101,7 @@ describe("correct behavior", () => {
|
|||
{ type: "literal", value: " weeks" },
|
||||
]);
|
||||
|
||||
expect(ar.formatToParts(-1, "week")).toEqual([
|
||||
{ type: "literal", value: "الأسبوع الماضي" },
|
||||
]);
|
||||
expect(ar.formatToParts(-1, "week")).toEqual([{ type: "literal", value: "الأسبوع الماضي" }]);
|
||||
});
|
||||
|
||||
test("month", () => {
|
||||
|
|
@ -129,9 +121,7 @@ describe("correct behavior", () => {
|
|||
{ type: "literal", value: " quarters" },
|
||||
]);
|
||||
|
||||
expect(ar.formatToParts(-1, "quarter")).toEqual([
|
||||
{ type: "literal", value: "الربع الأخير" },
|
||||
]);
|
||||
expect(ar.formatToParts(-1, "quarter")).toEqual([{ type: "literal", value: "الربع الأخير" }]);
|
||||
});
|
||||
|
||||
test("year", () => {
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ describe("correct behavior", () => {
|
|||
for (const [input, expected] of values) {
|
||||
expect(Intl.RelativeTimeFormat.supportedLocalesOf(input)).toEqual(expected);
|
||||
// "best fit" (implementation defined) just uses the same implementation as "lookup" at the moment
|
||||
expect(
|
||||
Intl.RelativeTimeFormat.supportedLocalesOf(input, { localeMatcher: "best fit" })
|
||||
).toEqual(
|
||||
expect(Intl.RelativeTimeFormat.supportedLocalesOf(input, { localeMatcher: "best fit" })).toEqual(
|
||||
Intl.RelativeTimeFormat.supportedLocalesOf(input, { localeMatcher: "lookup" })
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,7 @@ describe("errors", () => {
|
|||
test("cannot set the built-in Iterator's toStringTag", () => {
|
||||
expect(() => {
|
||||
Iterator.prototype[Symbol.toStringTag] = sentinel;
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Cannot write to non-writable property '[object IteratorPrototype]'"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Cannot write to non-writable property '[object IteratorPrototype]'");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,7 @@ describe("errors", () => {
|
|||
test("cannot set the built-in Iterator's constructor", () => {
|
||||
expect(() => {
|
||||
Iterator.prototype.constructor = sentinel;
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Cannot write to non-writable property '[object IteratorPrototype]'"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Cannot write to non-writable property '[object IteratorPrototype]'");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
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));
|
||||
|
|
|
|||
|
|
@ -17,19 +17,12 @@ test("JSON.rawJSON basic functionality", () => {
|
|||
|
||||
expect(JSON.stringify({ 42: JSON.rawJSON(37) })).toBe('{"42":37}');
|
||||
expect(JSON.stringify({ x: JSON.rawJSON(1), y: JSON.rawJSON(2) })).toBe('{"x":1,"y":2}');
|
||||
expect(JSON.stringify({ x: { x: JSON.rawJSON(1), y: JSON.rawJSON(2) } })).toBe(
|
||||
'{"x":{"x":1,"y":2}}'
|
||||
);
|
||||
expect(JSON.stringify({ x: { x: JSON.rawJSON(1), y: JSON.rawJSON(2) } })).toBe('{"x":{"x":1,"y":2}}');
|
||||
|
||||
expect(JSON.stringify([JSON.rawJSON(1), JSON.rawJSON(1.1)])).toBe("[1,1.1]");
|
||||
expect(
|
||||
JSON.stringify([
|
||||
JSON.rawJSON('"1"'),
|
||||
JSON.rawJSON(true),
|
||||
JSON.rawJSON(null),
|
||||
JSON.rawJSON(false),
|
||||
])
|
||||
).toBe('["1",true,null,false]');
|
||||
expect(JSON.stringify([JSON.rawJSON('"1"'), JSON.rawJSON(true), JSON.rawJSON(null), JSON.rawJSON(false)])).toBe(
|
||||
'["1",true,null,false]'
|
||||
);
|
||||
expect(JSON.stringify([{ x: JSON.rawJSON(1), y: JSON.rawJSON(1) }])).toBe('[{"x":1,"y":1}]');
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,5 @@ test("basic functionality", () => {
|
|||
|
||||
o.key1 = "key1";
|
||||
|
||||
expect(JSON.stringify(o)).toBe(
|
||||
'{"0":0,"1":1,"2":2,"key2":"key2","defined":"defined","key4":"key4","key1":"key1"}'
|
||||
);
|
||||
expect(JSON.stringify(o)).toBe('{"0":0,"1":1,"2":2,"key2":"key2","defined":"defined","key4":"key4","key1":"key1"}');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ test("basic functionality", () => {
|
|||
return value;
|
||||
});
|
||||
|
||||
expect(string).toBe(
|
||||
'{"var1":"foo","var2":42,"arr":[1,2,{"nested":{},"x":20}],"obj":{"subarr":[3,4,5]}}'
|
||||
);
|
||||
expect(string).toBe('{"var1":"foo","var2":42,"arr":[1,2,{"nested":{},"x":20}],"obj":{"subarr":[3,4,5]}}');
|
||||
|
||||
string = JSON.stringify(o, ["var1", "var1", "var2", "obj"]);
|
||||
expect(string).toBe('{"var1":"foo","var2":42,"obj":{}}');
|
||||
|
|
|
|||
|
|
@ -8,89 +8,72 @@ test("basic functionality", () => {
|
|||
expect(Math.sumPrecise([0.1])).toBe(0.1);
|
||||
expect(Math.sumPrecise([0.1, 0.1])).toBe(0.2);
|
||||
expect(Math.sumPrecise([0.1, -0.1])).toBe(0);
|
||||
expect(Math.sumPrecise([1e308, 1e308, 0.1, 0.1, 1e30, 0.1, -1e30, -1e308, -1e308])).toBe(
|
||||
0.30000000000000004
|
||||
);
|
||||
expect(Math.sumPrecise([1e308, 1e308, 0.1, 0.1, 1e30, 0.1, -1e30, -1e308, -1e308])).toBe(0.30000000000000004);
|
||||
expect(Math.sumPrecise([1e30, 0.1, -1e30])).toBe(0.1);
|
||||
|
||||
expect(
|
||||
Math.sumPrecise([8.98846567431158e307, 8.988465674311579e307, -1.7976931348623157e308])
|
||||
).toBe(9.9792015476736e291);
|
||||
expect(
|
||||
Math.sumPrecise([-5.630637621603525e255, 9.565271205476345e307, 2.9937604643020797e292])
|
||||
).toBe(9.565271205476347e307);
|
||||
expect(Math.sumPrecise([8.98846567431158e307, 8.988465674311579e307, -1.7976931348623157e308])).toBe(
|
||||
9.9792015476736e291
|
||||
);
|
||||
expect(Math.sumPrecise([-5.630637621603525e255, 9.565271205476345e307, 2.9937604643020797e292])).toBe(
|
||||
9.565271205476347e307
|
||||
);
|
||||
expect(
|
||||
Math.sumPrecise([
|
||||
6.739986666787661e66, 2, -1.2689709186578243e-116, 1.7046015739467354e308,
|
||||
-9.979201547673601e291, 6.160926733208294e307, -3.179557053031852e234,
|
||||
-7.027282978772846e307, -0.7500000000000001,
|
||||
6.739986666787661e66, 2, -1.2689709186578243e-116, 1.7046015739467354e308, -9.979201547673601e291,
|
||||
6.160926733208294e307, -3.179557053031852e234, -7.027282978772846e307, -0.7500000000000001,
|
||||
])
|
||||
).toBe(1.61796594939028e308);
|
||||
expect(
|
||||
Math.sumPrecise([
|
||||
0.31150493246968836, -8.988465674311582e307, 1.8315037361673755e-270,
|
||||
-15.999999999999996, 2.9999999999999996, 7.345200721499384e164, -2.033582473639399,
|
||||
-8.98846567431158e307, -3.5737295155405993e292, 4.13894772383715e-124,
|
||||
-3.6111186457260667e-35, 2.387234887098013e180, 7.645295562778372e-298,
|
||||
3.395189016861822e-103, -2.6331611115768973e-149,
|
||||
0.31150493246968836, -8.988465674311582e307, 1.8315037361673755e-270, -15.999999999999996,
|
||||
2.9999999999999996, 7.345200721499384e164, -2.033582473639399, -8.98846567431158e307,
|
||||
-3.5737295155405993e292, 4.13894772383715e-124, -3.6111186457260667e-35, 2.387234887098013e180,
|
||||
7.645295562778372e-298, 3.395189016861822e-103, -2.6331611115768973e-149,
|
||||
])
|
||||
).toBe(-Infinity);
|
||||
expect(
|
||||
Math.sumPrecise([
|
||||
-1.1442589134409902e308, 9.593842098384855e138, 4.494232837155791e307,
|
||||
-1.3482698511467367e308, 4.494232837155792e307,
|
||||
-1.1442589134409902e308, 9.593842098384855e138, 4.494232837155791e307, -1.3482698511467367e308,
|
||||
4.494232837155792e307,
|
||||
])
|
||||
).toBe(-1.5936821971565685e308);
|
||||
expect(
|
||||
Math.sumPrecise([
|
||||
-1.1442589134409902e308, 4.494232837155791e307, -1.3482698511467367e308,
|
||||
4.494232837155792e307,
|
||||
-1.1442589134409902e308, 4.494232837155791e307, -1.3482698511467367e308, 4.494232837155792e307,
|
||||
])
|
||||
).toBe(-1.5936821971565687e308);
|
||||
expect(
|
||||
Math.sumPrecise([
|
||||
9.593842098384855e138, -6.948356297254111e307, -1.3482698511467367e308,
|
||||
4.494232837155792e307,
|
||||
])
|
||||
Math.sumPrecise([9.593842098384855e138, -6.948356297254111e307, -1.3482698511467367e308, 4.494232837155792e307])
|
||||
).toBe(-1.5936821971565685e308);
|
||||
expect(
|
||||
Math.sumPrecise([-2.534858246857893e115, 8.988465674311579e307, 8.98846567431158e307]),
|
||||
1.7976931348623157e308
|
||||
);
|
||||
expect(Math.sumPrecise([1.3588124894186193e308, 1.4803986201152006e223, 6.741349255733684e307])).toBe(Infinity);
|
||||
expect(Math.sumPrecise([6.741349255733684e307, 1.7976931348623155e308, -7.388327292663961e41])).toBe(Infinity);
|
||||
expect(Math.sumPrecise([-1.9807040628566093e28, 1.7976931348623157e308, 9.9792015476736e291])).toBe(
|
||||
1.7976931348623157e308
|
||||
);
|
||||
expect(
|
||||
Math.sumPrecise([1.3588124894186193e308, 1.4803986201152006e223, 6.741349255733684e307])
|
||||
).toBe(Infinity);
|
||||
expect(
|
||||
Math.sumPrecise([6.741349255733684e307, 1.7976931348623155e308, -7.388327292663961e41])
|
||||
).toBe(Infinity);
|
||||
expect(
|
||||
Math.sumPrecise([-1.9807040628566093e28, 1.7976931348623157e308, 9.9792015476736e291])
|
||||
Math.sumPrecise([-1.0214557991173964e61, 1.7976931348623157e308, 8.98846567431158e307, -8.988465674311579e307])
|
||||
).toBe(1.7976931348623157e308);
|
||||
expect(
|
||||
Math.sumPrecise([
|
||||
-1.0214557991173964e61, 1.7976931348623157e308, 8.98846567431158e307,
|
||||
-8.988465674311579e307,
|
||||
])
|
||||
).toBe(1.7976931348623157e308);
|
||||
expect(
|
||||
Math.sumPrecise([
|
||||
1.7976931348623157e308, 7.999999999999999, -1.908963895403937e-230,
|
||||
1.6445950082320264e292, 2.0734856707605806e205,
|
||||
1.7976931348623157e308, 7.999999999999999, -1.908963895403937e-230, 1.6445950082320264e292,
|
||||
2.0734856707605806e205,
|
||||
])
|
||||
).toBe(Infinity);
|
||||
expect(
|
||||
Math.sumPrecise([6.197409167220438e-223, -9.979201547673601e291, -1.7976931348623157e308])
|
||||
).toBe(-Infinity);
|
||||
expect(Math.sumPrecise([6.197409167220438e-223, -9.979201547673601e291, -1.7976931348623157e308])).toBe(-Infinity);
|
||||
expect(
|
||||
Math.sumPrecise([
|
||||
4.49423283715579e307, 8.944251746776101e307, -0.0002441406250000001,
|
||||
1.1752060710043817e308, 4.940846717201632e292, -1.6836699406454528e308,
|
||||
4.49423283715579e307, 8.944251746776101e307, -0.0002441406250000001, 1.1752060710043817e308,
|
||||
4.940846717201632e292, -1.6836699406454528e308,
|
||||
])
|
||||
).toBe(8.353845887521184e307);
|
||||
expect(
|
||||
Math.sumPrecise([
|
||||
8.988465674311579e307, 7.999999999999998, 7.029158107234023e-308,
|
||||
-2.2303483759420562e-172, -1.7976931348623157e308, -8.98846567431158e307,
|
||||
8.988465674311579e307, 7.999999999999998, 7.029158107234023e-308, -2.2303483759420562e-172,
|
||||
-1.7976931348623157e308, -8.98846567431158e307,
|
||||
])
|
||||
).toBe(-1.7976931348623157e308);
|
||||
expect(Math.sumPrecise([8.98846567431158e307, 8.98846567431158e307])).toBe(Infinity);
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@ describe("styles", () => {
|
|||
|
||||
test("percent", () => {
|
||||
expect((0.234).toLocaleString("en", { style: "percent" })).toBe("23%");
|
||||
expect((0.234).toLocaleString("ar-u-nu-arab", { style: "percent" })).toBe(
|
||||
"\u0662\u0663\u066a\u061c"
|
||||
);
|
||||
expect((0.234).toLocaleString("ar-u-nu-arab", { style: "percent" })).toBe("\u0662\u0663\u066a\u061c");
|
||||
});
|
||||
|
||||
test("currency", () => {
|
||||
|
|
|
|||
|
|
@ -21,10 +21,7 @@ describe("errors", () => {
|
|||
[-Infinity, 0, 101, Infinity].forEach(value => {
|
||||
expect(() => {
|
||||
(0).toPrecision(value);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Precision must be an integer no less than 1, and no greater than 100"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "Precision must be an integer no less than 1, and no greater than 100");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -86,10 +86,7 @@ describe("correct behavior", () => {
|
|||
3,
|
||||
"122200222200200002020000221212111212020212021222122122201112112001202200202210122011020121220102211210120110",
|
||||
],
|
||||
[
|
||||
4,
|
||||
"11323100002023111300233213100000000000000000000000000000000000000000000000000000000000",
|
||||
],
|
||||
[4, "11323100002023111300233213100000000000000000000000000000000000000000000000000000000000"],
|
||||
[5, "20213333043100433442123113244334300004432332001224240433304410013422100304"],
|
||||
[6, "550003524220341511224004404200404220224024020444420402442220220420"],
|
||||
[7, "4235625635040541506562064422461122351652161506062250163366335"],
|
||||
|
|
|
|||
|
|
@ -29,14 +29,11 @@ describe("normal behavior", () => {
|
|||
|
||||
test("merges objects", () => {
|
||||
const s = Symbol();
|
||||
expect(
|
||||
Object.assign(
|
||||
{},
|
||||
{ foo: 0, bar: "baz" },
|
||||
{ [s]: [1, 2, 3] },
|
||||
{ foo: 1 },
|
||||
{ [42]: "test" }
|
||||
)
|
||||
).toEqual({ foo: 1, bar: "baz", [s]: [1, 2, 3], 42: "test" });
|
||||
expect(Object.assign({}, { foo: 0, bar: "baz" }, { [s]: [1, 2, 3] }, { foo: 1 }, { [42]: "test" })).toEqual({
|
||||
foo: 1,
|
||||
bar: "baz",
|
||||
[s]: [1, 2, 3],
|
||||
42: "test",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,10 +4,7 @@ test("length is 2", () => {
|
|||
|
||||
describe("errors", () => {
|
||||
test("non-object prototype value", () => {
|
||||
expect(() => Object.create(42)).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Prototype must be an object or null"
|
||||
);
|
||||
expect(() => Object.create(42)).toThrowWithMessage(TypeError, "Prototype must be an object or null");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,7 @@ test("length is 2", () => {
|
|||
|
||||
describe("errors", () => {
|
||||
test("non-object argument", () => {
|
||||
expect(() => Object.defineProperties(42, {})).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Object argument is not an object"
|
||||
);
|
||||
expect(() => Object.defineProperties(42, {})).toThrowWithMessage(TypeError, "Object argument is not an object");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -188,10 +188,7 @@ describe("errors", () => {
|
|||
get() {},
|
||||
value: 9,
|
||||
});
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Accessor property descriptor cannot specify a value or writable key"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Accessor property descriptor cannot specify a value or writable key");
|
||||
});
|
||||
|
||||
test("cannot define 'value' and 'set' in the same descriptor", () => {
|
||||
|
|
@ -202,10 +199,7 @@ describe("errors", () => {
|
|||
set() {},
|
||||
writable: true,
|
||||
});
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Accessor property descriptor cannot specify a value or writable key"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Accessor property descriptor cannot specify a value or writable key");
|
||||
});
|
||||
|
||||
test("redefine non-configurable accessor", () => {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
test("basic functionality", () => {
|
||||
[Array, BigInt, Boolean, Date, Error, Function, Number, Object, String].forEach(constructor => {
|
||||
expect(constructor.prototype.constructor).toBe(constructor);
|
||||
if (constructor !== BigInt)
|
||||
expect(Reflect.construct(constructor, []).constructor).toBe(constructor);
|
||||
if (constructor !== BigInt) expect(Reflect.construct(constructor, []).constructor).toBe(constructor);
|
||||
});
|
||||
|
||||
let o = {};
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
describe("[Call][GetOwnProperty]] trap normal behavior", () => {
|
||||
test("forwarding when not defined in handler", () => {
|
||||
expect(Object.getOwnPropertyDescriptor(new Proxy({}, { getOwnPropertyDescriptor: null }), "a")).toBeUndefined();
|
||||
expect(
|
||||
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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,33 +7,21 @@ test("constructs properly", () => {
|
|||
test("constructor argument count", () => {
|
||||
expect(() => {
|
||||
new Proxy();
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Expected target argument of Proxy constructor to be object, got undefined"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Expected target argument of Proxy constructor to be object, got undefined");
|
||||
|
||||
expect(() => {
|
||||
new Proxy({});
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Expected handler argument of Proxy constructor to be object, got undefined"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Expected handler argument of Proxy constructor to be object, got undefined");
|
||||
});
|
||||
|
||||
test("constructor requires objects", () => {
|
||||
expect(() => {
|
||||
new Proxy(1, {});
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Expected target argument of Proxy constructor to be object, got 1"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Expected target argument of Proxy constructor to be object, got 1");
|
||||
|
||||
expect(() => {
|
||||
new Proxy({}, 1);
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Expected handler argument of Proxy constructor to be object, got 1"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Expected handler argument of Proxy constructor to be object, got 1");
|
||||
});
|
||||
|
||||
test("constructor must be invoked with 'new'", () => {
|
||||
|
|
|
|||
|
|
@ -6,33 +6,21 @@ describe("errors", () => {
|
|||
test("constructor argument count", () => {
|
||||
expect(() => {
|
||||
Proxy.revocable();
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Expected target argument of Proxy constructor to be object, got undefined"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Expected target argument of Proxy constructor to be object, got undefined");
|
||||
|
||||
expect(() => {
|
||||
Proxy.revocable({});
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Expected handler argument of Proxy constructor to be object, got undefined"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Expected handler argument of Proxy constructor to be object, got undefined");
|
||||
});
|
||||
|
||||
test("constructor requires objects", () => {
|
||||
expect(() => {
|
||||
Proxy.revocable(1, {});
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Expected target argument of Proxy constructor to be object, got 1"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Expected target argument of Proxy constructor to be object, got 1");
|
||||
|
||||
expect(() => {
|
||||
Proxy.revocable({}, 1);
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Expected handler argument of Proxy constructor to be object, got 1"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Expected handler argument of Proxy constructor to be object, got 1");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ 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", () => {
|
||||
|
|
|
|||
|
|
@ -45,9 +45,7 @@ describe("normal behavior", () => {
|
|||
var o = {};
|
||||
|
||||
expect(o.foo).toBeUndefined();
|
||||
expect(
|
||||
Reflect.defineProperty(o, "foo", { value: 1, configurable: true, writable: true })
|
||||
).toBeTrue();
|
||||
expect(Reflect.defineProperty(o, "foo", { value: 1, configurable: true, writable: true })).toBeTrue();
|
||||
expect(o.foo).toBe(1);
|
||||
expect(Reflect.defineProperty(o, "foo", { value: 2 })).toBeTrue();
|
||||
expect(o.foo).toBe(2);
|
||||
|
|
@ -57,9 +55,7 @@ describe("normal behavior", () => {
|
|||
var o = {};
|
||||
|
||||
expect(o.foo).toBeUndefined();
|
||||
expect(
|
||||
Reflect.defineProperty(o, "foo", { value: 1, configurable: true, writable: false })
|
||||
).toBeTrue();
|
||||
expect(Reflect.defineProperty(o, "foo", { value: 1, configurable: true, writable: false })).toBeTrue();
|
||||
expect(o.foo).toBe(1);
|
||||
expect(Reflect.defineProperty(o, "foo", { value: 2 })).toBeTrue();
|
||||
expect(o.foo).toBe(2);
|
||||
|
|
@ -69,9 +65,7 @@ describe("normal behavior", () => {
|
|||
var o = {};
|
||||
|
||||
expect(o.foo).toBeUndefined();
|
||||
expect(
|
||||
Reflect.defineProperty(o, "foo", { value: 1, configurable: false, writable: false })
|
||||
).toBeTrue();
|
||||
expect(Reflect.defineProperty(o, "foo", { value: 1, configurable: false, writable: false })).toBeTrue();
|
||||
expect(o.foo).toBe(1);
|
||||
expect(Reflect.defineProperty(o, "foo", { value: 2 })).toBeFalse();
|
||||
expect(o.foo).toBe(1);
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ describe("errors", () => {
|
|||
test("invalid pattern", () => {
|
||||
expect(() => {
|
||||
RegExp("[");
|
||||
}).toThrowWithMessage(
|
||||
SyntaxError,
|
||||
"RegExp compile error: Error during parsing of regular expression:"
|
||||
);
|
||||
}).toThrowWithMessage(SyntaxError, "RegExp compile error: Error during parsing of regular expression:");
|
||||
});
|
||||
|
||||
test("invalid flag", () => {
|
||||
|
|
@ -116,26 +113,7 @@ test("Unicode properties of strings", () => {
|
|||
}).not.toThrow();
|
||||
}
|
||||
|
||||
const matchStrings = [
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"8",
|
||||
"A",
|
||||
"B",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
"f",
|
||||
];
|
||||
const matchStrings = ["0", "1", "2", "3", "4", "5", "8", "A", "B", "D", "E", "F", "a", "b", "c", "d", "e", "f"];
|
||||
|
||||
const nonMatchStrings = [
|
||||
"6\uFE0F\u20E3",
|
||||
|
|
|
|||
|
|
@ -50,14 +50,10 @@ describe("normal behavior", () => {
|
|||
expect(shadowRealm.evaluate("(function () {})")).toHaveLength(0);
|
||||
expect(shadowRealm.evaluate("(function (foo, bar) {})")).toHaveLength(2);
|
||||
expect(
|
||||
shadowRealm.evaluate(
|
||||
"Object.defineProperty(function () {}, 'length', { get() { return -Infinity } })"
|
||||
)
|
||||
shadowRealm.evaluate("Object.defineProperty(function () {}, 'length', { get() { return -Infinity } })")
|
||||
).toHaveLength(0);
|
||||
expect(
|
||||
shadowRealm.evaluate(
|
||||
"Object.defineProperty(function () {}, 'length', { get() { return Infinity } })"
|
||||
)
|
||||
shadowRealm.evaluate("Object.defineProperty(function () {}, 'length', { get() { return Infinity } })")
|
||||
).toHaveLength(Infinity);
|
||||
|
||||
for (const property of ["name", "length"]) {
|
||||
|
|
@ -70,18 +66,12 @@ describe("normal behavior", () => {
|
|||
});
|
||||
`
|
||||
);
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Trying to copy target name and length did not complete normally"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Trying to copy target name and length did not complete normally");
|
||||
}
|
||||
|
||||
expect(() => {
|
||||
shadowRealm.evaluate("(function () { throw Error(); })")();
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Call of wrapped target function did not complete normally"
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, "Call of wrapped target function did not complete normally");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -16,22 +16,13 @@ test("basic functionality", () => {
|
|||
test("errors", () => {
|
||||
expect(() => {
|
||||
String.fromCodePoint(NaN);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"must be an integer no less than 0 and no greater than 0x10FFFF"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "must be an integer no less than 0 and no greater than 0x10FFFF");
|
||||
|
||||
expect(() => {
|
||||
String.fromCodePoint(-5);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"must be an integer no less than 0 and no greater than 0x10FFFF"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "must be an integer no less than 0 and no greater than 0x10FFFF");
|
||||
|
||||
expect(() => {
|
||||
String.fromCodePoint(0x123ffff);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"must be an integer no less than 0 and no greater than 0x10FFFF"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "must be an integer no less than 0 and no greater than 0x10FFFF");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,21 +2,7 @@ test("basic functionality", () => {
|
|||
expect(String.prototype.split).toHaveLength(2);
|
||||
|
||||
expect("hello friends".split()).toEqual(["hello friends"]);
|
||||
expect("hello friends".split("")).toEqual([
|
||||
"h",
|
||||
"e",
|
||||
"l",
|
||||
"l",
|
||||
"o",
|
||||
" ",
|
||||
"f",
|
||||
"r",
|
||||
"i",
|
||||
"e",
|
||||
"n",
|
||||
"d",
|
||||
"s",
|
||||
]);
|
||||
expect("hello friends".split("")).toEqual(["h", "e", "l", "l", "o", " ", "f", "r", "i", "e", "n", "d", "s"]);
|
||||
expect("hello friends".split(" ")).toEqual(["hello", "friends"]);
|
||||
|
||||
expect("a,b,c,d".split(",")).toEqual(["a", "b", "c", "d"]);
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ describe("normal behavior", () => {
|
|||
expect(new SuppressedError().toString()).toBe("SuppressedError");
|
||||
expect(new SuppressedError(1).toString()).toBe("SuppressedError");
|
||||
expect(new SuppressedError(1, 1).toString()).toBe("SuppressedError");
|
||||
expect(new SuppressedError(undefined, undefined, "Foo").toString()).toBe(
|
||||
"SuppressedError: Foo"
|
||||
);
|
||||
expect(new SuppressedError(undefined, undefined, "Foo").toString()).toBe("SuppressedError: Foo");
|
||||
expect(new SuppressedError(1, 1, "Foo").toString()).toBe("SuppressedError: Foo");
|
||||
expect(Object.hasOwn(new SuppressedError(), "error")).toBeTrue();
|
||||
expect(Object.hasOwn(new SuppressedError(), "suppressed")).toBeTrue();
|
||||
|
|
@ -39,10 +37,7 @@ describe("normal behavior", () => {
|
|||
|
||||
test("converts message to string", () => {
|
||||
expect(new SuppressedError(undefined, undefined, 1)).toHaveProperty("message", "1");
|
||||
expect(new SuppressedError(undefined, undefined, {})).toHaveProperty(
|
||||
"message",
|
||||
"[object Object]"
|
||||
);
|
||||
expect(new SuppressedError(undefined, undefined, {})).toHaveProperty("message", "[object Object]");
|
||||
});
|
||||
|
||||
test("supports options object with cause", () => {
|
||||
|
|
|
|||
|
|
@ -121,30 +121,21 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
Temporal.Duration.compare(duration1, duration2);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"A starting point is required for comparing calendar units"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "A starting point is required for comparing calendar units");
|
||||
|
||||
const duration3 = new Temporal.Duration(0, 3);
|
||||
const duration4 = new Temporal.Duration(0, 4);
|
||||
|
||||
expect(() => {
|
||||
Temporal.Duration.compare(duration3, duration4);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"A starting point is required for comparing calendar units"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "A starting point is required for comparing calendar units");
|
||||
|
||||
const duration5 = new Temporal.Duration(0, 0, 5);
|
||||
const duration6 = new Temporal.Duration(0, 0, 6);
|
||||
|
||||
expect(() => {
|
||||
Temporal.Duration.compare(duration5, duration6);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"A starting point is required for comparing calendar units"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "A starting point is required for comparing calendar units");
|
||||
|
||||
// Still throws if year/month/week of one the duration objects is non-zero.
|
||||
const duration7 = new Temporal.Duration(0, 0, 0, 7);
|
||||
|
|
@ -152,20 +143,14 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
Temporal.Duration.compare(duration7, duration8);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"A starting point is required for comparing calendar units"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "A starting point is required for comparing calendar units");
|
||||
|
||||
const duration9 = new Temporal.Duration(0, 0, 9);
|
||||
const duration10 = new Temporal.Duration(0, 0, 0, 10);
|
||||
|
||||
expect(() => {
|
||||
Temporal.Duration.compare(duration9, duration10);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"A starting point is required for comparing calendar units"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "A starting point is required for comparing calendar units");
|
||||
});
|
||||
|
||||
test("sub-minute time zone offset mismatch (unambiguous time zone transition)", () => {
|
||||
|
|
@ -176,19 +161,13 @@ describe("errors", () => {
|
|||
Temporal.Duration.compare(duration1, duration2, {
|
||||
relativeTo: "1970-01-01T00:00:00-00:44:40[Africa/Monrovia]",
|
||||
});
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Invalid offset for the provided date and time in the current time zone"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "Invalid offset for the provided date and time in the current time zone");
|
||||
|
||||
expect(() => {
|
||||
Temporal.Duration.compare(duration1, duration2, {
|
||||
relativeTo: "1970-01-01T00:00:00-00:45:00[Africa/Monrovia]",
|
||||
});
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Invalid offset for the provided date and time in the current time zone"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "Invalid offset for the provided date and time in the current time zone");
|
||||
});
|
||||
|
||||
test("sub-minute time zone offset mismatch (ambiguous time zone transition)", () => {
|
||||
|
|
@ -199,9 +178,6 @@ describe("errors", () => {
|
|||
Temporal.Duration.compare(duration1, duration2, {
|
||||
relativeTo: "1952-10-15T23:59:59-11:19:50[Pacific/Niue]",
|
||||
});
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Invalid offset for the provided date and time in the current time zone"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "Invalid offset for the provided date and time in the current time zone");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ describe("correct behavior", () => {
|
|||
});
|
||||
|
||||
test("Duration instance argument", () => {
|
||||
const duration = Temporal.Duration.from(
|
||||
new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
|
||||
);
|
||||
const duration = Temporal.Duration.from(new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
||||
expectDurationOneToTen(duration);
|
||||
});
|
||||
|
||||
|
|
@ -62,17 +60,11 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
Temporal.Duration.from({ years: "foo" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Invalid value for duration property 'years': must be an integer, got foo"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "Invalid value for duration property 'years': must be an integer, got foo");
|
||||
|
||||
expect(() => {
|
||||
Temporal.Duration.from({ years: NaN });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Invalid value for duration property 'years': must be an integer, got NaN"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "Invalid value for duration property 'years': must be an integer, got NaN");
|
||||
});
|
||||
|
||||
test("invalid duration string", () => {
|
||||
|
|
|
|||
|
|
@ -38,10 +38,7 @@ describe("correct behavior", () => {
|
|||
["nanosecond", { nanoseconds: 1840300200300400 }],
|
||||
["microsecond", { microseconds: 1840300200300, nanoseconds: 400 }],
|
||||
["millisecond", { milliseconds: 1840300200, microseconds: 300, nanoseconds: 400 }],
|
||||
[
|
||||
"second",
|
||||
{ seconds: 1840300, milliseconds: 200, microseconds: 300, nanoseconds: 400 },
|
||||
],
|
||||
["second", { seconds: 1840300, milliseconds: 200, microseconds: 300, nanoseconds: 400 }],
|
||||
[
|
||||
"minute",
|
||||
{
|
||||
|
|
@ -143,20 +140,14 @@ describe("errors", () => {
|
|||
const duration = new Temporal.Duration(1);
|
||||
expect(() => {
|
||||
duration.round({ smallestUnit: "second", roundingMode: "serenityOS" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"serenityOS is not a valid value for option roundingMode"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "serenityOS is not a valid value for option roundingMode");
|
||||
});
|
||||
|
||||
test("invalid smallest unit", () => {
|
||||
const duration = new Temporal.Duration(1);
|
||||
expect(() => {
|
||||
duration.round({ smallestUnit: "serenityOS" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"serenityOS is not a valid value for option smallestUnit"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "serenityOS is not a valid value for option smallestUnit");
|
||||
});
|
||||
|
||||
test("increment may not be NaN", () => {
|
||||
|
|
@ -176,10 +167,7 @@ describe("errors", () => {
|
|||
}).toThrowWithMessage(RangeError, "0 is not a valid value for option roundingIncrement");
|
||||
expect(() => {
|
||||
duration.round({ smallestUnit: "second", roundingIncrement: Infinity });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Infinity is not a valid value for option roundingIncrement"
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, "Infinity is not a valid value for option roundingIncrement");
|
||||
});
|
||||
|
||||
test("must provide one or both of smallestUnit or largestUnit", () => {
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ describe("correct behavior", () => {
|
|||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
expect(new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).toJSON()).toBe(
|
||||
"P1Y2M3W4DT5H6M7.00800901S"
|
||||
);
|
||||
expect(new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).toJSON()).toBe("P1Y2M3W4DT5H6M7.00800901S");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -25,10 +25,7 @@ describe("correct behavior", () => {
|
|||
[[1, 2, 3, 4, 5, 6, 7, 8], "P1Y2M3W4DT5H6M7.008S"],
|
||||
[[1, 2, 3, 4, 5, 6, 7, 8, 9], "P1Y2M3W4DT5H6M7.008009S"],
|
||||
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "P1Y2M3W4DT5H6M7.00800901S"],
|
||||
[
|
||||
[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],
|
||||
"P100Y200M300W400DT500H600M700.800901S",
|
||||
],
|
||||
[[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], "P100Y200M300W400DT500H600M700.800901S"],
|
||||
[[-1], "-P1Y"],
|
||||
];
|
||||
for (const [args, expected] of values) {
|
||||
|
|
@ -44,9 +41,7 @@ describe("correct behavior", () => {
|
|||
["nanosecond", "P1Y2M3W4DT5H6M7.008010000S"],
|
||||
];
|
||||
for (const [smallestUnit, expected] of values) {
|
||||
expect(
|
||||
new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 8, 10).toString({ smallestUnit })
|
||||
).toBe(expected);
|
||||
expect(new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 8, 10).toString({ smallestUnit })).toBe(expected);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -85,10 +80,7 @@ describe("errors", () => {
|
|||
for (const smallestUnit of values) {
|
||||
expect(() => {
|
||||
new Temporal.Duration(0).toString({ smallestUnit });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
`${smallestUnit} is not a valid value for option smallestUnit`
|
||||
);
|
||||
}).toThrowWithMessage(RangeError, `${smallestUnit} is not a valid value for option smallestUnit`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,14 +9,11 @@ describe("correct behavior", () => {
|
|||
});
|
||||
|
||||
test("Instant string argument", () => {
|
||||
expect(Temporal.Instant.from("1975-02-02T14:25:36.123456789Z").epochNanoseconds).toBe(
|
||||
expect(Temporal.Instant.from("1975-02-02T14:25:36.123456789Z").epochNanoseconds).toBe(160583136123456789n);
|
||||
// Time zone is not validated
|
||||
expect(Temporal.Instant.from("1975-02-02T14:25:36.123456789Z[Custom/TimeZone]").epochNanoseconds).toBe(
|
||||
160583136123456789n
|
||||
);
|
||||
// Time zone is not validated
|
||||
expect(
|
||||
Temporal.Instant.from("1975-02-02T14:25:36.123456789Z[Custom/TimeZone]")
|
||||
.epochNanoseconds
|
||||
).toBe(160583136123456789n);
|
||||
|
||||
// Accepts but ignores the calendar.
|
||||
let result = null;
|
||||
|
|
|
|||
|
|
@ -6,21 +6,17 @@ describe("correct behavior", () => {
|
|||
test("basic functionality", () => {
|
||||
expect(Temporal.Instant.fromEpochMilliseconds(0).epochMilliseconds).toBe(0);
|
||||
expect(Temporal.Instant.fromEpochMilliseconds(1).epochMilliseconds).toBe(1);
|
||||
expect(Temporal.Instant.fromEpochMilliseconds(999_999_999).epochMilliseconds).toBe(
|
||||
999_999_999
|
||||
expect(Temporal.Instant.fromEpochMilliseconds(999_999_999).epochMilliseconds).toBe(999_999_999);
|
||||
expect(Temporal.Instant.fromEpochMilliseconds(8_640_000_000_000_000).epochMilliseconds).toBe(
|
||||
8_640_000_000_000_000
|
||||
);
|
||||
expect(
|
||||
Temporal.Instant.fromEpochMilliseconds(8_640_000_000_000_000).epochMilliseconds
|
||||
).toBe(8_640_000_000_000_000);
|
||||
|
||||
expect(Temporal.Instant.fromEpochMilliseconds(-0).epochMilliseconds).toBe(0);
|
||||
expect(Temporal.Instant.fromEpochMilliseconds(-1).epochMilliseconds).toBe(-1);
|
||||
expect(Temporal.Instant.fromEpochMilliseconds(-999_999_999).epochMilliseconds).toBe(
|
||||
-999_999_999
|
||||
expect(Temporal.Instant.fromEpochMilliseconds(-999_999_999).epochMilliseconds).toBe(-999_999_999);
|
||||
expect(Temporal.Instant.fromEpochMilliseconds(-8_640_000_000_000_000).epochMilliseconds).toBe(
|
||||
-8_640_000_000_000_000
|
||||
);
|
||||
expect(
|
||||
Temporal.Instant.fromEpochMilliseconds(-8_640_000_000_000_000).epochMilliseconds
|
||||
).toBe(-8_640_000_000_000_000);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -6,21 +6,17 @@ describe("correct behavior", () => {
|
|||
test("basic functionality", () => {
|
||||
expect(Temporal.Instant.fromEpochNanoseconds(0n).epochNanoseconds).toBe(0n);
|
||||
expect(Temporal.Instant.fromEpochNanoseconds(1n).epochNanoseconds).toBe(1n);
|
||||
expect(Temporal.Instant.fromEpochNanoseconds(999_999_999n).epochNanoseconds).toBe(
|
||||
999_999_999n
|
||||
expect(Temporal.Instant.fromEpochNanoseconds(999_999_999n).epochNanoseconds).toBe(999_999_999n);
|
||||
expect(Temporal.Instant.fromEpochNanoseconds(8_640_000_000_000_000_000_000n).epochNanoseconds).toBe(
|
||||
8_640_000_000_000_000_000_000n
|
||||
);
|
||||
expect(
|
||||
Temporal.Instant.fromEpochNanoseconds(8_640_000_000_000_000_000_000n).epochNanoseconds
|
||||
).toBe(8_640_000_000_000_000_000_000n);
|
||||
|
||||
expect(Temporal.Instant.fromEpochNanoseconds(-0n).epochNanoseconds).toBe(0n);
|
||||
expect(Temporal.Instant.fromEpochNanoseconds(-1n).epochNanoseconds).toBe(-1n);
|
||||
expect(Temporal.Instant.fromEpochNanoseconds(-999_999_999n).epochNanoseconds).toBe(
|
||||
-999_999_999n
|
||||
expect(Temporal.Instant.fromEpochNanoseconds(-999_999_999n).epochNanoseconds).toBe(-999_999_999n);
|
||||
expect(Temporal.Instant.fromEpochNanoseconds(-8_640_000_000_000_000_000_000n).epochNanoseconds).toBe(
|
||||
-8_640_000_000_000_000_000_000n
|
||||
);
|
||||
expect(
|
||||
Temporal.Instant.fromEpochNanoseconds(-8_640_000_000_000_000_000_000n).epochNanoseconds
|
||||
).toBe(-8_640_000_000_000_000_000_000n);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user