From 9642e2d7446a4796d4a83255375bc3814be12cbc Mon Sep 17 00:00:00 2001 From: Bart Blast Date: Thu, 17 Oct 2024 15:33:52 +0200 Subject: [PATCH] Test boxed tuples 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 447696a97..b5509bcbf 100644 --- a/test/javascript/serializer_test.mjs +++ b/test/javascript/serializer_test.mjs @@ -149,6 +149,29 @@ describe("Serializer", () => { assert.equal(serialize(term), expected); }); }); + + describe("tuple", () => { + it("top-level", () => { + const term = Type.tuple([Type.integer(1), Type.float(1.23)]); + + const expected = + '[1,{"type":"tuple","data":["__integer__:1","__float__:1.23"]}]'; + + assert.equal(serialize(term), expected); + }); + + it("nested", () => { + const term = { + a: Type.tuple([Type.integer(1), Type.float(1.23)]), + b: 2, + }; + + const expected = + '[1,{"a":{"type":"tuple","data":["__integer__:1","__float__:1.23"]},"b":2}]'; + + assert.equal(serialize(term), expected); + }); + }); }); describe("JS terms", () => {