From 26fde59322bf8f49ee7fb8d3d9d0209d20e71774 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 13 Apr 2008 20:05:38 +0000 Subject: [PATCH] 2008-04-13 21:59 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * source/rtl/mod.c ! Fixed error object to be C5x compatible when wrong or too few parameters were passed to MOD(). Now the previously corrected MOD() regression tests pass. (I misinterpreted the problem in the previous ChangeLog entry.) * utils/hbtest/rt_math.prg + Added two new tests for MOD() --- harbour/ChangeLog | 14 ++++++++++---- harbour/source/rtl/mod.c | 8 +++++++- harbour/utils/hbtest/rt_math.prg | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index fb74ef6359..2a72a60b09 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-04-13 21:59 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * source/rtl/mod.c + ! Fixed error object to be C5x compatible when wrong or too + few parameters were passed to MOD(). Now the previously + corrected MOD() regression tests pass. (I misinterpreted + the problem in the previous ChangeLog entry.) + + * utils/hbtest/rt_math.prg + + Added two new tests for MOD() + 2008-04-13 19:19 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * common.mak + utils/hbtest/rt_main.h @@ -37,10 +47,6 @@ * utils/hbtest/rt_math.prg ! Corrected expected C5.2/5.3 result for 'MOD()'. - TOFIX: The Harbour result is different, and in contrary to - C5.x it won't allow to substitue values from the - error handler, when wrong types were passed initially, - which is IMO a bug. * utils/hbtest/rt_misc.prg ! Some results synced with C5.x (where the result could be diff --git a/harbour/source/rtl/mod.c b/harbour/source/rtl/mod.c index 8b1d81055d..e0206f05c3 100644 --- a/harbour/source/rtl/mod.c +++ b/harbour/source/rtl/mod.c @@ -99,7 +99,13 @@ HB_FUNC( MOD ) } } else - hb_errRT_BASE_SubstR( EG_ARG, 1085, NULL, "%", HB_ERR_ARGS_BASEPARAMS ); + { + PHB_ITEM pItemNIL = hb_itemNew( NULL ); + + hb_errRT_BASE_SubstR( EG_ARG, 1085, NULL, "%", 2, hb_pcount() > 0 ? hb_param( 1, HB_IT_ANY ) : pItemNIL, hb_pcount() > 1 ? hb_param( 2, HB_IT_ANY ) : pItemNIL ); + + hb_itemRelease( pItemNIL ); + } } /* diff --git a/harbour/utils/hbtest/rt_math.prg b/harbour/utils/hbtest/rt_math.prg index 60ac9b12e1..136466ed40 100644 --- a/harbour/utils/hbtest/rt_math.prg +++ b/harbour/utils/hbtest/rt_math.prg @@ -361,6 +361,8 @@ FUNCTION Main_MATH() /* MOD() */ TEST_LINE( MOD() , "E BASE 1085 Argument error % A:2:U:NIL;U:NIL F:S" ) + TEST_LINE( MOD( NIL ) , "E BASE 1085 Argument error % A:2:U:NIL;U:NIL F:S" ) + TEST_LINE( MOD( 100 ) , "E BASE 1085 Argument error % A:2:N:100;U:NIL F:S" ) TEST_LINE( MOD( "A", "B" ) , "E BASE 1085 Argument error % A:2:C:A;C:B F:S" ) TEST_LINE( MOD( "A", 100 ) , "E BASE 1085 Argument error % A:2:C:A;N:100 F:S" ) TEST_LINE( MOD( 100, "B" ) , "E BASE 1085 Argument error % A:2:N:100;C:B F:S" )