Skip to content

Commit 567b23c

Browse files
committed
fixup! merge repair
1 parent 1e5b6d5 commit 567b23c

File tree

4 files changed

+63
-8
lines changed

4 files changed

+63
-8
lines changed

packages/marshal/test/encodePassable-for-testing.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,23 @@ const encodePassableInternal = makeEncodePassable({
5454
encodeError: er => encodeThing('!', er),
5555
});
5656

57+
export const encodePassableInternal2 = makeEncodePassable({
58+
encodeRemotable: r => encodeThing('r', r),
59+
encodePromise: p => encodeThing('?', p),
60+
encodeError: er => encodeThing('!', er),
61+
format: 'compactOrdered',
62+
});
63+
5764
export const encodePassable = passable => {
5865
resetBuffers();
5966
return encodePassableInternal(passable);
6067
};
6168

62-
const decodePassableInternal = makeDecodePassable({
69+
export const encodePassable2 = passable => {
70+
resetBuffers();
71+
return encodePassableInternal2(passable);
72+
};
73+
export const decodePassableInternal = makeDecodePassable({
6374
decodeRemotable: e => decodeThing('r', e),
6475
decodePromise: e => decodeThing('?', e),
6576
decodeError: e => decodeThing('!', e),

packages/marshal/test/test-encodePassable.js

+49-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
/* eslint-disable no-bitwise, @endo/restrict-comparison-operands */
23
import test from '@endo/ses-ava/prepare-endo.js';
34

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

9-
// eslint-disable-next-line import/no-extraneous-dependencies
10-
10+
import { makePassableKit, makeEncodePassable } from '../src/encodePassable.js';
1111
import { compareRank } from '../src/rankOrder.js';
12-
import { sample } from './test-rankOrder.js';
12+
import { unsortedSample } from './marshal-test-data.js';
1313

1414
import {
1515
encodePassable,
16+
encodePassable2,
17+
encodePassableInternal2,
1618
decodePassable,
19+
decodePassableInternal,
1720
compareFull,
1821
} from './encodePassable-for-testing.js';
1922

23+
test('makePassableKit output shape', t => {
24+
const kit = makePassableKit();
25+
t.deepEqual(Reflect.ownKeys(kit).sort(), [
26+
'decodePassable',
27+
'encodePassable',
28+
]);
29+
t.deepEqual(
30+
Object.fromEntries(
31+
Object.entries(kit).map(([key, value]) => [key, typeof value]),
32+
),
33+
{ encodePassable: 'function', decodePassable: 'function' },
34+
);
35+
});
36+
37+
const verifyEncodeOptions = test.macro({
38+
title: label => `${label} encode options validation`,
39+
// eslint-disable-next-line no-shadow
40+
exec: (t, makeEncodePassable) => {
41+
t.notThrows(() => makeEncodePassable(), 'must accept zero arguments');
42+
t.notThrows(() => makeEncodePassable({}), 'must accept empty options');
43+
t.notThrows(
44+
() => makeEncodePassable({ format: 'legacyOrdered' }),
45+
'must accept format: "legacyOrdered"',
46+
);
47+
t.notThrows(
48+
() => makeEncodePassable({ format: 'compactOrdered' }),
49+
'must accept format: "compactOrdered"',
50+
);
51+
t.throws(
52+
() => makeEncodePassable({ format: 'newHotness' }),
53+
{ message: /^Unrecognized format\b/ },
54+
'must reject unknown format',
55+
);
56+
},
57+
});
58+
test('makeEncodePassable', verifyEncodeOptions, makeEncodePassable);
59+
test(
60+
'makePassableKit',
61+
verifyEncodeOptions,
62+
(...args) => makePassableKit(...args).encodePassable,
63+
);
64+
2065
const asNumber = new Float64Array(1);
2166
const asBits = new BigUint64Array(asNumber.buffer);
2267
const getNaN = (hexEncoding = '0008000000000000') => {
@@ -31,7 +76,7 @@ const getNaN = (hexEncoding = '0008000000000000') => {
3176

3277
const NegativeNaN = getNaN('ffffffffffffffff');
3378

34-
/** @type {[number | bigint, string][]} */
79+
/** @type {[Key, string][]} */
3580
const goldenPairs = harden([
3681
[1, 'fbff0000000000000'],
3782
[-1, 'f400fffffffffffff'],

packages/marshal/test/test-string-rank-order.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test } from './prepare-test-env-ava.js';
1+
import test from '@endo/ses-ava/prepare-endo.js';
22

33
import { compareRank } from '../src/rankOrder.js';
44
import { encodePassable } from './encodePassable-for-testing.js';

packages/patterns/test/test-string-key-order.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// modeled on test-string-rank-order.js
2-
3-
import { test } from './prepare-test-env-ava.js';
2+
import test from '@endo/ses-ava/prepare-endo.js';
43

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

0 commit comments

Comments
 (0)