Skip to content

Commit

Permalink
fixup! merge repair
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Apr 6, 2024
1 parent c3a7d5b commit 939657b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 8 deletions.
13 changes: 12 additions & 1 deletion packages/marshal/test/encodePassable-for-testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,23 @@ const encodePassableInternal = makeEncodePassable({
encodeError: er => encodeThing('!', er),
});

export const encodePassableInternal2 = makeEncodePassable({
encodeRemotable: r => encodeThing('r', r),
encodePromise: p => encodeThing('?', p),
encodeError: er => encodeThing('!', er),
format: 'compactOrdered',
});

export const encodePassable = passable => {
resetBuffers();
return encodePassableInternal(passable);
};

const decodePassableInternal = makeDecodePassable({
export const encodePassable2 = passable => {
resetBuffers();
return encodePassableInternal2(passable);
};
export const decodePassableInternal = makeDecodePassable({
decodeRemotable: e => decodeThing('r', e),
decodePromise: e => decodeThing('?', e),
decodeError: e => decodeThing('!', e),
Expand Down
53 changes: 49 additions & 4 deletions packages/marshal/test/test-encodePassable.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/* eslint-disable no-bitwise, @endo/restrict-comparison-operands */
import test from '@endo/ses-ava/prepare-endo.js';

Expand All @@ -6,17 +7,61 @@ import { Remotable } from '@endo/pass-style';
import { arbPassable } from '@endo/pass-style/tools.js';
import { Fail } from '@endo/errors';

// eslint-disable-next-line import/no-extraneous-dependencies

import { makePassableKit, makeEncodePassable } from '../src/encodePassable.js';
import { compareRank } from '../src/rankOrder.js';
import { sample } from './test-rankOrder.js';
import { unsortedSample } from './marshal-test-data.js';

import {
encodePassable,
encodePassable2,
encodePassableInternal2,
decodePassable,
decodePassableInternal,
compareFull,
} from './encodePassable-for-testing.js';

test('makePassableKit output shape', t => {
const kit = makePassableKit();
t.deepEqual(Reflect.ownKeys(kit).sort(), [
'decodePassable',
'encodePassable',
]);
t.deepEqual(
Object.fromEntries(
Object.entries(kit).map(([key, value]) => [key, typeof value]),
),
{ encodePassable: 'function', decodePassable: 'function' },
);
});

const verifyEncodeOptions = test.macro({
title: label => `${label} encode options validation`,
// eslint-disable-next-line no-shadow
exec: (t, makeEncodePassable) => {
t.notThrows(() => makeEncodePassable(), 'must accept zero arguments');
t.notThrows(() => makeEncodePassable({}), 'must accept empty options');
t.notThrows(
() => makeEncodePassable({ format: 'legacyOrdered' }),
'must accept format: "legacyOrdered"',
);
t.notThrows(
() => makeEncodePassable({ format: 'compactOrdered' }),
'must accept format: "compactOrdered"',
);
t.throws(
() => makeEncodePassable({ format: 'newHotness' }),
{ message: /^Unrecognized format\b/ },
'must reject unknown format',
);
},
});
test('makeEncodePassable', verifyEncodeOptions, makeEncodePassable);
test(
'makePassableKit',
verifyEncodeOptions,
(...args) => makePassableKit(...args).encodePassable,
);

const asNumber = new Float64Array(1);
const asBits = new BigUint64Array(asNumber.buffer);
const getNaN = (hexEncoding = '0008000000000000') => {
Expand All @@ -31,7 +76,7 @@ const getNaN = (hexEncoding = '0008000000000000') => {

const NegativeNaN = getNaN('ffffffffffffffff');

/** @type {[number | bigint, string][]} */
/** @type {[Key, string][]} */
const goldenPairs = harden([
[1, 'fbff0000000000000'],
[-1, 'f400fffffffffffff'],
Expand Down
2 changes: 1 addition & 1 deletion packages/marshal/test/test-string-rank-order.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from './prepare-test-env-ava.js';
import test from '@endo/ses-ava/prepare-endo.js';

import { compareRank } from '../src/rankOrder.js';
import { encodePassable } from './encodePassable-for-testing.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/patterns/test/test-string-key-order.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// modeled on test-string-rank-order.js

import { test } from './prepare-test-env-ava.js';
import test from '@endo/ses-ava/prepare-endo.js';

import { compareKeys } from '../src/keys/compareKeys.js';

Expand Down

0 comments on commit 939657b

Please sign in to comment.