From 4335a4f4756de329d8abe3cf77fae90b8e664faf Mon Sep 17 00:00:00 2001 From: griffin Date: Tue, 8 Nov 2022 22:02:33 +0000 Subject: Remove unused/incomplete functions. Some cleanup. --- generic/tcl.h | 9 +- generic/tclArithSeries.c | 35 ----- generic/tclDictObj.c | 172 +++++++++++++++++++++++-- generic/tclInt.h | 2 - generic/tclListObj.c | 1 - generic/tclTestABSList.c | 42 ++---- tests/abstractlist.test | 325 +++++++++++++++++++++++------------------------ tests/dict.test | 31 +++-- 8 files changed, 350 insertions(+), 267 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index f19e09a..451b536 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -613,8 +613,6 @@ typedef void (Tcl_FinalizeNotifierProc) (void *clientData); typedef void (Tcl_MainLoopProc) (void); /* Abstract List functions */ -typedef struct Tcl_Obj* (Tcl_ALNewObjProc) (Tcl_Size objc, struct Tcl_Obj * const objv[]); -typedef void (Tcl_ALDupRepProc) (struct Tcl_Obj *srcPtr, struct Tcl_Obj *copyPtr); typedef Tcl_WideInt (Tcl_ALLengthProc) (struct Tcl_Obj *listPtr); typedef int (Tcl_ALIndexProc) (Tcl_Interp *interp, struct Tcl_Obj *listPtr, Tcl_Size index, struct Tcl_Obj** elemObj); @@ -625,8 +623,6 @@ typedef int (Tcl_ALReverseProc) (Tcl_Interp *interp, struct Tcl_Obj *listPtr struct Tcl_Obj **newObjPtr); typedef int (Tcl_ALGetElements) (Tcl_Interp *interp, struct Tcl_Obj *listPtr, Tcl_Size *objcptr, struct Tcl_Obj ***objvptr); -typedef void (Tcl_ALFreeConcreteRep) (struct Tcl_Obj *listPtr); -typedef void (Tcl_ALToStringRep) (struct Tcl_Obj *listPtr); typedef struct Tcl_Obj* (Tcl_ALSetElement) (Tcl_Interp *interp, struct Tcl_Obj *listPtr, Tcl_Size indexCount, struct Tcl_Obj *const indexArray[], @@ -667,8 +663,6 @@ typedef struct Tcl_ObjType { Tcl_ObjTypeVersion version; /* List emulation functions - ObjTypeVersion 1 */ - Tcl_ALNewObjProc *newObjProc; /* How to create a new Tcl_Obj of this - ** custom type */ Tcl_ALLengthProc *lengthProc; /* Return the [llength] of the ** AbstractList */ Tcl_ALIndexProc *indexProc; /* Return a value (Tcl_Obj) for @@ -699,7 +693,6 @@ typedef struct Tcl_ObjType { NULL, \ NULL, \ NULL, \ - NULL, \ NULL /* @@ -764,7 +757,7 @@ typedef struct Tcl_Obj { typedef enum { TCL_OBJ_FREEREP, TCL_OBJ_DUPREP, TCL_OBJ_UPDATESTRING, TCL_OBJ_SETFROMANY, - TCL_OBJ_NEW, TCL_OBJ_LENGTH, TCL_OBJ_INDEX, + TCL_OBJ_LENGTH, TCL_OBJ_INDEX, TCL_OBJ_SLICE, TCL_OBJ_REVERSE, TCL_OBJ_GETELEMENTS, TCL_OBJ_SETELEMENT, TCL_OBJ_REPLACE } Tcl_ObjProcType; diff --git a/generic/tclArithSeries.c b/generic/tclArithSeries.c index bd00502..d64b5c4 100755 --- a/generic/tclArithSeries.c +++ b/generic/tclArithSeries.c @@ -69,7 +69,6 @@ static Tcl_Obj *TclNewArithSeriesDbl(double start, double end, static void DupArithSeriesRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void FreeArithSeriesRep(Tcl_Obj *arithSeriesObjPtr); static void UpdateStringOfArithSeries(Tcl_Obj *arithSeriesObjPtr); -static Tcl_Obj *Tcl_NewArithSeriesObj(Tcl_Size objc, Tcl_Obj * const objv[]); static Tcl_ObjType arithSeriesType = { "arithseries", @@ -78,7 +77,6 @@ static Tcl_ObjType arithSeriesType = { UpdateStringOfArithSeries, NULL, // setFromAny TCL_OBJTYPE_V1, - Tcl_NewArithSeriesObj, TclArithSeriesObjLength, TclArithSeriesObjIndex, TclArithSeriesObjRange, @@ -552,39 +550,6 @@ TclArithSeriesObjStep( /* *---------------------------------------------------------------------- * - * Tcl_NewArithSeriesObj -- - * - * Creates a new ArithSeries object. The returned object has - * refcount = 0. - * - * Results: - * - * A Tcl_Obj pointer to the created ArithSeries object. - * A NULL pointer of the range is invalid. - * - * Side Effects: - * - * None. - *---------------------------------------------------------------------- - */ - -Tcl_Obj * -Tcl_NewArithSeriesObj(Tcl_Size objc, Tcl_Obj * const objv[]) -{ - Tcl_Obj *arithSeriesObj; - if (objc != 4) return NULL; - // TODO: Define this use model! - if (TclNewArithSeriesObj(NULL, &arithSeriesObj, 0/*TODO: int vs double support */, - objv[0]/*start*/, objv[1]/*end*/, - objv[2]/*step*/, objv[3]/*len*/) != TCL_OK) { - arithSeriesObj = NULL; - } - return arithSeriesObj; -} - -/* - *---------------------------------------------------------------------- - * * TclArithSeriesObjRange -- * * Makes a slice of an ArithSeries value. diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index d9739aa..84a0f99 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -61,6 +61,8 @@ static Tcl_ObjCmdProc DictForNRCmd; static Tcl_ObjCmdProc DictMapNRCmd; static Tcl_NRPostProc DictForLoopCallback; static Tcl_NRPostProc DictMapLoopCallback; +static Tcl_ALLengthProc DictAsListLength; +static Tcl_ALIndexProc DictAsListIndex; /* * Table of dict subcommand names and implementations. @@ -143,14 +145,16 @@ typedef struct Dict { const Tcl_ObjType tclDictType = { "dict", - FreeDictInternalRep, /* freeIntRepProc */ - DupDictInternalRep, /* dupIntRepProc */ - UpdateStringOfDict, /* updateStringProc */ - SetDictFromAny, /* setFromAnyProc */ - TCL_OBJTYPE_V1, /* Extended type for AbstractLists */ - NULL, - NULL, - NULL, + FreeDictInternalRep, /* freeIntRepProc */ + DupDictInternalRep, /* dupIntRepProc */ + UpdateStringOfDict, /* updateStringProc */ + SetDictFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V1, /* Extended type for AbstractLists */ + DictAsListLength, /* return "list" length of dict value w/o + * shimmering */ + DictAsListIndex, /* return key or value at "list" index + * location. (keysare at even indicies, + * values at odd indicies) */ NULL, NULL, NULL, @@ -3777,6 +3781,158 @@ TclInitDictCmd( } /* + *---------------------------------------------------------------------- + * + * DictAsListLength -- + * + * Compute the length of a list as if the dict value were converted to a + * list. + * + * Note: the list length may not match the dict size * 2. This occurs when + * there are duplicate keys in the original string representation. + * + * Side Effects -- + * + * The intent is to have no side effects. + */ + +static Tcl_WideInt +DictAsListLength( + Tcl_Obj *objPtr) +{ + Tcl_Size estCount, length, llen; + const char *limit, *nextElem = Tcl_GetStringFromObj(objPtr, &length); + Tcl_Obj *elemPtr; + + /* + * Allocate enough space to hold a (Tcl_Obj *) for each + * (possible) list element. + */ + + estCount = TclMaxListLength(nextElem, length, &limit); + estCount += (estCount == 0); /* Smallest list struct holds 1 + * element. */ + elemPtr = Tcl_NewObj(); + + llen = 0; + + while (nextElem < limit) { + const char *elemStart; + char *check; + Tcl_Size elemSize; + int literal; + + if (TCL_OK != TclFindElement(NULL, nextElem, limit - nextElem, + &elemStart, &nextElem, &elemSize, &literal)) { + Tcl_DecrRefCount(elemPtr); + return 0; + } + if (elemStart == limit) { + break; + } + + TclInvalidateStringRep(elemPtr); + check = Tcl_InitStringRep(elemPtr, literal ? elemStart : NULL, + elemSize); + if (elemSize && check == NULL) { + Tcl_DecrRefCount(elemPtr); + return 0; + } + if (!literal) { + Tcl_InitStringRep(elemPtr, NULL, + TclCopyAndCollapse(elemSize, elemStart, check)); + } + llen++; + } + Tcl_DecrRefCount(elemPtr); + return llen; +} + + +/* + *---------------------------------------------------------------------- + * + * DictAsListIndex -- + * + * Return the key or value at the given "list" index, i.e., as if the string + * value where treated as a list. The intent is to support this list + * operation w/o causing the Obj value to shimmer into a List. + * + * Side Effects -- + * + * The intent is to have no side effects. + * + */ + +static int +DictAsListIndex( + Tcl_Interp *interp, + struct Tcl_Obj *objPtr, + Tcl_Size index, + Tcl_Obj** elemObjPtr) +{ + Tcl_Size /*estCount,*/ length, llen; + const char *limit, *nextElem = Tcl_GetStringFromObj(objPtr, &length); + Tcl_Obj *elemPtr; + + /* + * Compute limit of the list string + */ + + TclMaxListLength(nextElem, length, &limit); + elemPtr = Tcl_NewObj(); + + llen = 0; + + /* + * parse out each element until reaching the "index"th element. + * Sure this is slow, but shimmering is slower. + */ + while (nextElem < limit) { + const char *elemStart; + char *check; + Tcl_Size elemSize; + int literal; + + if (TCL_OK != TclFindElement(NULL, nextElem, limit - nextElem, + &elemStart, &nextElem, &elemSize, &literal)) { + Tcl_DecrRefCount(elemPtr); + return 0; + } + if (elemStart == limit) { + break; + } + + TclInvalidateStringRep(elemPtr); + check = Tcl_InitStringRep(elemPtr, literal ? elemStart : NULL, + elemSize); + if (elemSize && check == NULL) { + Tcl_DecrRefCount(elemPtr); + if (interp) { + // Need error message here + } + return TCL_ERROR; + } + if (!literal) { + Tcl_InitStringRep(elemPtr, NULL, + TclCopyAndCollapse(elemSize, elemStart, check)); + } + if (llen == index) { + *elemObjPtr = elemPtr; + return TCL_OK; + } + llen++; + } + + /* + * Index is beyond end of list - return empty + */ + Tcl_InitStringRep(elemPtr, NULL, 0); + *elemObjPtr = elemPtr; + return TCL_OK; +} + +/* * Local Variables: * mode: c * c-basic-offset: 4 diff --git a/generic/tclInt.h b/generic/tclInt.h index fab77c6..8d40f4f 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4694,8 +4694,6 @@ TclObjTypeHasProc(Tcl_Obj* objPtr, Tcl_ObjProcType ptype) } case (size_t)TCL_OBJTYPE_V1: switch (ptype) { - case TCL_OBJ_NEW: - return (typePtr->newObjProc != NULL); case TCL_OBJ_DUPREP: return (typePtr->dupIntRepProc != NULL); case TCL_OBJ_LENGTH: diff --git a/generic/tclListObj.c b/generic/tclListObj.c index c699e67..16157fd 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -162,7 +162,6 @@ const Tcl_ObjType tclListType = { NULL, NULL, NULL, - NULL, NULL }; diff --git a/generic/tclTestABSList.c b/generic/tclTestABSList.c index 57d25e6..cfe03c6 100644 --- a/generic/tclTestABSList.c +++ b/generic/tclTestABSList.c @@ -57,7 +57,7 @@ typedef struct LString { /* * AbstractList definition of an lstring type */ -static Tcl_ObjType lstringTypes[12] = { +static Tcl_ObjType lstringTypes[11] = { { "lstring", freeRep, @@ -65,7 +65,6 @@ static Tcl_ObjType lstringTypes[12] = { UpdateStringOfLString, NULL, TCL_OBJTYPE_V1, -/**/ NULL, /*default NULL,*/ my_LStringObjLength, my_LStringObjIndex, my_LStringObjRange,/*ObjRange*/ @@ -81,23 +80,6 @@ static Tcl_ObjType lstringTypes[12] = { UpdateStringOfLString, NULL, TCL_OBJTYPE_V1, - NULL, - my_LStringObjLength, - my_LStringObjIndex, - my_LStringObjRange,/*ObjRange*/ - my_LStringObjReverse, - my_LStringGetElements, - my_LStringObjSetElem, /* use default update string */ - my_LStringReplace - }, - { - "lstring", - freeRep, - DupLStringRep, - UpdateStringOfLString, - NULL, - TCL_OBJTYPE_V1, - NULL, /**/ NULL, /*default my_LStringObjLength,*/ my_LStringObjIndex, my_LStringObjRange,/*ObjRange*/ @@ -113,7 +95,6 @@ static Tcl_ObjType lstringTypes[12] = { UpdateStringOfLString, NULL, TCL_OBJTYPE_V1, - NULL, my_LStringObjLength, /**/ NULL, /*default my_LStringObjIndex,*/ my_LStringObjRange,/*ObjRange*/ @@ -130,7 +111,6 @@ static Tcl_ObjType lstringTypes[12] = { UpdateStringOfLString, NULL, TCL_OBJTYPE_V1, - NULL, my_LStringObjLength, my_LStringObjIndex, /**/ NULL, /*default my_LStringObjRange,*/ @@ -146,7 +126,6 @@ static Tcl_ObjType lstringTypes[12] = { UpdateStringOfLString, NULL, TCL_OBJTYPE_V1, - NULL, my_LStringObjLength, my_LStringObjIndex, my_LStringObjRange,/*ObjRange*/ @@ -162,7 +141,6 @@ static Tcl_ObjType lstringTypes[12] = { UpdateStringOfLString, NULL, TCL_OBJTYPE_V1, - NULL, my_LStringObjLength, my_LStringObjIndex, my_LStringObjRange,/*ObjRange*/ @@ -178,7 +156,6 @@ static Tcl_ObjType lstringTypes[12] = { UpdateStringOfLString, NULL, TCL_OBJTYPE_V1, - NULL, my_LStringObjLength, my_LStringObjIndex, my_LStringObjRange,/*ObjRange*/ @@ -194,7 +171,6 @@ static Tcl_ObjType lstringTypes[12] = { UpdateStringOfLString, NULL, TCL_OBJTYPE_V1, - NULL, my_LStringObjLength, my_LStringObjIndex, my_LStringObjRange,/*ObjRange*/ @@ -210,7 +186,6 @@ static Tcl_ObjType lstringTypes[12] = { UpdateStringOfLString, NULL, TCL_OBJTYPE_V1, - NULL, my_LStringObjLength, my_LStringObjIndex, my_LStringObjRange,/*ObjRange*/ @@ -226,7 +201,6 @@ static Tcl_ObjType lstringTypes[12] = { UpdateStringOfLString, NULL, TCL_OBJTYPE_V1, - NULL, my_LStringObjLength, my_LStringObjIndex, my_LStringObjRange,/*ObjRange*/ @@ -242,7 +216,6 @@ static Tcl_ObjType lstringTypes[12] = { UpdateStringOfLString, NULL, TCL_OBJTYPE_V1, - NULL, my_LStringObjLength, my_LStringObjIndex, my_LStringObjRange,/*ObjRange*/ @@ -639,9 +612,10 @@ my_LStringReplace( static Tcl_ObjType * my_SetAbstractProc(Tcl_ObjProcType ptype) { - Tcl_ObjType *typePtr = &lstringTypes[11]; - if (TCL_OBJ_NEW <= ptype && ptype <= TCL_OBJ_REPLACE) { - typePtr = &lstringTypes[ptype]; + Tcl_ObjType *typePtr = &lstringTypes[0]; /* default value */ + if (TCL_OBJ_LENGTH <= ptype && ptype <= TCL_OBJ_REPLACE) { + /* Table has no entries for the slots upto setfromany */ + typePtr = &lstringTypes[(ptype-TCL_OBJ_SETFROMANY)]; } return typePtr; } @@ -675,13 +649,13 @@ my_NewLStringObj( Tcl_Obj *lstringPtr; const char *string; static const char* procTypeNames[] = { - "NEW", "DUPREP", "LENGTH", "INDEX", - "SLICE", "REVERSE", "GETELEMENTS", "FREEREP", + "FREEREP", "DUPREP", "UPDATESTRING", "SETFROMANY", + "LENGTH", "INDEX", "SLICE", "REVERSE", "GETELEMENTS", "TOSTRING", "SETELEMENT", "REPLACE", NULL }; int i = 0; Tcl_ObjProcType ptype; - Tcl_ObjType *lstringTypePtr = &lstringTypes[11]; + Tcl_ObjType *lstringTypePtr = &lstringTypes[10]; repSize = sizeof(LString); lstringRepPtr = (LString*)Tcl_Alloc(repSize); diff --git a/tests/abstractlist.test b/tests/abstractlist.test index ea90e2f..8ea760e 100644 --- a/tests/abstractlist.test +++ b/tests/abstractlist.test @@ -14,17 +14,6 @@ testConstraint testevalex [llength [info commands testevalex]] set abstractlisttestvars [info var *] -proc value-isa {var {expected ""}} { - upvar $var v - set t [lindex [tcl::unsupported::representation $v] 3] - if {$expected ne "" && $expected ne $t} { - set fail " expecting: $expected" - } else { - set fail "" - } - return "$var is a $t$fail" -} - proc value-cmp {vara varb} { upvar $vara a upvar $varb b @@ -49,34 +38,34 @@ test abstractlist-1.1 {error cases} -body { test abstractlist-2.0 {no shimmer llength} { set l [lstring $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set len [llength $l] - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] list $l ${l-isa} ${len} ${l-isa2} -} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} {l is a lstring} 63 {l is a lstring}} +} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} lstring 63 lstring} test abstractlist-2.1 {no shimmer lindex} { set l [lstring $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set ele [lindex $l 22] - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] list $l ${l-isa} ${ele} ${l-isa2} -} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} {l is a lstring} y {l is a lstring}} +} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} lstring y lstring} test abstractlist-2.2 {no shimmer lreverse} { set l [lstring $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set r [lreverse $l] - set r-isa [value-isa r] - set l-isa2 [value-isa l] + set r-isa [testobj objtype $r] + set l-isa2 [testobj objtype $l] list $r ${l-isa} ${r-isa} ${l-isa2} -} {{! e i d { } o t { } e r a p e r P { } . r e h t a f { } y m { } d e l l i k { } u o Y { } . a y o t n o M { } o g i n I { } s i { } e m a n { } y M} {l is a lstring} {r is a lstring} {l is a lstring}} +} {{! e i d { } o t { } e r a p e r P { } . r e h t a f { } y m { } d e l l i k { } u o Y { } . a y o t n o M { } o g i n I { } s i { } e m a n { } y M} lstring lstring lstring} test abstractlist-2.3 {no shimmer lrange} { set l [lstring $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set il [lsearch -all [lstring $str] { }] - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] lappend il [llength $l] set start 0 set words [lmap i $il { @@ -84,13 +73,13 @@ test abstractlist-2.3 {no shimmer lrange} { set start [expr {$i+1}] set w }] - set l-isa3 [value-isa l] + set l-isa3 [testobj objtype $l] list ${l-isa} $il ${l-isa2} ${l-isa3} $words -} {{l is a lstring} {2 7 10 16 25 29 36 39 47 55 58 63} {l is a lstring} {l is a lstring} {My name is Inigo Montoya. You killed my father. Prepare to die!}} +} {lstring {2 7 10 16 25 29 36 39 47 55 58 63} lstring lstring {My name is Inigo Montoya. You killed my father. Prepare to die!}} test abstractlist-2.4 {no shimmer foreach} { set l [lstring $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set word {} set words {} foreach c $l { @@ -104,102 +93,102 @@ test abstractlist-2.4 {no shimmer foreach} { if {$word ne ""} { lappend words $word } - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] list ${l-isa} ${l-isa2} $words -} {{l is a lstring} {l is a lstring} {My name is Inigo Montoya. You killed my father. Prepare to die!}} +} {lstring lstring {My name is Inigo Montoya. You killed my father. Prepare to die!}} # -# The TBCE implements lreplace as a lrange + lappend operation, so, in this case, $m results is a list, not an lstring. +# The TBCE implements lreplace as a lrange + lappend operation, so, in this case, $m list, not an lstring. # test abstractlist-2.5 {!no shimmer lreplace} { set l [lstring $str2] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [lreplace $l 18 23 { } f a i l ?] - set m-isa [value-isa m] - set l-isa1 [value-isa l] + set m-isa [testobj objtype $m] + set l-isa1 [testobj objtype $l] list ${l-isa} $m ${m-isa} ${l-isa1} -} {{l is a lstring} {V i z z i n i : { } H E { } D I D N ' T { } f a i l ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {m is a lstring} {l is a lstring}} +} {lstring {V i z z i n i : { } H E { } D I D N ' T { } f a i l ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} lstring lstring} test abstractlist-2.6 {no shimmer ledit} { # "ledit m 9 8 S" set l [lstring $str2] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set e [ledit l 9 8 S] - set e-isa [value-isa e] + set e-isa [testobj objtype $e] list ${l-isa} $e ${e-isa} -} {{l is a lstring} {V i z z i n i : { } S H E { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {e is a lstring}} +} {lstring {V i z z i n i : { } S H E { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} lstring} test abstractlist-2.7 {no shimmer linsert} { # "ledit m 9 8 S" set l [lstring $str2] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set i [linsert $l 12 {*}[split "almost " {}]] - set i-isa [value-isa i] + set i-isa [testobj objtype $i] set res [list ${l-isa} $i ${i-isa}] set p [lpop i 23] - set p-isa [value-isa p] - set i-isa2 [value-isa i] + set p-isa [testobj objtype $p] + set i-isa2 [testobj objtype $i] lappend res $p ${p-isa} $i ${i-isa2} -} {{l is a lstring} {V i z z i n i : { } H E { } a l m o s t { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {i is a lstring} ' {p is a pure} {V i z z i n i : { } H E { } a l m o s t { } D I D N T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {i is a lstring}} +} {lstring {V i z z i n i : { } H E { } a l m o s t { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} lstring ' none {V i z z i n i : { } H E { } a l m o s t { } D I D N T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} lstring} test abstractlist-2.8 {shimmer lassign} { set l [lstring Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set l2 [lassign $l i n c] - set l-isa2 [value-isa l] - set l2-isa [value-isa l2] + set l-isa2 [testobj objtype $l] + set l2-isa [testobj objtype $l2] list $l ${l-isa} $l2 ${l-isa2} ${l2-isa} -} {{I n c o n c e i v a b l e} {l is a lstring} {o n c e i v a b l e} {l is a lstring} {l2 is a lstring}} +} {{I n c o n c e i v a b l e} lstring {o n c e i v a b l e} lstring lstring} test abstractlist-2.9 {no shimmer lremove} { set l [lstring Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set l2 [lremove $l 0 1] - set l-isa2 [value-isa l] - set l2-isa [value-isa l2] + set l-isa2 [testobj objtype $l] + set l2-isa [testobj objtype $l2] list $l ${l-isa} $l2 ${l-isa2} ${l2-isa} -} {{I n c o n c e i v a b l e} {l is a lstring} {c o n c e i v a b l e} {l is a lstring} {l2 is a lstring}} +} {{I n c o n c e i v a b l e} lstring {c o n c e i v a b l e} lstring lstring} test abstractlist-2.10 {shimmer lreverse} { set l [lstring Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set l2 [lreverse $l] - set l-isa2 [value-isa l] - set l2-isa [value-isa l2] + set l-isa2 [testobj objtype $l] + set l2-isa [testobj objtype $l2] list $l ${l-isa} $l2 ${l-isa2} ${l2-isa} -} {{I n c o n c e i v a b l e} {l is a lstring} {e l b a v i e c n o c n I} {l is a lstring} {l2 is a lstring}} +} {{I n c o n c e i v a b l e} lstring {e l b a v i e c n o c n I} lstring lstring} test abstractlist-2.11 {shimmer lset} { set l [lstring Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [lset l 2 k] - set m-isa [value-isa m] + set m-isa [testobj objtype $m] list $l ${l-isa} $m ${m-isa} [value-cmp l m] -} {{I n k o n c e i v a b l e} {l is a lstring} {I n k o n c e i v a b l e} {m is a lstring} 0} +} {{I n k o n c e i v a b l e} lstring {I n k o n c e i v a b l e} lstring 0} # lrepeat test abstractlist-2.12 {shimmer lrepeat} { set l [lstring Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [lrepeat 3 $l] - set m-isa [value-isa m] + set m-isa [testobj objtype $m] set n [lindex $m 1] - list $l ${l-isa} $m ${m-isa} [value-isa n] [value-cmp l n] -} {{I n c o n c e i v a b l e} {l is a lstring} {{I n c o n c e i v a b l e} {I n c o n c e i v a b l e} {I n c o n c e i v a b l e}} {m is a list} {n is a lstring} 0} + list $l ${l-isa} $m ${m-isa} [testobj objtype $n] [value-cmp l n] +} {{I n c o n c e i v a b l e} lstring {{I n c o n c e i v a b l e} {I n c o n c e i v a b l e} {I n c o n c e i v a b l e}} list lstring 0} test abstractlist-2.13 {no shimmer join llength==1} { set l [lstring G] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set j [join $l :] - set j-isa [value-isa j] + set j-isa [testobj objtype $j] list ${l-isa} $l ${j-isa} $j -} {{l is a lstring} G {j is a pure} G} +} {lstring G none G} test abstractlist-2.14 {error case lset multiple indicies} -body { set l [lstring Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [lset l 2 0 1 k] - set m-isa [value-isa m] + set m-isa [testobj objtype $m] list $l ${l-isa} $m ${m-isa} [value-cmp l m] } -returnCodes 1 \ -result {Multiple indicies not supported by lstring.} @@ -208,35 +197,35 @@ test abstractlist-2.14 {error case lset multiple indicies} -body { test abstractlist-3.0 {no shimmer llength} { set l [lstring -not SLICE $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set len [llength $l] - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] list $l ${l-isa} ${len} ${l-isa2} -} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} {l is a lstring} 63 {l is a lstring}} +} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} lstring 63 lstring} test abstractlist-3.1 {no shimmer lindex} { set l [lstring -not SLICE $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set n 22 set ele [lindex $l $n] ;# exercise INST_LIST_INDEX - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] list $l ${l-isa} ${ele} ${l-isa2} -} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} {l is a lstring} y {l is a lstring}} +} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} lstring y lstring} test abstractlist-3.2 {no shimmer lreverse} { set l [lstring -not SLICE $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set r [lreverse $l] - set r-isa [value-isa r] - set l-isa2 [value-isa l] + set r-isa [testobj objtype $r] + set l-isa2 [testobj objtype $l] list $r ${l-isa} ${r-isa} ${l-isa2} -} {{! e i d { } o t { } e r a p e r P { } . r e h t a f { } y m { } d e l l i k { } u o Y { } . a y o t n o M { } o g i n I { } s i { } e m a n { } y M} {l is a lstring} {r is a lstring} {l is a lstring}} +} {{! e i d { } o t { } e r a p e r P { } . r e h t a f { } y m { } d e l l i k { } u o Y { } . a y o t n o M { } o g i n I { } s i { } e m a n { } y M} lstring lstring lstring} test abstractlist-3.3 {shimmer lrange} { set l [lstring -not SLICE $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set il [lsearch -all [lstring -not SLICE $str] { }] - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] lappend il [llength $l] set start 0 set words [lmap i $il { @@ -244,13 +233,13 @@ test abstractlist-3.3 {shimmer lrange} { set start [expr {$i+1}] set w }] - set l-isa3 [value-isa l]; # lrange defaults to list behavior + set l-isa3 [testobj objtype $l]; # lrange defaults to list behavior list ${l-isa} $il ${l-isa2} ${l-isa3} $words -} {{l is a lstring} {2 7 10 16 25 29 36 39 47 55 58 63} {l is a lstring} {l is a list} {My name is Inigo Montoya. You killed my father. Prepare to die!}} +} {lstring {2 7 10 16 25 29 36 39 47 55 58 63} lstring list {My name is Inigo Montoya. You killed my father. Prepare to die!}} test abstractlist-3.4 {no shimmer foreach} { set l [lstring -not SLICE $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set word {} set words {} foreach c $l { @@ -264,89 +253,89 @@ test abstractlist-3.4 {no shimmer foreach} { if {$word ne ""} { lappend words $word } - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] list ${l-isa} ${l-isa2} $words -} {{l is a lstring} {l is a lstring} {My name is Inigo Montoya. You killed my father. Prepare to die!}} +} {lstring lstring {My name is Inigo Montoya. You killed my father. Prepare to die!}} # -# The TBCE implements lreplace as a lrange + lappend operation, so, in this case, $m results is a list, not an lstring. +# The TBCE implements lreplace as a lrange + lappend operation, so, in this case, $m list, not an lstring. # test abstractlist-3.5 {!no shimmer lreplace} { set l [lstring -not SLICE $str2] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [lreplace $l 18 23 { } f a i l ?] - set m-isa [value-isa m] - set l-isa1 [value-isa l] + set m-isa [testobj objtype $m] + set l-isa1 [testobj objtype $l] list ${l-isa} $m ${m-isa} ${l-isa1} -} {{l is a lstring} {V i z z i n i : { } H E { } D I D N ' T { } f a i l ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {m is a lstring} {l is a lstring}} +} {lstring {V i z z i n i : { } H E { } D I D N ' T { } f a i l ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} lstring lstring} test abstractlist-3.6 {no shimmer ledit} { # "ledit m 9 8 S" set l [lstring -not SLICE $str2] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set e [ledit l 9 8 S] - set e-isa [value-isa e] + set e-isa [testobj objtype $e] list ${l-isa} $e ${e-isa} -} {{l is a lstring} {V i z z i n i : { } S H E { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {e is a lstring}} +} {lstring {V i z z i n i : { } S H E { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} lstring} test abstractlist-3.7 {no shimmer linsert} { # "ledit m 9 8 S" set res {} set l [lstring -not SLICE $str2] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set i [linsert $l 12 {*}[split "almost " {}]] - set i-isa [value-isa i] + set i-isa [testobj objtype $i] set res [list ${l-isa} $i ${i-isa}] set p [lpop i 23] - set p-isa [value-isa p] - set i-isa2 [value-isa i] + set p-isa [testobj objtype $p] + set i-isa2 [testobj objtype $i] lappend res $p ${p-isa} $i ${i-isa2} -} {{l is a lstring} {V i z z i n i : { } H E { } a l m o s t { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {i is a lstring} ' {p is a pure} {V i z z i n i : { } H E { } a l m o s t { } D I D N T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {i is a lstring}} +} {lstring {V i z z i n i : { } H E { } a l m o s t { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} lstring ' none {V i z z i n i : { } H E { } a l m o s t { } D I D N T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} lstring} test abstractlist-3.8 {shimmer lassign} { set l [lstring -not SLICE Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set l2 [lassign $l i n c] ;# must be using lrange internally - set l-isa2 [value-isa l] - set l2-isa [value-isa l2] + set l-isa2 [testobj objtype $l] + set l2-isa [testobj objtype $l2] list $l ${l-isa} $l2 ${l-isa2} ${l2-isa} -} {{I n c o n c e i v a b l e} {l is a lstring} {o n c e i v a b l e} {l is a list} {l2 is a list}} +} {{I n c o n c e i v a b l e} lstring {o n c e i v a b l e} list list} test abstractlist-3.9 {no shimmer lremove} { set l [lstring -not SLICE Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set l2 [lremove $l 0 1] - set l-isa2 [value-isa l] - set l2-isa [value-isa l2] + set l-isa2 [testobj objtype $l] + set l2-isa [testobj objtype $l2] list $l ${l-isa} $l2 ${l-isa2} ${l2-isa} -} {{I n c o n c e i v a b l e} {l is a lstring} {c o n c e i v a b l e} {l is a lstring} {l2 is a lstring}} +} {{I n c o n c e i v a b l e} lstring {c o n c e i v a b l e} lstring lstring} test abstractlist-3.10 {shimmer lreverse} { set l [lstring -not SLICE Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set l2 [lreverse $l] - set l-isa2 [value-isa l] - set l2-isa [value-isa l2] + set l-isa2 [testobj objtype $l] + set l2-isa [testobj objtype $l2] list $l ${l-isa} $l2 ${l-isa2} ${l2-isa} -} {{I n c o n c e i v a b l e} {l is a lstring} {e l b a v i e c n o c n I} {l is a lstring} {l2 is a lstring}} +} {{I n c o n c e i v a b l e} lstring {e l b a v i e c n o c n I} lstring lstring} test abstractlist-3.11 {shimmer lset} { set l [lstring -not SLICE Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [lset l 2 k] - set m-isa [value-isa m] + set m-isa [testobj objtype $m] list $l ${l-isa} $m ${m-isa} [value-cmp l m] -} {{I n k o n c e i v a b l e} {l is a lstring} {I n k o n c e i v a b l e} {m is a lstring} 0} +} {{I n k o n c e i v a b l e} lstring {I n k o n c e i v a b l e} lstring 0} # lrepeat test abstractlist-3.12 {shimmer lrepeat} { set l [lstring -not SLICE Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [lrepeat 3 $l] - set m-isa [value-isa m] + set m-isa [testobj objtype $m] set n [lindex $m 1] - list $l ${l-isa} $m ${m-isa} [value-isa n] [value-cmp l n] -} {{I n c o n c e i v a b l e} {l is a lstring} {{I n c o n c e i v a b l e} {I n c o n c e i v a b l e} {I n c o n c e i v a b l e}} {m is a list} {n is a lstring} 0} + list $l ${l-isa} $m ${m-isa} [testobj objtype $n] [value-cmp l n] +} {{I n c o n c e i v a b l e} lstring {{I n c o n c e i v a b l e} {I n c o n c e i v a b l e} {I n c o n c e i v a b l e}} list lstring 0} # lsort foreach not {{} REVERSE SLICE SETELEMENT REPLACE GETELEMENTS} { @@ -356,34 +345,34 @@ foreach not {{} REVERSE SLICE SETELEMENT REPLACE GETELEMENTS} { test abstractlist-$not-4.0 {no shimmer llength} { set l [lstring {*}$options $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set len [llength $l] - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] list $l ${l-isa} ${len} ${l-isa2} -} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} {l is a lstring} 63 {l is a lstring}} +} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} lstring 63 lstring} test abstractlist-$not-4.1 {no shimmer lindex} { set l [lstring {*}$options $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set ele [lindex $l 22] - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] list $l ${l-isa} ${ele} ${l-isa2} -} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} {l is a lstring} y {l is a lstring}} +} {{M y { } n a m e { } i s { } I n i g o { } M o n t o y a . { } Y o u { } k i l l e d { } m y { } f a t h e r . { } P r e p a r e { } t o { } d i e !} lstring y lstring} test abstractlist-$not-4.2 {lreverse} ReverseShimmer { set l [lstring {*}$options $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set r [lreverse $l] - set r-isa [value-isa r] - set l-isa2 [value-isa l] + set r-isa [testobj objtype $r] + set l-isa2 [testobj objtype $l] list $r ${l-isa} ${r-isa} ${l-isa2} -} {{! e i d { } o t { } e r a p e r P { } . r e h t a f { } y m { } d e l l i k { } u o Y { } . a y o t n o M { } o g i n I { } s i { } e m a n { } y M} {l is a lstring} {r is a lstring} {l is a lstring}} +} {{! e i d { } o t { } e r a p e r P { } . r e h t a f { } y m { } d e l l i k { } u o Y { } . a y o t n o M { } o g i n I { } s i { } e m a n { } y M} lstring lstring lstring} test abstractlist-$not-4.3 {no shimmer lrange} RangeShimmer { set l [lstring {*}$options $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set il [lsearch -all [lstring {*}$options $str] { }] - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] lappend il [llength $l] set start 0 set words [lmap i $il { @@ -391,13 +380,13 @@ test abstractlist-$not-4.3 {no shimmer lrange} RangeShimmer { set start [expr {$i+1}] set w }] - set l-isa3 [value-isa l] + set l-isa3 [testobj objtype $l] list ${l-isa} $il ${l-isa2} ${l-isa3} $words -} {{l is a lstring} {2 7 10 16 25 29 36 39 47 55 58 63} {l is a lstring} {l is a lstring} {My name is Inigo Montoya. You killed my father. Prepare to die!}} +} {lstring {2 7 10 16 25 29 36 39 47 55 58 63} lstring lstring {My name is Inigo Montoya. You killed my father. Prepare to die!}} test abstractlist-$not-4.4 {no shimmer foreach} { set l [lstring {*}$options $str] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set word {} set words {} foreach c $l { @@ -411,94 +400,94 @@ test abstractlist-$not-4.4 {no shimmer foreach} { if {$word ne ""} { lappend words $word } - set l-isa2 [value-isa l] + set l-isa2 [testobj objtype $l] list ${l-isa} ${l-isa2} $words -} {{l is a lstring} {l is a lstring} {My name is Inigo Montoya. You killed my father. Prepare to die!}} +} {lstring lstring {My name is Inigo Montoya. You killed my father. Prepare to die!}} # -# The TBCE implements lreplace as a lrange + lappend operation, so, in this case, $m results is a list, not an lstring. +# The TBCE implements lreplace as a lrange + lappend operation, so, in this case, $m list, not an lstring. # test abstractlist-$not-4.5 {!no shimmer lreplace} RangeShimmer { set l [lstring {*}$options $str2] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [lreplace $l 18 23 { } f a i l ?] - set m-isa [value-isa m] - set l-isa1 [value-isa l] + set m-isa [testobj objtype $m] + set l-isa1 [testobj objtype $l] list ${l-isa} $m ${m-isa} ${l-isa1} -} {{l is a lstring} {V i z z i n i : { } H E { } D I D N ' T { } f a i l ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {m is a list} {l is a lstring}} +} {lstring {V i z z i n i : { } H E { } D I D N ' T { } f a i l ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} list lstring} test abstractlist-$not-4.6 {no shimmer ledit} {SetelementShimmer ReplaceShimmer} { # "ledit m 9 8 S" set l [lstring {*}$options $str2] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set e [ledit l 9 8 S] - set e-isa [value-isa e] + set e-isa [testobj objtype $e] list ${l-isa} $e ${e-isa} -} {{l is a lstring} {V i z z i n i : { } S H E { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {e is a lstring}} +} {lstring {V i z z i n i : { } S H E { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} lstring} test abstractlist-$not-4.7 {no shimmer linsert} ReplaceShimmer { # "ledit m 9 8 S" set l [lstring {*}$options $str2] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set i [linsert $l 12 {*}[split "almost " {}]] - set i-isa [value-isa i] + set i-isa [testobj objtype $i] set res [list ${l-isa} $i ${i-isa}] set p [lpop i 23] - set p-isa [value-isa p] - set i-isa2 [value-isa i] + set p-isa [testobj objtype $p] + set i-isa2 [testobj objtype $i] lappend res $p ${p-isa} $i ${i-isa2} -} {{l is a lstring} {V i z z i n i : { } H E { } a l m o s t { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {i is a lstring} ' {p is a pure} {V i z z i n i : { } H E { } a l m o s t { } D I D N T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} {i is a list}} +} {lstring {V i z z i n i : { } H E { } a l m o s t { } D I D N ' T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} lstring ' none {V i z z i n i : { } H E { } a l m o s t { } D I D N T { } F A L L ? { } I N C O N C E I V A B L E . { } I n i g o { } M o n t o y a : { } Y o u { } k e e p { } u s i n g { } t h a t { } w o r d . { } I { } d o { } n o t { } t h i n k { } i t { } m e a n s { } w h a t { } y o u { } t h i n k { } i t { } m e a n s .} list} # lassign probably uses lrange internally test abstractlist-$not-4.8 {shimmer lassign} RangeShimmer { set l [lstring {*}$options Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set l2 [lassign $l i n c] - set l-isa2 [value-isa l] - set l2-isa [value-isa l2] + set l-isa2 [testobj objtype $l] + set l2-isa [testobj objtype $l2] list $l ${l-isa} $l2 ${l-isa2} ${l2-isa} -} {{I n c o n c e i v a b l e} {l is a lstring} {o n c e i v a b l e} {l is a lstring} {l2 is a lstring}} +} {{I n c o n c e i v a b l e} lstring {o n c e i v a b l e} lstring lstring} test abstractlist-$not-4.9 {no shimmer lremove} ReplaceShimmer { set l [lstring {*}$options Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set l2 [lremove $l 0 1] - set l-isa2 [value-isa l] - set l2-isa [value-isa l2] + set l-isa2 [testobj objtype $l] + set l2-isa [testobj objtype $l2] list $l ${l-isa} $l2 ${l-isa2} ${l2-isa} -} {{I n c o n c e i v a b l e} {l is a lstring} {c o n c e i v a b l e} {l is a lstring} {l2 is a lstring}} +} {{I n c o n c e i v a b l e} lstring {c o n c e i v a b l e} lstring lstring} test abstractlist-$not-4.10 {shimmer lreverse} ReverseShimmer { set l [lstring {*}$options Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set l2 [lreverse $l] - set l-isa2 [value-isa l] - set l2-isa [value-isa l2] + set l-isa2 [testobj objtype $l] + set l2-isa [testobj objtype $l2] list $l ${l-isa} $l2 ${l-isa2} ${l2-isa} -} {{I n c o n c e i v a b l e} {l is a lstring} {e l b a v i e c n o c n I} {l is a lstring} {l2 is a lstring}} +} {{I n c o n c e i v a b l e} lstring {e l b a v i e c n o c n I} lstring lstring} test abstractlist-$not-4.11 {shimmer lset} SetelementShimmer { set l [lstring {*}$options Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [lset l 2 k] - set m-isa [value-isa m] + set m-isa [testobj objtype $m] list $l ${l-isa} $m ${m-isa} [value-cmp l m] -} {{I n k o n c e i v a b l e} {l is a lstring} {I n k o n c e i v a b l e} {m is a lstring} 0} +} {{I n k o n c e i v a b l e} lstring {I n k o n c e i v a b l e} lstring 0} test abstractlist-$not-4.11x {lset not compiled} {SetelementShimmer testevalex} { set l [lstring {*}$options Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [testevalex {lset l 2 k}] - set m-isa [value-isa m] + set m-isa [testobj objtype $m] list $l ${l-isa} $m ${m-isa} [value-cmp l m] -} {{I n k o n c e i v a b l e} {l is a lstring} {I n k o n c e i v a b l e} {m is a lstring} 0} +} {{I n k o n c e i v a b l e} lstring {I n k o n c e i v a b l e} lstring 0} test abstractlist-$not-4.11e {error case lset multiple indicies} \ -constraints {SetelementShimmer testevalex} -body { set l [lstring Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [testevalex {lset l 2 0 1 k}] - set m-isa [value-isa m] + set m-isa [testobj objtype $m] list $l ${l-isa} $m ${m-isa} [value-cmp l m] } -returnCodes 1 \ -result {Multiple indicies not supported by lstring.} @@ -506,12 +495,12 @@ test abstractlist-$not-4.11e {error case lset multiple indicies} \ # lrepeat test abstractlist-$not-4.12 {shimmer lrepeat} { set l [lstring {*}$options Inconceivable] - set l-isa [value-isa l] + set l-isa [testobj objtype $l] set m [lrepeat 3 $l] - set m-isa [value-isa m] + set m-isa [testobj objtype $m] set n [lindex $m 1] - list $l ${l-isa} $m ${m-isa} [value-isa n] [value-cmp l n] -} {{I n c o n c e i v a b l e} {l is a lstring} {{I n c o n c e i v a b l e} {I n c o n c e i v a b l e} {I n c o n c e i v a b l e}} {m is a list} {n is a lstring} 0} + list $l ${l-isa} $m ${m-isa} [testobj objtype $n] [value-cmp l n] +} {{I n c o n c e i v a b l e} lstring {{I n c o n c e i v a b l e} {I n c o n c e i v a b l e} {I n c o n c e i v a b l e}} list lstring 0} # Disable constraint testConstraint [format "%sShimmer" [string totitle $not]] 1 diff --git a/tests/dict.test b/tests/dict.test index d67f703..fe4f498 100644 --- a/tests/dict.test +++ b/tests/dict.test @@ -27,6 +27,7 @@ if {[testConstraint memory]} { expr {$end - $tmp} } } + test dict-1.1 {dict command basic syntax} -returnCodes error -body { dict @@ -138,8 +139,16 @@ test dict-3.15 {compiled dict get error cleanliness - Bug 2431847} -body { dict get $a(z) d }} } -returnCodes error -result {key "d" not known in dictionary} -test dict-3.16 {dict/list shimmering - Bug 3004007} {set l [list p 1 p 2 q 3];dict get $l q;set l} {p 1 p 2 q 3} -test dict-3.17 {dict/list shimmering - Bug 3004007} {set l [list p 1 p 2 q 3];dict get $l q;llength $l} 6 +test dict-3.16 {dict/list shimmering - Bug 3004007} { + set l [list p 1 p 2 q 3] + dict get $l q + list $l [testobj objtype $l] +} {{p 1 p 2 q 3} dict} +test dict-3.17 {dict/list shimmering - Bug 3004007} { + set l [list p 1 p 2 q 3] + dict get $l q + list [llength $l] [testobj objtype $l] +} {6 dict} test dict-4.1 {dict replace command} { dict replace {a b c d} @@ -662,15 +671,15 @@ test dict-14.14 {dict for command: handle representation loss} -body { set keys {} set values {} dict for {k v} $dictVar { - if {[llength $dictVar]} { + if {[string length $dictVar]} { lappend keys $k lappend values $v } } - list [lsort $keys] [lsort $values] + list [lsort $keys] [lsort $values] [testobj objtype $dictVar] } -cleanup { unset dictVar keys values k v -} -result {{a c e g} {b d f h}} +} -result {{a c e g} {b d f h} string} test dict-14.15 {dict for command: keys are unique and iterated over once only} -setup { unset -nocomplain accum array set accum {} @@ -1808,27 +1817,27 @@ test dict-24.14 {dict map command: handle representation loss} -setup { } -body { set dictVar {a b c d e f g h} list [dict size [dict map {k v} $dictVar { - if {[llength $dictVar]} { + if {[string length $dictVar]} { lappend keys $k lappend values $v return -level 0 $k } - }]] [lsort $keys] [lsort $values] + }]] [lsort $keys] [lsort $values] [testobj objtype $dictVar] } -cleanup { unset dictVar keys values k v -} -result {4 {a c e g} {b d f h}} +} -result {4 {a c e g} {b d f h} string} test dict-24.14a {dict map command: handle representation loss} -body { apply {{} { set dictVar {a b c d e f g h} list [dict size [dict map {k v} $dictVar { - if {[llength $dictVar]} { + if {[string length $dictVar]} { lappend keys $k lappend values $v return -level 0 $k } - }]] [lsort $keys] [lsort $values] + }]] [lsort $keys] [lsort $values] [testobj objtype $dictVar] }} -} -result {4 {a c e g} {b d f h}} +} -result {4 {a c e g} {b d f h} string} test dict-24.15 {dict map command: keys are unique and iterated over once only} -setup { unset -nocomplain accum array set accum {} -- cgit v0.12