Skip to content

Commit

Permalink
test(marshal): Make a macro for encodePassable round-trip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Sep 7, 2023
1 parent 30bce94 commit 85aa08c
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions packages/marshal/test/test-encodePassable.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,30 +170,19 @@ const orderInvariants = (x, y) => {
}
};

test('Passables round-trip', async t => {
const testRoundTrip = test.macro(async (t, encode) => {
await fc.assert(
fc.property(arbPassable, n => {
const en = encodePassable(n);
const en = encode(n);
const rt = decodePassable(en);
const er = encodePassable(rt);
t.is(en, er);
t.is(compareFull(n, rt), 0);
}),
);
});
// TODO: Implement via macro
// https://github.com/avajs/ava/blob/main/docs/01-writing-tests.md#reusing-test-logic-through-macros
test('Small-encoded passables round-trip', async t => {
await fc.assert(
fc.property(arbPassable, n => {
const en = encodePassable2(n);
const rt = decodePassable(en);
const er = encodePassable2(rt);
const er = encode(rt);
t.is(en, er);
t.is(compareFull(n, rt), 0);
}),
);
});
test('original encoding round-trips', testRoundTrip, encodePassable);
test('small encoding round-trips', testRoundTrip, encodePassable2);

test('BigInt encoding comparison corresponds with numeric comparison', async t => {
await fc.assert(
Expand Down

0 comments on commit 85aa08c

Please sign in to comment.