@@ -83,7 +83,7 @@ describe('Function VALUE', () => {
8383 it ( 'should convert string with thousand separator' , ( ) => {
8484 const engine = HyperFormula . buildFromArray ( [
8585 [ '=VALUE("1,234")' ] ,
86- ] )
86+ ] , { thousandSeparator : ',' , functionArgSeparator : ';' } )
8787
8888 expect ( engine . getCellValue ( adr ( 'A1' ) ) ) . toBe ( 1234 )
8989 } )
@@ -95,6 +95,22 @@ describe('Function VALUE', () => {
9595
9696 expect ( engine . getCellValue ( adr ( 'A1' ) ) ) . toBe ( - 123 )
9797 } )
98+
99+ it ( 'should return VALUE error for nested parentheses' , ( ) => {
100+ const engine = HyperFormula . buildFromArray ( [
101+ [ '=VALUE("((123))")' ] ,
102+ ] )
103+
104+ expect ( engine . getCellValue ( adr ( 'A1' ) ) ) . toEqualError ( detailedError ( ErrorType . VALUE , ErrorMessage . NumberCoercion ) )
105+ } )
106+
107+ it ( 'should return VALUE error for unbalanced parentheses' , ( ) => {
108+ const engine = HyperFormula . buildFromArray ( [
109+ [ '=VALUE("(123")' ] ,
110+ ] )
111+
112+ expect ( engine . getCellValue ( adr ( 'A1' ) ) ) . toEqualError ( detailedError ( ErrorType . VALUE , ErrorMessage . NumberCoercion ) )
113+ } )
98114 } )
99115
100116 describe ( 'percentage strings' , ( ) => {
@@ -119,7 +135,7 @@ describe('Function VALUE', () => {
119135 it ( 'should convert currency string with thousand separator and decimal' , ( ) => {
120136 const engine = HyperFormula . buildFromArray ( [
121137 [ '=VALUE("$1,234.56")' ] ,
122- ] )
138+ ] , { thousandSeparator : ',' , functionArgSeparator : ';' } )
123139
124140 expect ( engine . getCellValue ( adr ( 'A1' ) ) ) . toBe ( 1234.56 )
125141 } )
@@ -204,12 +220,15 @@ describe('Function VALUE', () => {
204220 expect ( engine . getCellValue ( adr ( 'A1' ) ) ) . toEqualError ( detailedError ( ErrorType . VALUE , ErrorMessage . NumberCoercion ) )
205221 } )
206222
207- it ( 'should return VALUE error for 12-hour time format without proper config' , ( ) => {
223+ } )
224+
225+ describe ( '12-hour time format' , ( ) => {
226+ it ( 'should parse 12-hour time format with am/pm' , ( ) => {
208227 const engine = HyperFormula . buildFromArray ( [
209228 [ '=VALUE("3:00pm")' ] ,
210229 ] )
211230
212- expect ( engine . getCellValue ( adr ( 'A1' ) ) ) . toEqualError ( detailedError ( ErrorType . VALUE , ErrorMessage . NumberCoercion ) )
231+ expect ( engine . getCellValue ( adr ( 'A1' ) ) ) . toBeCloseTo ( 0.625 , 6 )
213232 } )
214233 } )
215234
@@ -238,9 +257,17 @@ describe('Function VALUE', () => {
238257 expect ( engine . getCellValue ( adr ( 'A1' ) ) ) . toEqualError ( detailedError ( ErrorType . DIV_BY_ZERO ) )
239258 } )
240259
241- it ( 'should convert cell reference with numeric string' , ( ) => {
260+ it ( 'should convert cell reference with string value' , ( ) => {
261+ const engine = HyperFormula . buildFromArray ( [
262+ [ "'123" , '=VALUE(A1)' ] ,
263+ ] )
264+
265+ expect ( engine . getCellValue ( adr ( 'B1' ) ) ) . toBe ( 123 )
266+ } )
267+
268+ it ( 'should pass through cell reference with numeric value' , ( ) => {
242269 const engine = HyperFormula . buildFromArray ( [
243- [ ' 123' , '=VALUE(A1)' ] ,
270+ [ 123 , '=VALUE(A1)' ] ,
244271 ] )
245272
246273 expect ( engine . getCellValue ( adr ( 'B1' ) ) ) . toBe ( 123 )
@@ -251,15 +278,15 @@ describe('Function VALUE', () => {
251278 it ( 'should respect decimal separator config' , ( ) => {
252279 const engine = HyperFormula . buildFromArray ( [
253280 [ '=VALUE("123,45")' ] ,
254- ] , { decimalSeparator : ',' , thousandSeparator : ' ' } )
281+ ] , { decimalSeparator : ',' , thousandSeparator : ' ' , functionArgSeparator : ';' } )
255282
256283 expect ( engine . getCellValue ( adr ( 'A1' ) ) ) . toBe ( 123.45 )
257284 } )
258285
259286 it ( 'should respect thousand separator config' , ( ) => {
260287 const engine = HyperFormula . buildFromArray ( [
261288 [ '=VALUE("1 234,56")' ] ,
262- ] , { decimalSeparator : ',' , thousandSeparator : ' ' } )
289+ ] , { decimalSeparator : ',' , thousandSeparator : ' ' , functionArgSeparator : ';' } )
263290
264291 expect ( engine . getCellValue ( adr ( 'A1' ) ) ) . toBe ( 1234.56 )
265292 } )
0 commit comments