1
+ // @ts -nocheck
1
2
/* eslint-disable no-bitwise, @endo/restrict-comparison-operands */
2
3
import test from '@endo/ses-ava/prepare-endo.js' ;
3
4
@@ -6,17 +7,61 @@ import { Remotable } from '@endo/pass-style';
6
7
import { arbPassable } from '@endo/pass-style/tools.js' ;
7
8
import { Fail } from '@endo/errors' ;
8
9
9
- // eslint-disable-next-line import/no-extraneous-dependencies
10
-
10
+ import { makePassableKit , makeEncodePassable } from '../src/encodePassable.js' ;
11
11
import { compareRank } from '../src/rankOrder.js' ;
12
- import { sample } from './test-rankOrder .js' ;
12
+ import { unsortedSample } from './marshal- test-data .js' ;
13
13
14
14
import {
15
15
encodePassable ,
16
+ encodePassable2 ,
17
+ encodePassableInternal2 ,
16
18
decodePassable ,
19
+ decodePassableInternal ,
17
20
compareFull ,
18
21
} from './encodePassable-for-testing.js' ;
19
22
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 : / ^ U n r e c o g n i z e d f o r m a t \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
+
20
65
const asNumber = new Float64Array ( 1 ) ;
21
66
const asBits = new BigUint64Array ( asNumber . buffer ) ;
22
67
const getNaN = ( hexEncoding = '0008000000000000' ) => {
@@ -31,7 +76,7 @@ const getNaN = (hexEncoding = '0008000000000000') => {
31
76
32
77
const NegativeNaN = getNaN ( 'ffffffffffffffff' ) ;
33
78
34
- /** @type {[number | bigint , string][] } */
79
+ /** @type {[Key , string][] } */
35
80
const goldenPairs = harden ( [
36
81
[ 1 , 'fbff0000000000000' ] ,
37
82
[ - 1 , 'f400fffffffffffff' ] ,
0 commit comments