File tree Expand file tree Collapse file tree
packages/kernel-utils/src/sheaf Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments