diff options
author | Luca Casonato <hello@lcas.dev> | 2023-05-03 12:44:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-03 11:44:00 +0000 |
commit | 93a78d3d4aedb96cfc2641048532c95197f661bb (patch) | |
tree | 27698b73a919cb2f013b3fb982802ae376103f78 /cli/tests/unit | |
parent | 798c1ad0f1de80ff0e7196b6140a3f74e31fe111 (diff) |
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>
Diffstat (limited to 'cli/tests/unit')
-rw-r--r-- | cli/tests/unit/kv_test.ts | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/cli/tests/unit/kv_test.ts b/cli/tests/unit/kv_test.ts index 5a202fb0b..3a3476857 100644 --- a/cli/tests/unit/kv_test.ts +++ b/cli/tests/unit/kv_test.ts @@ -578,17 +578,29 @@ Deno.test("KvU64 underflow", () => { }, RangeError); }); -Deno.test("KvU64 frozen", () => { +Deno.test("KvU64 unbox", () => { const a = new Deno.KvU64(1n); - assertThrows(() => { - // @ts-expect-error value is readonly - a.value = 2n; - }, TypeError); + assertEquals(a.value, 1n); }); -Deno.test("KvU64 unbox", () => { +Deno.test("KvU64 unbox with valueOf", () => { const a = new Deno.KvU64(1n); - assertEquals(a.value, 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>( |