Skip to content

Commit

Permalink
Test JS arrays serializing
Browse files Browse the repository at this point in the history
  • Loading branch information
bartblast committed Oct 17, 2024
1 parent 9642e2d commit 525d52f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/javascript/serializer_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 525d52f

Please sign in to comment.