Skip to content

Commit 073bca7

Browse files
grypezclaude
andcommitted
test(kernel-utils): add failing test for -0 vs +0 collapse in metadataKey
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9052050 commit 073bca7

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

packages/kernel-utils/src/sheaf/sheafify.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,44 @@ describe('sheafify', () => {
490490
]);
491491
});
492492

493+
it('does not collapse +0 and -0 metadata as equivalent', async () => {
494+
type Meta = { cost: number };
495+
let germCount = 0;
496+
497+
const sections: PresheafSection<Meta>[] = [
498+
{
499+
exo: makeSection(
500+
'Wallet:0',
501+
M.interface('Wallet:0', {
502+
getBalance: M.call(M.string()).returns(M.number()),
503+
}),
504+
{ getBalance: (_acct: string) => 0 },
505+
),
506+
metadata: constant({ cost: +0 }),
507+
},
508+
{
509+
exo: makeSection(
510+
'Wallet:1',
511+
M.interface('Wallet:1', {
512+
getBalance: M.call(M.string()).returns(M.number()),
513+
}),
514+
{ getBalance: (_acct: string) => 0 },
515+
),
516+
metadata: constant({ cost: -0 }),
517+
},
518+
];
519+
520+
const wallet = sheafify({ name: 'Wallet', sections }).getGlobalSection({
521+
async *lift(germs) {
522+
germCount = germs.length;
523+
yield germs[0]!;
524+
},
525+
});
526+
527+
await E(wallet).getBalance('alice');
528+
expect(germCount).toBe(2);
529+
});
530+
493531
it('does not collapse Infinity and null metadata as equivalent', async () => {
494532
type Meta = { cost: number | null };
495533
let germCount = 0;

0 commit comments

Comments
 (0)