@@ -283,6 +283,126 @@ describe('OSF Parser', () => {
283283      expect ( docBlock . content ) . toBe ( '' ) ; 
284284    } ) ; 
285285
286+     it ( 'should parse negative numeric literals' ,  ( )  =>  { 
287+       const  input  =  `@meta { 
288+         temperature: -25; 
289+         balance: -1000.50; 
290+         offset: -0.5; 
291+         zero: 0; 
292+         positive: 42; 
293+       }` ; 
294+ 
295+       const  result  =  parse ( input ) ; 
296+ 
297+       expect ( result . blocks ) . toHaveLength ( 1 ) ; 
298+       expect ( result . blocks [ 0 ] ?. type ) . toBe ( 'meta' ) ; 
299+ 
300+       const  metaBlock  =  result . blocks [ 0 ]  as  MetaBlock ; 
301+       expect ( metaBlock . props . temperature ) . toBe ( - 25 ) ; 
302+       expect ( metaBlock . props . balance ) . toBe ( - 1000.50 ) ; 
303+       expect ( metaBlock . props . offset ) . toBe ( - 0.5 ) ; 
304+       expect ( metaBlock . props . zero ) . toBe ( 0 ) ; 
305+       expect ( metaBlock . props . positive ) . toBe ( 42 ) ; 
306+     } ) ; 
307+ 
308+     it ( 'should parse negative numbers in arrays' ,  ( )  =>  { 
309+       const  input  =  `@meta { 
310+         values: [-10, -5.5, 0, 5.5, 10]; 
311+         coordinates: [-1, -2, -3]; 
312+       }` ; 
313+ 
314+       const  result  =  parse ( input ) ; 
315+       const  metaBlock  =  result . blocks [ 0 ]  as  MetaBlock ; 
316+       
317+       expect ( metaBlock . props . values ) . toEqual ( [ - 10 ,  - 5.5 ,  0 ,  5.5 ,  10 ] ) ; 
318+       expect ( metaBlock . props . coordinates ) . toEqual ( [ - 1 ,  - 2 ,  - 3 ] ) ; 
319+     } ) ; 
320+ 
321+     it ( 'should parse negative numbers in nested objects' ,  ( )  =>  { 
322+       const  input  =  `@meta { 
323+         position: { x: -10; y: -20.5; z: -0.1; }; 
324+         range: { min: -100; max: 100; }; 
325+       }` ; 
326+ 
327+       const  result  =  parse ( input ) ; 
328+       const  metaBlock  =  result . blocks [ 0 ]  as  MetaBlock ; 
329+       
330+       expect ( metaBlock . props . position ) . toEqual ( {  x : - 10 ,  y : - 20.5 ,  z : - 0.1  } ) ; 
331+       expect ( metaBlock . props . range ) . toEqual ( {  min : - 100 ,  max : 100  } ) ; 
332+     } ) ; 
333+ 
334+     it ( 'should parse negative numbers in sheet data' ,  ( )  =>  { 
335+       const  input  =  `@sheet { 
336+         name: "NegativeNumbers"; 
337+         data { 
338+           (1,1) = -42; 
339+           (1,2) = -3.14159; 
340+           (2,1) = -0.001; 
341+           (2,2) = 100; 
342+         } 
343+       }` ; 
344+ 
345+       const  result  =  parse ( input ) ; 
346+       const  sheetBlock  =  result . blocks [ 0 ]  as  SheetBlock ; 
347+       
348+       expect ( sheetBlock . data ) . toEqual ( { 
349+         '1,1' : - 42 , 
350+         '1,2' : - 3.14159 , 
351+         '2,1' : - 0.001 , 
352+         '2,2' : 100 
353+       } ) ; 
354+     } ) ; 
355+ 
356+     it ( 'should handle edge cases for negative numbers' ,  ( )  =>  { 
357+       const  input  =  `@meta { 
358+         minusZero: -0; 
359+         largeNegative: -999999999; 
360+         smallNegative: -0.000001; 
361+       }` ; 
362+ 
363+       const  result  =  parse ( input ) ; 
364+       const  metaBlock  =  result . blocks [ 0 ]  as  MetaBlock ; 
365+       
366+       expect ( metaBlock . props . minusZero ) . toBe ( - 0 ) ; 
367+       expect ( metaBlock . props . largeNegative ) . toBe ( - 999999999 ) ; 
368+       expect ( metaBlock . props . smallNegative ) . toBe ( - 0.000001 ) ; 
369+     } ) ; 
370+ 
371+     it ( 'should throw error for invalid negative number formats' ,  ( )  =>  { 
372+       const  invalidInputs  =  [ 
373+         `@meta { invalid: -; }` , 
374+         `@meta { invalid: -abc; }` , 
375+         `@meta { invalid: --5; }` , 
376+       ] ; 
377+ 
378+       invalidInputs . forEach ( input  =>  { 
379+         expect ( ( )  =>  parse ( input ) ) . toThrow ( ) ; 
380+       } ) ; 
381+     } ) ; 
382+ 
383+     it ( 'should serialize negative numbers correctly' ,  ( )  =>  { 
384+       const  doc : OSFDocument  =  { 
385+         blocks : [ 
386+           { 
387+             type : 'meta' , 
388+             props : { 
389+               negative : - 42 , 
390+               decimal : - 3.14 , 
391+               zero : - 0 , 
392+               positive : 100 
393+             } 
394+           }  as  MetaBlock 
395+         ] 
396+       } ; 
397+ 
398+       const  serialized  =  serialize ( doc ) ; 
399+       
400+       expect ( serialized ) . toContain ( 'negative: -42' ) ; 
401+       expect ( serialized ) . toContain ( 'decimal: -3.14' ) ; 
402+       expect ( serialized ) . toContain ( 'zero: 0' ) ;  // -0 should serialize as 0 
403+       expect ( serialized ) . toContain ( 'positive: 100' ) ; 
404+     } ) ; 
405+ 
286406  } ) ; 
287407
288408  describe ( 'serialize' ,  ( )  =>  { 
0 commit comments