mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
fix(ext/kv): KvU64#valueOf and KvU64 inspect (#18656)
`new Deno.KvU64(1n) + 2n == 3n` is now true. `new Deno.KvU64(1n)` is now inspected as `[Deno.KvU64: 1n]` (`Object(1n)` is inspected as `[BigInt: 1n]`). --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
798c1ad0f1
commit
93a78d3d4a
3 changed files with 57 additions and 19 deletions
|
@ -578,19 +578,31 @@ Deno.test("KvU64 underflow", () => {
|
|||
}, RangeError);
|
||||
});
|
||||
|
||||
Deno.test("KvU64 frozen", () => {
|
||||
const a = new Deno.KvU64(1n);
|
||||
assertThrows(() => {
|
||||
// @ts-expect-error value is readonly
|
||||
a.value = 2n;
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
Deno.test("KvU64 unbox", () => {
|
||||
const a = new Deno.KvU64(1n);
|
||||
assertEquals(a.value, 1n);
|
||||
});
|
||||
|
||||
Deno.test("KvU64 unbox with valueOf", () => {
|
||||
const a = new Deno.KvU64(1n);
|
||||
assertEquals(a.valueOf(), 1n);
|
||||
});
|
||||
|
||||
Deno.test("KvU64 auto-unbox", () => {
|
||||
const a = new Deno.KvU64(1n);
|
||||
assertEquals(a as unknown as bigint + 1n, 2n);
|
||||
});
|
||||
|
||||
Deno.test("KvU64 toString", () => {
|
||||
const a = new Deno.KvU64(1n);
|
||||
assertEquals(a.toString(), "1");
|
||||
});
|
||||
|
||||
Deno.test("KvU64 inspect", () => {
|
||||
const a = new Deno.KvU64(1n);
|
||||
assertEquals(Deno.inspect(a), "[Deno.KvU64: 1n]");
|
||||
});
|
||||
|
||||
async function collect<T>(
|
||||
iter: Deno.KvListIterator<T>,
|
||||
): Promise<Deno.KvEntry<T>[]> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue