diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d369e95a7a..1dbb3336db 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,19 @@ +20000403-01:26 GMT+1 Victor Szakats + + * source/vm/itemapi.c + ! hb_itemStr() 9 character limit on decimals removed. + Now seven more tests pass. + + * source/vm/hvm.c + ! hb_vmPushDouble() 9 character limit on decimals removed. + Now newly added tests pass. + + * utils/hbtest/rt_str.prg + + New STR() tests added. + + * utils/hbtest/hbtest.prg + + Shows the percentage of the passes compared to the number of tests. + 20000402-23:44 GMT+2 Maurilio Longo * source/rtl/gtos2/gtos2.c diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 6a62f3ab66..70cb8bb65e 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -1189,7 +1189,7 @@ static void hb_vmNegate( void ) else if( HB_IS_DOUBLE( pItem ) ) { pItem->item.asDouble.value = -pItem->item.asDouble.value; - pItem->item.asDouble.length = pItem->item.asDouble.value >= 10000000000.0 ? 20 : 10; + pItem->item.asDouble.length = ( pItem->item.asDouble.value >= 10000000000.0 || pItem->item.asDouble.value <= -10000000000.0 ) ? 20 : 10; } else { @@ -2820,11 +2820,11 @@ void hb_vmPushDouble( double dNumber, int iDec ) hb_stack.pPos->type = HB_IT_DOUBLE; hb_stack.pPos->item.asDouble.value = dNumber; - hb_stack.pPos->item.asDouble.length = ( dNumber > 10000000000.0 ) ? 20 : 10; + hb_stack.pPos->item.asDouble.length = ( dNumber > 10000000000.0 || dNumber <= -10000000000.0 ) ? 20 : 10; if( iDec == HB_DEFAULT_DECIMALS ) hb_stack.pPos->item.asDouble.decimal = hb_set.HB_SET_DECIMALS; else - hb_stack.pPos->item.asDouble.decimal = ( iDec > 9 ) ? 9 : iDec; + hb_stack.pPos->item.asDouble.decimal = iDec; hb_stackPush(); } diff --git a/harbour/source/vm/itemapi.c b/harbour/source/vm/itemapi.c index da5c0ce5ca..0393db49a3 100644 --- a/harbour/source/vm/itemapi.c +++ b/harbour/source/vm/itemapi.c @@ -1155,8 +1155,7 @@ char * hb_itemStr( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec ) if( pNumber ) { /* Default to the width and number of decimals specified by the item, - with a limit of 20 integer places and 9 decimal places, plus one - space for the sign. */ + with a limit of 20 integer places, plus one space for the sign. */ int iWidth; int iDec; @@ -1164,8 +1163,7 @@ char * hb_itemStr( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec ) if( iWidth > 20 ) iWidth = 20; - if( iDec > 9 ) - iDec = 9; + if( hb_set.HB_SET_FIXED ) iDec = hb_set.HB_SET_DECIMALS; @@ -1176,7 +1174,7 @@ char * hb_itemStr( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec ) int iWidthPar = hb_itemGetNI( pWidth ); if( iWidthPar < 1 ) - iWidth = 10; /* If 0 or negative, use default */ + iWidth = 10; /* If 0 or negative, use default */ else iWidth = iWidthPar; diff --git a/harbour/utils/hbtest/hbtest.prg b/harbour/utils/hbtest/hbtest.prg index 2f34c14298..1a557575dd 100644 --- a/harbour/utils/hbtest/hbtest.prg +++ b/harbour/utils/hbtest/hbtest.prg @@ -355,7 +355,7 @@ STATIC FUNCTION TEST_END() s_nEndTime := Seconds() FWrite( s_nFhnd, "===========================================================================" + HB_OSNewLine() +; - "Test calls passed: " + Str( s_nPass ) + HB_OSNewLine() +; + "Test calls passed: " + Str( s_nPass ) + " ( " + LTrim( Str( ( 1 - ( s_nFail / s_nPass ) ) * 100, 6, 2 ) ) + " % )" + HB_OSNewLine() +; "Test calls failed: " + Str( s_nFail ) + " ( " + LTrim( Str( ( s_nFail / s_nPass ) * 100, 6, 2 ) ) + " % )" + HB_OSNewLine() +; " ----------" + HB_OSNewLine() +; " Total: " + Str( s_nPass + s_nFail ) +; diff --git a/harbour/utils/hbtest/rt_str.prg b/harbour/utils/hbtest/rt_str.prg index cff8682cd4..fcdb0ea679 100644 --- a/harbour/utils/hbtest/rt_str.prg +++ b/harbour/utils/hbtest/rt_str.prg @@ -689,9 +689,20 @@ FUNCTION Main_STR() TEST_LINE( Str( w_TEST->TYPE_N_D ) , " 101.127" ) TEST_LINE( Str( w_TEST->TYPE_N_DE ) , " 0.000" ) TEST_LINE( Str(5000000000.0) , "5000000000.0" ) + TEST_LINE( Str(50000000) , " 50000000" ) + TEST_LINE( Str(500000000) , " 500000000" ) TEST_LINE( Str(5000000000) , " 5000000000" ) + TEST_LINE( Str(50000000000) , " 50000000000" ) TEST_LINE( Str(-5000000000.0) , " -5000000000.0" ) - TEST_LINE( Str(-5000000000) , " -5000000000" ) + TEST_LINE( Str(-5000000000) , " -5000000000" ) + TEST_LINE( Str(2.0000000000000001) , " 2.0000000000000000" ) + TEST_LINE( Str(2.0000000000000009) , " 2.0000000000000010" ) + TEST_LINE( Str(2.000000000000001) , " 2.000000000000001" ) + TEST_LINE( Str(2.000000000000009) , " 2.000000000000009" ) + TEST_LINE( Str(2.00000000000001) , " 2.00000000000001" ) + TEST_LINE( Str(2.00000000000009) , " 2.00000000000009" ) + TEST_LINE( Str(2.000000000001) , " 2.000000000001" ) + TEST_LINE( Str(2.00000000001) , " 2.00000000001" ) TEST_LINE( Str(10) , " 10" ) TEST_LINE( Str(10.0) , " 10.0" ) TEST_LINE( Str(10.00) , " 10.00" )