From 525d52f480200bba9968fae34311e22f3e05827c Mon Sep 17 00:00:00 2001 From: Bart Blast Date: Thu, 17 Oct 2024 15:38:40 +0200 Subject: [PATCH] Test JS arrays serializing --- test/javascript/serializer_test.mjs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/javascript/serializer_test.mjs b/test/javascript/serializer_test.mjs index b5509bcbf..7e7b4d0ff 100644 --- a/test/javascript/serializer_test.mjs +++ b/test/javascript/serializer_test.mjs @@ -175,6 +175,29 @@ describe("Serializer", () => { }); describe("JS terms", () => { + describe("array", () => { + it("top-level", () => { + const term = [123, Type.float(2.34), Type.bitstring([1, 0, 1, 0])]; + + const expected = + '[1,[123,"__float__:2.34",{"type":"bitstring","bits":[1,0,1,0]}]]'; + + assert.equal(serialize(term), expected); + }); + + it("nested", () => { + const term = { + a: [123, Type.float(2.34), Type.bitstring([1, 0, 1, 0])], + b: 2, + }; + + const expected = + '[1,{"a":[123,"__float__:2.34",{"type":"bitstring","bits":[1,0,1,0]}],"b":2}]'; + + assert.equal(serialize(term), expected); + }); + }); + describe("BigInt", () => { it("top-level", () => { const term = 123n;