diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-08-16 18:03:27 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-08-16 18:03:27 (GMT) |
commit | 57102e40e92f6bcde3433f2971c5f9c891cbaec5 (patch) | |
tree | 82077ab0edca5c3b59bda159360658698f92615f | |
parent | afc4e512cb5887c4ba160007e09e4a1ed9d8b438 (diff) | |
download | tcl-57102e40e92f6bcde3433f2971c5f9c891cbaec5.zip tcl-57102e40e92f6bcde3433f2971c5f9c891cbaec5.tar.gz tcl-57102e40e92f6bcde3433f2971c5f9c891cbaec5.tar.bz2 |
Experiment, resolving platform differences at script level. Don't look ...
-rw-r--r-- | generic/tclBasic.c | 47 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 7 | ||||
-rw-r--r-- | generic/tclCompCmdsSZ.c | 3 | ||||
-rw-r--r-- | generic/tclExecute.c | 11 | ||||
-rw-r--r-- | generic/tclInt.h | 4 | ||||
-rw-r--r-- | generic/tclObj.c | 6 | ||||
-rw-r--r-- | generic/tclStubInit.c | 4 | ||||
-rw-r--r-- | tests/compExpr-old.test | 6 | ||||
-rw-r--r-- | tests/expr.test | 219 | ||||
-rw-r--r-- | tests/format.test | 15 | ||||
-rw-r--r-- | tests/obj.test | 16 | ||||
-rw-r--r-- | tests/scan.test | 4 | ||||
-rw-r--r-- | tests/string.test | 12 | ||||
-rw-r--r-- | tests/uplevel.test | 16 |
14 files changed, 149 insertions, 221 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 81e1927..b7a6a24 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -116,7 +116,6 @@ static Tcl_ObjCmdProc ExprCeilFunc; static Tcl_ObjCmdProc ExprDoubleFunc; static Tcl_ObjCmdProc ExprEntierFunc; static Tcl_ObjCmdProc ExprFloorFunc; -static Tcl_ObjCmdProc ExprIntFunc; static Tcl_ObjCmdProc ExprIsqrtFunc; static Tcl_ObjCmdProc ExprMaxFunc; static Tcl_ObjCmdProc ExprMinFunc; @@ -125,7 +124,7 @@ static Tcl_ObjCmdProc ExprRoundFunc; static Tcl_ObjCmdProc ExprSqrtFunc; static Tcl_ObjCmdProc ExprSrandFunc; static Tcl_ObjCmdProc ExprUnaryFunc; -static Tcl_ObjCmdProc ExprWideFunc; +static Tcl_ObjCmdProc ExprIntFunc; static void MathFuncWrongNumArgs(Tcl_Interp *interp, int expected, int actual, Tcl_Obj *const *objv); static Tcl_NRPostProc NRCoroutineCallerCallback; @@ -336,7 +335,7 @@ static const BuiltinFuncDef BuiltinFuncTable[] = { { "srand", ExprSrandFunc, NULL }, { "tan", ExprUnaryFunc, (ClientData) tan }, { "tanh", ExprUnaryFunc, (ClientData) tanh }, - { "wide", ExprWideFunc, NULL }, + { "wide", ExprIntFunc, NULL }, { NULL, NULL, NULL } }; @@ -3660,16 +3659,8 @@ OldMathFuncProc( args[k].doubleValue = d; break; case TCL_INT: - if (ExprIntFunc(NULL, interp, 2, &objv[j-1]) != TCL_OK) { - ckfree(args); - return TCL_ERROR; - } - valuePtr = Tcl_GetObjResult(interp); - Tcl_GetLongFromObj(NULL, valuePtr, &args[k].intValue); - Tcl_ResetResult(interp); - break; case TCL_WIDE_INT: - if (ExprWideFunc(NULL, interp, 2, &objv[j-1]) != TCL_OK) { + if (ExprIntFunc(NULL, interp, 2, &objv[j-1]) != TCL_OK) { ckfree(args); return TCL_ERROR; } @@ -7680,38 +7671,6 @@ ExprIntFunc( int objc, /* Actual parameter count. */ Tcl_Obj *const *objv) /* Actual parameter vector. */ { - long iResult; - Tcl_Obj *objPtr; - if (ExprEntierFunc(NULL, interp, objc, objv) != TCL_OK) { - return TCL_ERROR; - } - objPtr = Tcl_GetObjResult(interp); - if (TclGetLongFromObj(NULL, objPtr, &iResult) != TCL_OK) { - /* - * Truncate the bignum; keep only bits in long range. - */ - - mp_int big; - - Tcl_GetBignumFromObj(NULL, objPtr, &big); - mp_mod_2d(&big, (int) CHAR_BIT * sizeof(long), &big); - objPtr = Tcl_NewBignumObj(&big); - Tcl_IncrRefCount(objPtr); - TclGetLongFromObj(NULL, objPtr, &iResult); - Tcl_DecrRefCount(objPtr); - } - Tcl_SetObjResult(interp, Tcl_NewLongObj(iResult)); - return TCL_OK; -} - -static int -ExprWideFunc( - ClientData clientData, /* Ignored. */ - Tcl_Interp *interp, /* The interpreter in which to execute the - * function. */ - int objc, /* Actual parameter count. */ - Tcl_Obj *const *objv) /* Actual parameter vector. */ -{ Tcl_WideInt wResult; Tcl_Obj *objPtr; diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 0bd6cb4..f99a4a0 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -1622,11 +1622,6 @@ StringIsCmd( case STR_IS_GRAPH: chcomp = Tcl_UniCharIsGraph; break; - case STR_IS_INT: - if (TCL_OK == TclGetIntFromObj(NULL, objPtr, &i)) { - break; - } - goto failedIntParse; case STR_IS_ENTIER: if ((objPtr->typePtr == &tclIntType) || (objPtr->typePtr == &tclBignumType)) { @@ -1669,12 +1664,12 @@ StringIsCmd( failat = 0; } break; + case STR_IS_INT: case STR_IS_WIDE: if (TCL_OK == TclGetWideIntFromObj(NULL, objPtr, &w)) { break; } - failedIntParse: string1 = TclGetStringFromObj(objPtr, &length1); if (length1 == 0) { if (strict) { diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index 9434e54..8ab1ffa 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -692,9 +692,6 @@ TclCompileStringIsCmd( switch (t) { case STR_IS_INT: - PUSH( "1"); - OP( EQ); - break; case STR_IS_WIDE: PUSH( "2"); OP( LE); diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 82de752..034bfd2 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5634,18 +5634,9 @@ TEBCresume( case INST_NUM_TYPE: if (GetNumberFromObj(NULL, OBJ_AT_TOS, &ptr1, &type1) != TCL_OK) { type1 = 0; - } else if (type1 == TCL_NUMBER_WIDE) { - /* value is between LLONG_MIN and LLONG_MAX */ - /* [string is integer] is -UINT_MAX to UINT_MAX range */ - /* [string is wideinteger] is -ULLONG_MAX to ULLONG_MAX range */ - int i; - - if (Tcl_GetIntFromObj(NULL, OBJ_AT_TOS, &i) == TCL_OK) { - type1 = TCL_NUMBER_LONG; - } } else if (type1 == TCL_NUMBER_BIG) { /* value is an integer outside the LLONG_MIN to LLONG_MAX range */ - /* [string is wideinteger] is -ULLONG_MAX to ULLONG_MAX range */ + /* [string is wideinteger] is LLONG_MIN to LLONG_MAX range */ Tcl_WideInt w; if (Tcl_GetWideIntFromObj(NULL, OBJ_AT_TOS, &w) == TCL_OK) { diff --git a/generic/tclInt.h b/generic/tclInt.h index 64e7c67..c1e24f5 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2493,7 +2493,7 @@ typedef struct List { #else #define TclGetLongFromObj(interp, objPtr, longPtr) \ (((objPtr)->typePtr == &tclIntType \ - && (objPtr)->internalRep.wideValue >= -(Tcl_WideInt)(ULONG_MAX) \ + && (objPtr)->internalRep.wideValue >= (Tcl_WideInt)(LONG_MIN) \ && (objPtr)->internalRep.wideValue <= (Tcl_WideInt)(ULONG_MAX)) \ ? ((*(longPtr) = (long)(objPtr)->internalRep.wideValue), TCL_OK) \ : Tcl_GetLongFromObj((interp), (objPtr), (longPtr))) @@ -2501,7 +2501,7 @@ typedef struct List { #define TclGetIntFromObj(interp, objPtr, intPtr) \ (((objPtr)->typePtr == &tclIntType \ - && (objPtr)->internalRep.wideValue >= -(Tcl_WideInt)(UINT_MAX) \ + && (objPtr)->internalRep.wideValue >= (Tcl_WideInt)(INT_MIN) \ && (objPtr)->internalRep.wideValue <= (Tcl_WideInt)(UINT_MAX)) \ ? ((*(intPtr) = (int)(objPtr)->internalRep.wideValue), TCL_OK) \ : Tcl_GetIntFromObj((interp), (objPtr), (intPtr))) diff --git a/generic/tclObj.c b/generic/tclObj.c index e10cbd7..40c27d5 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -2563,7 +2563,7 @@ Tcl_GetIntFromObj( if (TclGetLongFromObj(interp, objPtr, &l) != TCL_OK) { return TCL_ERROR; } - if ((ULONG_MAX > UINT_MAX) && ((l > UINT_MAX) || (l < -(long)UINT_MAX))) { + if ((ULONG_MAX > UINT_MAX) && ((l > (long)(UINT_MAX)) || (l < (long)(INT_MIN)))) { if (interp != NULL) { const char *s = "integer value too large to represent as non-long integer"; @@ -2870,7 +2870,7 @@ Tcl_GetLongFromObj( #else if (objPtr->typePtr == &tclIntType) { /* - * We return any integer in the range -ULONG_MAX to ULONG_MAX + * We return any integer in the range LONG_MIN to ULONG_MAX * converted to a long, ignoring overflow. The rule preserves * existing semantics for conversion of integers on input, but * avoids inadvertent demotion of wide integers to 32-bit ones in @@ -2879,7 +2879,7 @@ Tcl_GetLongFromObj( Tcl_WideInt w = objPtr->internalRep.wideValue; - if (w >= -(Tcl_WideInt)(ULONG_MAX) + if (w >= (Tcl_WideInt)(LONG_MIN) && w <= (Tcl_WideInt)(ULONG_MAX)) { *longPtr = Tcl_WideAsLong(w); return TCL_OK; diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index a3641f9..94b5561 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -271,7 +271,7 @@ static int exprInt(Tcl_Interp *interp, const char *expr, int *ptr){ long longValue; int result = Tcl_ExprLong(interp, expr, &longValue); if (result == TCL_OK) { - if ((longValue >= -(long)(UINT_MAX)) + if ((longValue >= (long)(INT_MIN)) && (longValue <= (long)(UINT_MAX))) { *ptr = (int)longValue; } else { @@ -287,7 +287,7 @@ static int exprIntObj(Tcl_Interp *interp, Tcl_Obj*expr, int *ptr){ long longValue; int result = Tcl_ExprLongObj(interp, expr, &longValue); if (result == TCL_OK) { - if ((longValue >= -(long)(UINT_MAX)) + if ((longValue >= (long)(INT_MIN)) && (longValue <= (long)(UINT_MAX))) { *ptr = (int)longValue; } else { diff --git a/tests/compExpr-old.test b/tests/compExpr-old.test index 0136ccd..4354520 100644 --- a/tests/compExpr-old.test +++ b/tests/compExpr-old.test @@ -79,7 +79,6 @@ proc testIEEE {} { testConstraint ieeeFloatingPoint [testIEEE] testConstraint longIs32bit [expr {int(0x80000000) < 0}] -testConstraint longIs64bit [expr {int(0x8000000000000000) < 0}] # procedures used below @@ -335,12 +334,9 @@ test compExpr-old-9.4 {CompileRelationalExpr: just shift expr} {expr {1<<3}} 8 # The following test is different for 32-bit versus 64-bit # architectures because LONG_MIN is different -test compExpr-old-9.5a {CompileRelationalExpr: shift expr producing LONG_MIN} longIs64bit { +test compExpr-old-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} { expr {int(1<<63)} } -9223372036854775808 -test compExpr-old-9.5b {CompileRelationalExpr: shift expr producing LONG_MIN} longIs32bit { - expr {int(1<<31)} -} -2147483648 test compExpr-old-9.6 {CompileRelationalExpr: error in shift expr} -body { expr x>>3 diff --git a/tests/expr.test b/tests/expr.test index 713681a..30a80ad 100644 --- a/tests/expr.test +++ b/tests/expr.test @@ -18,13 +18,10 @@ if {[lsearch [namespace children] ::tcltest] == -1} { ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] -# Determine if "long int" type is a 32 bit number and if the wide -# type is a 64 bit number on this machine. +# Determine if "long int" type is a 32 bit number. testConstraint longIs32bit [expr {int(0x80000000) < 0}] testConstraint longIs64bit [expr {int(0x8000000000000000) < 0}] -testConstraint wideIs64bit \ - [expr {(wide(0x80000000) > 0) && (wide(0x8000000000000000) < 0)}] # Big test for correct ordering of data in [expr] @@ -5846,7 +5843,7 @@ test expr-33.2 {parse smallest long value} longIs32bit { [expr {int(-2147483648 - 1) == 0x7FFFFFFF}] \ } {-2147483648 -2147483648 -2147483648 -2147483648 1 1} -test expr-33.3 {parse largest wide value} wideIs64bit { +test expr-33.3 {parse largest wide value} { set max_wide_str 9223372036854775807 set max_wide_hex "0x7FFFFFFFFFFFFFFF " @@ -5863,7 +5860,7 @@ test expr-33.3 {parse largest wide value} wideIs64bit { [expr {wide(9223372036854775807 + 1) < 0}] \ } {9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807 1 1} -test expr-33.4 {parse smallest wide value} wideIs64bit { +test expr-33.4 {parse smallest wide value} { set min_wide_str -9223372036854775808 set min_wide_hex "-0x8000000000000000 " @@ -6271,341 +6268,341 @@ test expr-35.14 {expr edge cases} { set min -9223372036854775808 set max 9223372036854775807 -test expr-36.1 {expr edge cases} {wideIs64bit} { +test expr-36.1 {expr edge cases} { expr {$min / $min} } {1} -test expr-36.2 {expr edge cases} {wideIs64bit} { +test expr-36.2 {expr edge cases} { expr {$min % $min} } {0} -test expr-36.3 {expr edge cases} {wideIs64bit} { +test expr-36.3 {expr edge cases} { expr {$min / ($min + 1)} } {1} -test expr-36.4 {expr edge cases} {wideIs64bit} { +test expr-36.4 {expr edge cases} { expr {$min % ($min + 1)} } {-1} -test expr-36.5 {expr edge cases} {wideIs64bit} { +test expr-36.5 {expr edge cases} { expr {$min / ($min + 2)} } {1} -test expr-36.6 {expr edge cases} {wideIs64bit} { +test expr-36.6 {expr edge cases} { expr {$min % ($min + 2)} } {-2} -test expr-36.7 {expr edge cases} {wideIs64bit} { +test expr-36.7 {expr edge cases} { expr {$min / ($min + 3)} } {1} -test expr-36.8 {expr edge cases} {wideIs64bit} { +test expr-36.8 {expr edge cases} { expr {$min % ($min + 3)} } {-3} -test expr-36.9 {expr edge cases} {wideIs64bit} { +test expr-36.9 {expr edge cases} { expr {$min / -3} } {3074457345618258602} -test expr-36.10 {expr edge cases} {wideIs64bit} { +test expr-36.10 {expr edge cases} { expr {$min % -3} } {-2} -test expr-36.11 {expr edge cases} {wideIs64bit} { +test expr-36.11 {expr edge cases} { expr {$min / -2} } {4611686018427387904} -test expr-36.12 {expr edge cases} {wideIs64bit} { +test expr-36.12 {expr edge cases} { expr {$min % -2} } {0} -test expr-36.13 {expr edge cases} wideIs64bit { +test expr-36.13 {expr edge cases} { expr {wide($min / -1)} } $min -test expr-36.14 {expr edge cases} {wideIs64bit} { +test expr-36.14 {expr edge cases} { expr {$min % -1} } {0} -test expr-36.15 {expr edge cases} wideIs64bit { +test expr-36.15 {expr edge cases} { expr {wide($min * -1)} } $min -test expr-36.16 {expr edge cases} wideIs64bit { +test expr-36.16 {expr edge cases} { expr {wide(-$min)} } $min -test expr-36.17 {expr edge cases} {wideIs64bit} { +test expr-36.17 {expr edge cases} { expr {$min / 1} } $min -test expr-36.18 {expr edge cases} {wideIs64bit} { +test expr-36.18 {expr edge cases} { expr {$min % 1} } {0} -test expr-36.19 {expr edge cases} {wideIs64bit} { +test expr-36.19 {expr edge cases} { expr {$min / 2} } {-4611686018427387904} -test expr-36.20 {expr edge cases} {wideIs64bit} { +test expr-36.20 {expr edge cases} { expr {$min % 2} } {0} -test expr-36.21 {expr edge cases} {wideIs64bit} { +test expr-36.21 {expr edge cases} { expr {$min / 3} } {-3074457345618258603} -test expr-36.22 {expr edge cases} {wideIs64bit} { +test expr-36.22 {expr edge cases} { expr {$min % 3} } {1} -test expr-36.23 {expr edge cases} {wideIs64bit} { +test expr-36.23 {expr edge cases} { expr {$min / ($max - 3)} } {-2} -test expr-36.24 {expr edge cases} {wideIs64bit} { +test expr-36.24 {expr edge cases} { expr {$min % ($max - 3)} } {9223372036854775800} -test expr-36.25 {expr edge cases} {wideIs64bit} { +test expr-36.25 {expr edge cases} { expr {$min / ($max - 2)} } {-2} -test expr-36.26 {expr edge cases} {wideIs64bit} { +test expr-36.26 {expr edge cases} { expr {$min % ($max - 2)} } {9223372036854775802} -test expr-36.27 {expr edge cases} {wideIs64bit} { +test expr-36.27 {expr edge cases} { expr {$min / ($max - 1)} } {-2} -test expr-36.28 {expr edge cases} {wideIs64bit} { +test expr-36.28 {expr edge cases} { expr {$min % ($max - 1)} } {9223372036854775804} -test expr-36.29 {expr edge cases} {wideIs64bit} { +test expr-36.29 {expr edge cases} { expr {$min / $max} } {-2} -test expr-36.30 {expr edge cases} {wideIs64bit} { +test expr-36.30 {expr edge cases} { expr {$min % $max} } {9223372036854775806} -test expr-36.31 {expr edge cases} {wideIs64bit} { +test expr-36.31 {expr edge cases} { expr {$max / $max} } {1} -test expr-36.32 {expr edge cases} {wideIs64bit} { +test expr-36.32 {expr edge cases} { expr {$max % $max} } {0} -test expr-36.33 {expr edge cases} {wideIs64bit} { +test expr-36.33 {expr edge cases} { expr {$max / ($max - 1)} } {1} -test expr-36.34 {expr edge cases} {wideIs64bit} { +test expr-36.34 {expr edge cases} { expr {$max % ($max - 1)} } {1} -test expr-36.35 {expr edge cases} {wideIs64bit} { +test expr-36.35 {expr edge cases} { expr {$max / ($max - 2)} } {1} -test expr-36.36 {expr edge cases} {wideIs64bit} { +test expr-36.36 {expr edge cases} { expr {$max % ($max - 2)} } {2} -test expr-36.37 {expr edge cases} {wideIs64bit} { +test expr-36.37 {expr edge cases} { expr {$max / ($max - 3)} } {1} -test expr-36.38 {expr edge cases} {wideIs64bit} { +test expr-36.38 {expr edge cases} { expr {$max % ($max - 3)} } {3} -test expr-36.39 {expr edge cases} {wideIs64bit} { +test expr-36.39 {expr edge cases} { expr {$max / 3} } {3074457345618258602} -test expr-36.40 {expr edge cases} {wideIs64bit} { +test expr-36.40 {expr edge cases} { expr {$max % 3} } {1} -test expr-36.41 {expr edge cases} {wideIs64bit} { +test expr-36.41 {expr edge cases} { expr {$max / 2} } {4611686018427387903} -test expr-36.42 {expr edge cases} {wideIs64bit} { +test expr-36.42 {expr edge cases} { expr {$max % 2} } {1} -test expr-36.43 {expr edge cases} {wideIs64bit} { +test expr-36.43 {expr edge cases} { expr {$max / 1} } $max -test expr-36.44 {expr edge cases} {wideIs64bit} { +test expr-36.44 {expr edge cases} { expr {$max % 1} } {0} -test expr-36.45 {expr edge cases} {wideIs64bit} { +test expr-36.45 {expr edge cases} { expr {$max / -1} } "-$max" -test expr-36.46 {expr edge cases} {wideIs64bit} { +test expr-36.46 {expr edge cases} { expr {$max % -1} } {0} -test expr-36.47 {expr edge cases} {wideIs64bit} { +test expr-36.47 {expr edge cases} { expr {$max / -2} } {-4611686018427387904} -test expr-36.48 {expr edge cases} {wideIs64bit} { +test expr-36.48 {expr edge cases} { expr {$max % -2} } {-1} -test expr-36.49 {expr edge cases} {wideIs64bit} { +test expr-36.49 {expr edge cases} { expr {$max / -3} } {-3074457345618258603} -test expr-36.50 {expr edge cases} {wideIs64bit} { +test expr-36.50 {expr edge cases} { expr {$max % -3} } {-2} -test expr-36.51 {expr edge cases} {wideIs64bit} { +test expr-36.51 {expr edge cases} { expr {$max / ($min + 3)} } {-2} -test expr-36.52 {expr edge cases} {wideIs64bit} { +test expr-36.52 {expr edge cases} { expr {$max % ($min + 3)} } {-9223372036854775803} -test expr-36.53 {expr edge cases} {wideIs64bit} { +test expr-36.53 {expr edge cases} { expr {$max / ($min + 2)} } {-2} -test expr-36.54 {expr edge cases} {wideIs64bit} { +test expr-36.54 {expr edge cases} { expr {$max % ($min + 2)} } {-9223372036854775805} -test expr-36.55 {expr edge cases} {wideIs64bit} { +test expr-36.55 {expr edge cases} { expr {$max / ($min + 1)} } {-1} -test expr-36.56 {expr edge cases} {wideIs64bit} { +test expr-36.56 {expr edge cases} { expr {$max % ($min + 1)} } {0} -test expr-36.57 {expr edge cases} {wideIs64bit} { +test expr-36.57 {expr edge cases} { expr {$max / $min} } {-1} -test expr-36.58 {expr edge cases} {wideIs64bit} { +test expr-36.58 {expr edge cases} { expr {$max % $min} } {-1} -test expr-36.59 {expr edge cases} {wideIs64bit} { +test expr-36.59 {expr edge cases} { expr {($min + 1) / ($max - 1)} } {-2} -test expr-36.60 {expr edge cases} {wideIs64bit} { +test expr-36.60 {expr edge cases} { expr {($min + 1) % ($max - 1)} } {9223372036854775805} -test expr-36.61 {expr edge cases} {wideIs64bit} { +test expr-36.61 {expr edge cases} { expr {($max - 1) / ($min + 1)} } {-1} -test expr-36.62 {expr edge cases} {wideIs64bit} { +test expr-36.62 {expr edge cases} { expr {($max - 1) % ($min + 1)} } {-1} -test expr-36.63 {expr edge cases} {wideIs64bit} { +test expr-36.63 {expr edge cases} { expr {($max - 1) / $min} } {-1} -test expr-36.64 {expr edge cases} {wideIs64bit} { +test expr-36.64 {expr edge cases} { expr {($max - 1) % $min} } {-2} -test expr-36.65 {expr edge cases} {wideIs64bit} { +test expr-36.65 {expr edge cases} { expr {($max - 2) / $min} } {-1} -test expr-36.66 {expr edge cases} {wideIs64bit} { +test expr-36.66 {expr edge cases} { expr {($max - 2) % $min} } {-3} -test expr-36.67 {expr edge cases} {wideIs64bit} { +test expr-36.67 {expr edge cases} { expr {($max - 3) / $min} } {-1} -test expr-36.68 {expr edge cases} {wideIs64bit} { +test expr-36.68 {expr edge cases} { expr {($max - 3) % $min} } {-4} -test expr-36.69 {expr edge cases} {wideIs64bit} { +test expr-36.69 {expr edge cases} { expr {-3 / $min} } {0} -test expr-36.70 {expr edge cases} {wideIs64bit} { +test expr-36.70 {expr edge cases} { expr {-3 % $min} } {-3} -test expr-36.71 {expr edge cases} {wideIs64bit} { +test expr-36.71 {expr edge cases} { expr {-2 / $min} } {0} -test expr-36.72 {expr edge cases} {wideIs64bit} { +test expr-36.72 {expr edge cases} { expr {-2 % $min} } {-2} -test expr-36.73 {expr edge cases} {wideIs64bit} { +test expr-36.73 {expr edge cases} { expr {-1 / $min} } {0} -test expr-36.74 {expr edge cases} {wideIs64bit} { +test expr-36.74 {expr edge cases} { expr {-1 % $min} } {-1} -test expr-36.75 {expr edge cases} {wideIs64bit} { +test expr-36.75 {expr edge cases} { expr {0 / $min} } {0} -test expr-36.76 {expr edge cases} {wideIs64bit} { +test expr-36.76 {expr edge cases} { expr {0 % $min} } {0} -test expr-36.77 {expr edge cases} {wideIs64bit} { +test expr-36.77 {expr edge cases} { expr {0 / ($min + 1)} } {0} -test expr-36.78 {expr edge cases} {wideIs64bit} { +test expr-36.78 {expr edge cases} { expr {0 % ($min + 1)} } {0} -test expr-36.79 {expr edge cases} {wideIs64bit} { +test expr-36.79 {expr edge cases} { expr {1 / $min} } {-1} -test expr-36.80 {expr edge cases} {wideIs64bit} { +test expr-36.80 {expr edge cases} { expr {1 % $min} } {-9223372036854775807} -test expr-36.81 {expr edge cases} {wideIs64bit} { +test expr-36.81 {expr edge cases} { expr {1 / ($min + 1)} } {-1} -test expr-36.82 {expr edge cases} {wideIs64bit} { +test expr-36.82 {expr edge cases} { expr {1 % ($min + 1)} } {-9223372036854775806} -test expr-36.83 {expr edge cases} {wideIs64bit} { +test expr-36.83 {expr edge cases} { expr {2 / $min} } {-1} -test expr-36.84 {expr edge cases} {wideIs64bit} { +test expr-36.84 {expr edge cases} { expr {2 % $min} } {-9223372036854775806} -test expr-36.85 {expr edge cases} {wideIs64bit} { +test expr-36.85 {expr edge cases} { expr {2 / ($min + 1)} } {-1} -test expr-36.86 {expr edge cases} {wideIs64bit} { +test expr-36.86 {expr edge cases} { expr {2 % ($min + 1)} } {-9223372036854775805} -test expr-36.87 {expr edge cases} {wideIs64bit} { +test expr-36.87 {expr edge cases} { expr {3 / $min} } {-1} -test expr-36.88 {expr edge cases} {wideIs64bit} { +test expr-36.88 {expr edge cases} { expr {3 % $min} } {-9223372036854775805} -test expr-36.89 {expr edge cases} {wideIs64bit} { +test expr-36.89 {expr edge cases} { expr {3 / ($min + 1)} } {-1} -test expr-36.90 {expr edge cases} {wideIs64bit} { +test expr-36.90 {expr edge cases} { expr {3 % ($min + 1)} } {-9223372036854775804} -test expr-37.1 {expr edge cases} {wideIs64bit} { +test expr-37.1 {expr edge cases} { set dividend $max set divisor 2 set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($divisor * $q) + $r}] } {4611686018427387903 * 2 + 1 = 9223372036854775807} -test expr-37.2 {expr edge cases} {wideIs64bit} { +test expr-37.2 {expr edge cases} { set dividend [expr {$max - 1}] set divisor 2 set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {4611686018427387903 * 2 + 0 = 9223372036854775806} -test expr-37.3 {expr edge cases} {wideIs64bit} { +test expr-37.3 {expr edge cases} { set dividend [expr {$max - 2}] set divisor 2 set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {4611686018427387902 * 2 + 1 = 9223372036854775805} -test expr-37.4 {expr edge cases} {wideIs64bit} { +test expr-37.4 {expr edge cases} { set dividend $max set divisor 3 set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {3074457345618258602 * 3 + 1 = 9223372036854775807} -test expr-37.5 {expr edge cases} {wideIs64bit} { +test expr-37.5 {expr edge cases} { set dividend [expr {$max - 1}] set divisor 3 set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {3074457345618258602 * 3 + 0 = 9223372036854775806} -test expr-37.6 {expr edge cases} {wideIs64bit} { +test expr-37.6 {expr edge cases} { set dividend [expr {$max - 2}] set divisor 3 set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {3074457345618258601 * 3 + 2 = 9223372036854775805} -test expr-37.7 {expr edge cases} {wideIs64bit} { +test expr-37.7 {expr edge cases} { set dividend $min set divisor 2 set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {-4611686018427387904 * 2 + 0 = -9223372036854775808} -test expr-37.8 {expr edge cases} {wideIs64bit} { +test expr-37.8 {expr edge cases} { set dividend [expr {$min + 1}] set divisor 2 set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {-4611686018427387904 * 2 + 1 = -9223372036854775807} -test expr-37.9 {expr edge cases} {wideIs64bit} { +test expr-37.9 {expr edge cases} { set dividend [expr {$min + 2}] set divisor 2 set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {-4611686018427387903 * 2 + 0 = -9223372036854775806} -test expr-37.10 {expr edge cases} {wideIs64bit} { +test expr-37.10 {expr edge cases} { # Multiplication overflows 64 bit type here, # so when the 1 is added it overflows # again and we end up back at min. @@ -6615,28 +6612,28 @@ test expr-37.10 {expr edge cases} {wideIs64bit} { set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {-3074457345618258603 * 3 + 1 = -9223372036854775808} -test expr-37.11 {expr edge cases} {wideIs64bit} { +test expr-37.11 {expr edge cases} { set dividend $min set divisor -3 set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {3074457345618258602 * -3 + -2 = -9223372036854775808} -test expr-37.12 {expr edge cases} {wideIs64bit} { +test expr-37.12 {expr edge cases} { set dividend $min set divisor $min set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {1 * -9223372036854775808 + 0 = -9223372036854775808} -test expr-37.13 {expr edge cases} {wideIs64bit} { +test expr-37.13 {expr edge cases} { set dividend $min set divisor [expr {$min + 1}] set q [expr {$dividend / $divisor}] set r [expr {$dividend % $divisor}] list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {1 * -9223372036854775807 + -1 = -9223372036854775808} -test expr-37.14 {expr edge cases} {wideIs64bit} { +test expr-37.14 {expr edge cases} { set dividend $min set divisor [expr {$min + 2}] set q [expr {$dividend / $divisor}] @@ -6644,7 +6641,7 @@ test expr-37.14 {expr edge cases} {wideIs64bit} { list $q * $divisor + $r = [expr {($q * $divisor) + $r}] } {1 * -9223372036854775806 + -2 = -9223372036854775808} -test expr-38.1 {abs of smallest 32-bit integer [Bug 1241572]} {wideIs64bit} { +test expr-38.1 {abs of smallest 32-bit integer [Bug 1241572]} { expr {abs(-2147483648)} } 2147483648 test expr-38.2 {abs and -0 [Bug 1893815]} { diff --git a/tests/format.test b/tests/format.test index cdea545..ff85cb2 100644 --- a/tests/format.test +++ b/tests/format.test @@ -18,9 +18,6 @@ if {[lsearch [namespace children] ::tcltest] == -1} { # %u output depends on word length, so this test is not portable. testConstraint longIs32bit [expr {int(0x80000000) < 0}] testConstraint longIs64bit [expr {int(0x8000000000000000) < 0}] -testConstraint wideIs64bit \ - [expr {(wide(0x80000000) > 0) && (wide(0x8000000000000000) < 0)}] -testConstraint wideBiggerThanInt [expr {wide(0x80000000) != int(0x80000000)}] testConstraint pointerIs64bit [expr {$tcl_platform(pointerSize) >= 8}] test format-1.1 {integer formatting} { @@ -547,13 +544,13 @@ for {set i 290} {$i < 400} {incr i} { append b "x" } -test format-17.1 {testing %d with wide} {wideIs64bit wideBiggerThanInt} { +test format-17.1 {testing %d with wide} { format %d 7810179016327718216 -} 1819043144 -test format-17.2 {testing %ld with wide} {wideIs64bit} { +} 7810179016327718216 +test format-17.2 {testing %ld with wide} { format %ld 7810179016327718216 } 7810179016327718216 -test format-17.3 {testing %ld with non-wide} {wideIs64bit} { +test format-17.3 {testing %ld with non-wide} { format %ld 42 } 42 test format-17.4 {testing %l with non-integer} { @@ -580,11 +577,11 @@ test format-18.1 {do not demote existing numeric values} { format %08x $b lappend result [expr {$a == $b}] } {1 1 1 1} -test format-18.2 {do not demote existing numeric values} {wideBiggerThanInt} { +test format-18.2 {do not demote existing numeric values} { set a [expr {0xaaaaaaaaaa + 1}] set b 0xaaaaaaaaab list [format %08x $a] [expr {$a == $b}] -} {aaaaaaab 1} +} {aaaaaaaaab 1} test format-19.1 {regression test - tcl-core message by Brian Griffin on 26 0ctober 2004} -body { set x 0x8fedc654 diff --git a/tests/obj.test b/tests/obj.test index cb62d3f..41b1428 100644 --- a/tests/obj.test +++ b/tests/obj.test @@ -20,8 +20,6 @@ if {[lsearch [namespace children] ::tcltest] == -1} { catch [list package require -exact Tcltest [info patchlevel]] testConstraint testobj [llength [info commands testobj]] -testConstraint longIs32bit [expr {int(0x80000000) < 0}] -testConstraint wideBiggerThanInt [expr {wide(0x80000000) != int(0x80000000)}] test obj-1.1 {Tcl_AppendAllObjTypes, and InitTypeTable, Tcl_RegisterObjType} testobj { set r 1 @@ -549,34 +547,34 @@ test obj-32.1 {freeing very large object trees} { unset x } {} -test obj-33.1 {integer overflow on input} {longIs32bit wideBiggerThanInt} { +test obj-33.1 {integer overflow on input} { set x 0x8000; append x 0000 list [string is integer $x] [expr { wide($x) }] } {1 2147483648} -test obj-33.2 {integer overflow on input} {longIs32bit wideBiggerThanInt} { +test obj-33.2 {integer overflow on input} { set x 0xffff; append x ffff list [string is integer $x] [expr { wide($x) }] } {1 4294967295} test obj-33.3 {integer overflow on input} { set x 0x10000; append x 0000 list [string is integer $x] [expr { wide($x) }] -} {0 4294967296} -test obj-33.4 {integer overflow on input} {longIs32bit wideBiggerThanInt} { +} {1 4294967296} +test obj-33.4 {integer overflow on input} { set x -0x8000; append x 0000 list [string is integer $x] [expr { wide($x) }] } {1 -2147483648} -test obj-33.5 {integer overflow on input} {longIs32bit wideBiggerThanInt} { +test obj-33.5 {integer overflow on input} { set x -0x8000; append x 0001 list [string is integer $x] [expr { wide($x) }] } {1 -2147483649} -test obj-33.6 {integer overflow on input} {longIs32bit wideBiggerThanInt} { +test obj-33.6 {integer overflow on input} { set x -0xffff; append x ffff list [string is integer $x] [expr { wide($x) }] } {1 -4294967295} test obj-33.7 {integer overflow on input} { set x -0x10000; append x 0000 list [string is integer $x] [expr { wide($x) }] -} {0 -4294967296} +} {1 -4294967296} test obj-34.1 {mp_iseven} testobj { set result "" diff --git a/tests/scan.test b/tests/scan.test index 1f32b9f..0b7b14a 100644 --- a/tests/scan.test +++ b/tests/scan.test @@ -85,8 +85,6 @@ proc testIEEE {} { } testConstraint ieeeFloatingPoint [testIEEE] -testConstraint wideIs64bit \ - [expr {(wide(0x80000000) > 0) && (wide(0x8000000000000000) < 0)}] test scan-1.1 {BuildCharSet, CharInSet} { list [scan foo {%[^o]} x] $x @@ -521,7 +519,7 @@ test scan-5.11 {integer scanning} -constraints {nonPortable} -setup { list [scan "4294967280 4294967280" "%u %d" a b] $a \ [expr {$b == -16 || $b == 0x7fffffff}] } -result {2 4294967280 1} -test scan-5.12 {integer scanning} -constraints {wideIs64bit} -setup { +test scan-5.12 {integer scanning} -setup { set a {}; set b {}; set c {} } -body { list [scan "7810179016327718216,6c63546f6c6c6548,661432506755433062510" \ diff --git a/tests/string.test b/tests/string.test index d169193..81588ff 100644 --- a/tests/string.test +++ b/tests/string.test @@ -807,20 +807,20 @@ test string-6.91.$noComp {string is double, bad doubles} { } return $result } {1 1 0 0 0 1 0 0} -test string-6.92.$noComp {string is integer, 32-bit overflow} { +test string-6.92.$noComp {string is integer, 64-bit overflow} { # Bug 718878 - set x 0x100000000 + set x 0x10000000000000000 list [run {string is integer -failindex var $x}] $var } {0 -1} -test string-6.93.$noComp {string is integer, 32-bit overflow} { +test string-6.93.$noComp {string is integer, 64-bit overflow} { # Bug 718878 - set x 0x100000000 + set x 0x10000000000000000 append x "" list [run {string is integer -failindex var $x}] $var } {0 -1} -test string-6.94.$noComp {string is integer, 32-bit overflow} { +test string-6.94.$noComp {string is integer, 64-bit overflow} { # Bug 718878 - set x 0x100000000 + set x 0x10000000000000000 list [run {string is integer -failindex var [expr {$x}]}] $var } {0 -1} test string-6.95.$noComp {string is wideinteger, true} { diff --git a/tests/uplevel.test b/tests/uplevel.test index 737c571..83d6b42 100644 --- a/tests/uplevel.test +++ b/tests/uplevel.test @@ -137,18 +137,18 @@ test uplevel-4.15 {level parsing} { test uplevel-4.16 {level parsing} { apply {{} {uplevel #[expr 1] {}}} } {} -test uplevel-4.17 {level parsing} { +test uplevel-4.17 {level parsing} -returnCodes error -body { apply {{} {uplevel -0xffffffff {}}} -} {} -test uplevel-4.18 {level parsing} { +} -result {invalid command name "-0xffffffff"} +test uplevel-4.18 {level parsing} -returnCodes error -body { apply {{} {uplevel #-0xffffffff {}}} -} {} -test uplevel-4.19 {level parsing} { +} -result {bad level "#-0xffffffff"} +test uplevel-4.19 {level parsing} -returnCodes error -body { apply {{} {uplevel [expr -0xffffffff] {}}} -} {} -test uplevel-4.20 {level parsing} { +} -result {invalid command name "-4294967295"} +test uplevel-4.20 {level parsing} -returnCodes error -body { apply {{} {uplevel #[expr -0xffffffff] {}}} -} {} +} -result {bad level "#-4294967295"} test uplevel-4.21 {level parsing} -body { apply {{} {uplevel -1 {}}} } -returnCodes error -result {invalid command name "-1"} |