Changeset 424 for trunk/src


Ignore:
Timestamp:
May 1, 2006 11:16:11 PM (18 years ago)
Author:
dkearney
Message:

added some changes for tcl bindings that i've been holding onto for the last few weeks, still testing and changing.

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/RpLibrary.cc

    r400 r424  
    237237
    238238            if (!path.str().empty()) {
    239                 // path.str(_node2comp(snode) + "." + path.str());
    240                 path.str("." + _node2comp(snode) + path.str());
     239                path.str(_node2comp(snode) + "." + path.str());
     240                // path.str("." + _node2comp(snode) + path.str());
    241241            }
    242242            else {
    243                 // path.str(_node2comp(snode));
    244                 path.str("." + _node2comp(snode));
     243                path.str(_node2comp(snode));
     244                // path.str("." + _node2comp(snode));
    245245            }
    246246
     
    495495    }
    496496
     497    /*
    497498    if (path.empty()) {
    498499        // an empty path returns the current RpLibrary
    499500        return this;
    500501    }
    501 
    502     // get the node located at path
    503     retNode = _find(path,NO_CREATE_PATH);
    504 
    505     // if the node exists, create a rappture library object for it.
    506     if (retNode) {
    507         retLib = new RpLibrary( retNode,this->tree );
     502    */
     503
     504    if (path.empty()) {
     505        // this should be a smart pointer,
     506        // if someone deletes the original this->root, this object is void
     507        // and will be a memory leak.
     508        // retNode = this->root;
     509        retLib = new RpLibrary(*this);
     510    }
     511    else {
     512        // get the node located at path
     513        retNode = _find(path,NO_CREATE_PATH);
     514
     515        // if the node exists, create a rappture library object for it.
     516        if (retNode) {
     517            retLib = new RpLibrary( retNode,this->tree );
     518        }
    508519    }
    509520
     
    513524/**********************************************************************/
    514525// METHOD: entities()
    515 /// Search the path of a xml tree and return its next entity.
    516 /**
    517  * It is the user's responsibility to delete the object when
    518  * they are finished using it?, else i need to make this static
     526/// Search the path of a xml tree and return a list of its entities.
     527/**
    519528 */
    520529
     
    529538
    530539    RpLibrary* ele = NULL;
     540    std::string pathBack = "";
    531541
    532542    RpLibrary* child = NULL;
     
    546556        child = NULL;
    547557
     558        if ((*iter).empty()) {
     559            pathBack = "";
     560        }
     561        else {
     562            pathBack = *iter + ".";
     563        }
     564
    548565        while ( ele && (child = ele->children("",child)) != NULL ) {
    549566            childList.push_back(child->nodeComp());
     567            delete child;
    550568        }
    551569
     
    556574
    557575            childType = child->nodeType();
    558             childPath = child->nodePath();
     576            childPath = child->nodeComp();
    559577            if ( (childType == "group") || (childType == "phase") ) {
    560578                // add this path to the queue for paths to search
    561                 queue.push_back(childPath);
     579                queue.push_back(pathBack+childPath);
    562580            }
    563581            else if (childType == "structure") {
    564582                // add this path to the return list
    565                 retList.push_back(child->nodeComp());
     583                retList.push_back(pathBack+child->nodeComp());
    566584
    567585                // check to see if there is a ".current.parameters" node
    568586                // if so, add them to the queue list for paths to search
    569                 paramsPath = childPath + ".current.parameters";
     587                paramsPath = "current.parameters";
    570588                if (child->element(paramsPath) != NULL) {
    571                     queue.push_back(paramsPath);
     589                    queue.push_back((pathBack+child->nodeComp()+"."+paramsPath));
    572590                }
    573591            }
    574592            else {
    575593                // add this path to the return list
    576                 retList.push_back(child->nodeComp());
     594                retList.push_back(pathBack+child->nodeComp());
    577595
    578596                // look for embedded groups and phases
     
    586604                        queue.push_back(cchildPath);
    587605                    }
     606                    delete cchild;
    588607                }
    589608            }
     
    591610            childList.erase(childIter);
    592611            childIter = childList.begin();
     612            delete child;
    593613        }
    594614
     
    629649        return retList;
    630650    }
     651
    631652
    632653    thisv = this->entities(path);
     
    642663        }
    643664
    644         if (!path.empty()) {
    645             thisSpath = path + "." + *thisIter;
    646         }
    647         else {
    648             thisSpath = *thisIter;
    649         }
     665        //if (!path.empty()) {
     666        //    thisSpath = path + "." + *thisIter;
     667        //}
     668        //else {
     669        //    thisSpath = *thisIter;
     670        //}
     671        thisSpath = *thisIter;
    650672
    651673        if (otherIter == otherv.end()) {
     
    660682        else {
    661683
    662             if (!path.empty()) {
    663                 otherSpath = path + "." + *otherIter;
    664             }
    665             else {
    666                 otherSpath = *otherIter;
    667             }
     684            //if (!path.empty()) {
     685            //    otherSpath = path + "." + *otherIter;
     686            //}
     687            //else {
     688            //    otherSpath = *otherIter;
     689            //}
     690            otherSpath = *otherIter;
    668691
    669692            thisVal = this->value(thisSpath);
     
    689712    while ( otherIter != otherv.end() ) {
    690713
    691         if (!path.empty()) {
    692             otherSpath = path + "." + *otherIter;
    693         }
    694         else {
    695             otherSpath = *otherIter;
    696         }
     714        //if (!path.empty()) {
     715        //    otherSpath = path + "." + *otherIter;
     716        //}
     717        //else {
     718        //    otherSpath = *otherIter;
     719        //}
     720        otherSpath = *otherIter;
    697721
    698722        otherVal = otherLib->value(otherSpath);
     
    803827    RpLibrary* retLib = NULL;
    804828    std::string parentPath = "";
    805     std::string::size_type pos = 0;
     829    // std::string::size_type pos = 0;
     830    scew_element* ele = NULL;
    806831    scew_element* retNode = NULL;
    807832
     
    813838    if (path.empty()) {
    814839        // an empty path returns the parent of the current RpLibrary
    815         path = this->nodePath();
    816     }
    817 
    818     // get the path of the parent node
    819     // check to see if the path lists a parent node.
    820     pos = path.rfind(".",std::string::npos);
    821     if (pos != std::string::npos) {
    822         // there is a parent node, get the parent path.
    823         parentPath = path.substr(0,pos);
    824 
    825         // search for hte parent's node
    826         retNode = _find(parentPath,NO_CREATE_PATH);
    827 
     840        ele = this->root;
     841    }
     842    else {
     843        // else find the node representing the provided path
     844        ele = _find(path,NO_CREATE_PATH);
     845    }
     846
     847    if (ele != NULL) {
     848        retNode = scew_element_parent(ele);
    828849        if (retNode) {
    829850            // allocate a new rappture library object for the node
     
    831852        }
    832853    }
     854    else {
     855        // path was not found by _find
     856    }
     857
    833858
    834859    return retLib;
     
    848873{
    849874    RpLibrary* value = NULL;
    850     RpLibrary* child = NULL;
     875    // RpLibrary* child = NULL;
    851876
    852877    if (!this->root) {
     
    867892    }
    868893
    869     while ( (child = value->children("",child)) ) {
    870         this->put(toPath, child);
    871     }
     894    this->put(toPath, value);
     895    delete value;
    872896
    873897    return (*this);
     
    880904//
    881905// The lookup is reset when you send a NULL rpChilNode.
     906// User is responsible for deleting returned values
    882907//
    883908/**
     
    9961021    // this was static so user never has to delete the retLib.
    9971022    // should be replaced by a smart pointer
    998     static RpLibrary* retLib = NULL;
     1023    // static RpLibrary* retLib = NULL;
     1024    RpLibrary* retLib = NULL;
    9991025    int myChildCount = 0;
    10001026    scew_element* parentNode = NULL;
     
    10421068
    10431069    // clean up old memory
    1044     delete retLib;
     1070    // delete retLib;
    10451071
    10461072    if ( (childNode = scew_element_next(parentNode,childNode)) ) {
     
    13611387        // path did not exist and was not created.
    13621388    }
    1363 
    1364     /*
    1365     if (retNode) {
    1366         if ((new_elem = scew_element_copy(value->root))) {
    1367             if (scew_element_add_elem(retNode, new_elem)) {
    1368                 retVal = 0;
    1369             }
    1370         }
    1371     }
    1372 
    1373     */
    13741389
    13751390    return *this;
  • trunk/src/tcl/src/RpLibraryTclInterface.cc

    r403 r424  
    5151static int RpTclLibRemove _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,
    5252                                        int argc, const char *argv[]    ));
     53/*
    5354static int RpTclLibResult _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,
    5455                                        int argc, const char *argv[]    ));
    5556static int RpTclLibValue  _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,
    5657                                        int argc, const char *argv[]    ));
     58*/
    5759static int RpTclLibXml    _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,
    5860                                        int argc, const char *argv[]    ));
     
    7779        "?-as <fval>? ?-type <name>? ?<path>?",},
    7880    {"copy", 2, (Blt_Op)RpTclLibCopy, 5, 6,
    79         "<path> from ?<xmlobj>? <path>",},
    80     {"diff", 1, (Blt_Op)RpTclLibDiff, 3, 3, "<xmlobj>",},
    81     {"element", 1, (Blt_Op)RpTclLibElem, 2, 5, "?-as <fval>? ?<path>?",},
    82     {"get", 1, (Blt_Op)RpTclLibGet, 2, 3, "?<path>?",},
    83     {"info", 1, (Blt_Op)RpTclLibInfo, 3, 3, "<objType>",},
    84     {"isa", 1, (Blt_Op)RpTclLibIsa, 3, 3, "<objType>",},
     81        "path from ?xmlobj? path",},
     82    {"diff", 1, (Blt_Op)RpTclLibDiff, 3, 3, "xmlobj",},
     83    {"element", 1, (Blt_Op)RpTclLibElem, 2, 5, "?-as fval? ?path?",},
     84    {"get", 1, (Blt_Op)RpTclLibGet, 2, 3, "?path?",},
     85    {"info", 1, (Blt_Op)RpTclLibInfo, 3, 3, "objType",},
     86    {"isa", 1, (Blt_Op)RpTclLibIsa, 3, 3, "objType",},
    8587    {"parent", 2, (Blt_Op)RpTclLibParent, 2, 5, "?-as <fval>? ?<path>?",},
    8688    {"put", 2, (Blt_Op)RpTclLibPut, 2, 8,
     
    447449                // evaluate the "-as" flag on the returned node
    448450                retStr = (node->*asProc)();
     451                // remove the object, keep memory clean
     452                delete node;
    449453            }
    450454            else {
     
    484488    int nextarg          = 2;     // start parsing using the '2'th argument
    485489    int argsLeft         = 0;     // temp variable for calculation
    486     int noerr              = 0;     // err flag for Tcl_GetCommandInfo
     490    int noerr            = 0;     // err flag for Tcl_GetCommandInfo
    487491    Tcl_CmdInfo info;  // pointer to the command info
    488492
     
    494498        Tcl_AppendResult(interp,
    495499            "wrong # args: should be \"",
    496             argv[0], " path from ?<xmlobj>? path\"",
     500            argv[0], "copy path from ?xmlobj? path\"",
    497501            (char*)NULL);
    498502        return TCL_ERROR;
     
    544548    // call the rappture library copy function
    545549    ((RpLibrary*) cdata)->copy(toPath, fromPath, fromObj);
    546 
    547     // delete the fromObj pointer ???
    548550
    549551    // clear any previous result in the interpreter
     
    602604            // there was an error getting the command info
    603605            Tcl_AppendResult(interp,
    604                 "There was an error getting the command info for "
    605                 "the provided library \"", otherLibStr.c_str(), "\'",
    606                 "\nAre you sure its a Rappture Library Object?",
     606                "invalid command name \"", otherLibStr.c_str(), "\"",
    607607                (char*)NULL);
    608608            return TCL_ERROR;
     
    612612        Tcl_ResetResult(interp);
    613613        Tcl_AppendResult(interp,
    614             "wrong # args: should be \"diff <xmlobj>\"",
     614            "wrong # args: should be \"diff xmlobj\"",
    615615            (char*)NULL);
    616616        return TCL_ERROR;
     
    708708                    else {
    709709                        Tcl_AppendResult(interp, "bad flavor \"", argv[nextarg],
    710                             "\" for -as: should be component, id, type, path, object",
     710                            "\" for -as: should be component, id, object, path, type",
    711711                            (char*)NULL);
    712712                        return TCL_ERROR;
     
    715715                else {
    716716                    Tcl_AppendResult(interp, "bad flavor \"\" for -as:",
    717                            " should be component, id, type, path, object",
     717                           " should be component, id, object, path, type",
    718718                            (char*)NULL);
    719719                    return TCL_ERROR;
     
    731731    if (argsLeft > 1) {
    732732        Tcl_AppendResult(interp,
    733             "wrong # args: should be \"element ?-as <fval>? ?<path>?\"",
     733            "wrong # args: should be \"element ?-as fval? ?path?\"",
    734734            (char*)NULL);
    735735        return TCL_ERROR;
     
    752752            // evaluate the "-as" flag on the returned node
    753753            retStr = (node->*asProc)();
     754            // remove the object, keep memory clean
     755            delete node;
    754756        }
    755757        else {
     
    840842        Tcl_ResetResult(interp);
    841843        Tcl_AppendResult(interp,
    842             "wrong # args: should be \"info <infoType>\"",
     844            "wrong # args: should be \"info objType\"",
    843845            (char*)NULL);
    844846        return TCL_ERROR;
     
    897899        Tcl_ResetResult(interp);
    898900        Tcl_AppendResult(interp,
    899             "wrong # args: should be \"isa <objType>\"",
     901            "wrong # args: should be \"isa objType\"",
    900902            (char*)NULL);
    901903        return TCL_ERROR;
     
    988990                    else {
    989991                        Tcl_AppendResult(interp, "bad flavor \"", argv[nextarg],
    990                             "\": should be component, id, type, path, object",
     992                            "\": should be component, id, object, path, type",
    991993                            (char*)NULL);
    992994                        return TCL_ERROR;
     
    995997                else {
    996998                    Tcl_AppendResult(interp, "bad flavor \"\" for -as: ",
    997                             "should be component, id, type, path, object",
     999                            "should be component, id, object, path, type",
    9981000                            (char*)NULL);
    9991001                    return TCL_ERROR;
     
    10321034            // evaluate the "-as" flag on the returned node
    10331035            retStr = (node->*asProc)();
     1036            // remove the object, keep memory clean
     1037            delete node;
    10341038        }
    10351039        else {
     
    10801084        if (nextarg < argc && *argv[nextarg] == '-') {
    10811085            if (strncmp(argv[nextarg],"-append",7) == 0) {
    1082                 ++nextarg;
    1083                 if (nextarg < argc) {
    1084                     if (strncmp(argv[nextarg],"yes",3) == 0 ) {
    1085                         append = 1;
    1086                         nextarg++;
    1087                     }
    1088                     else if (strncmp(argv[nextarg],"no",2) == 0 ) {
    1089                         append = 0;
    1090                         nextarg++;
    1091                     }
    1092                     else {
    1093                         appendExpectErr(interp,
    1094                                 "expected boolean value but got ",
    1095                                 argv[nextarg]);
     1086                nextarg++;
     1087                if (argv[nextarg] != NULL) {
     1088                    if (Tcl_GetBoolean(interp, argv[nextarg], &append)) {
     1089                        // unrecognized value for -append option
     1090                        // Tcl_GetBoolean fills in error message
     1091                        // Tcl_AppendResult(interp,
     1092                        //     "expected boolean value but got \"",
     1093                        //     argv[nextarg], "\"", (char*)NULL);
    10961094                        return TCL_ERROR;
    10971095                    }
     1096                    // nextarg++;
    10981097                }
    10991098                else {
    1100                     appendExpectErr(interp,
    1101                             "expected boolean value but got ",
    1102                             argv[nextarg]);
     1099                    // if user does not specify wishes for this option,
     1100                    // return error.
     1101                    // unrecognized value for -units option
     1102                    Tcl_AppendResult(interp,
     1103                        "expected boolean value but got \"\"", (char*)NULL);
    11031104                    return TCL_ERROR;
    11041105                }
    11051106            }
    11061107            else if (strncmp(argv[nextarg],"-id",3) == 0) {
    1107                 id = std::string(argv[++nextarg]);
    11081108                nextarg++;
     1109                id = std::string(argv[nextarg]);
     1110                // nextarg++;
    11091111            }
    11101112            else {
     
    11131115                return TCL_ERROR;
    11141116            }
     1117            nextarg++;
    11151118        }
    11161119    }
     
    12141217}
    12151218
     1219/*
    12161220int
    12171221RpTclLibResult  (   ClientData cdata,
     
    12391243    return TCL_OK;
    12401244}
     1245*/
    12411246
    12421247/**********************************************************************/
     
    12551260 */
    12561261
     1262/*
    12571263int
    12581264RpTclLibValue   (   ClientData cdata,
     
    13311337    return TCL_OK;
    13321338}
     1339*/
    13331340
    13341341/**********************************************************************/
  • trunk/src/tcl/tests/children.test

    r403 r424  
    2424# children "?-as <fval>? ?-type <name>? ?<path>?"
    2525#----------------------------------------------------------
     26catch {unset lib}
     27set lib [Rappture::library rplib_test.xml]
    2628test library-8.0.1 {children command 0 arg} {
    27     catch {unset lib}
    28     set lib [Rappture::library rplib_test.xml]
    2929    $lib children
    3030} {tool input output}
    3131test library-8.1.1 {children command path as default type default 1 arg} {
    32     catch {unset lib}
    33     set lib [Rappture::library rplib_test.xml]
    3432    $lib children "input"
    3533} {string(formula) string(name) number(min) number(max)}
    3634test library-8.1.2 {children command path w/ id as default type default 1 arg} {
    37     catch {unset lib}
    38     set lib [Rappture::library rplib_test.xml]
    3935    $lib children "input.number(min)"
    4036} {about default current}
    4137test library-8.1.3 {children command non-existant path 1 arg} {
    42     catch {unset lib}
    43     set lib [Rappture::library rplib_test.xml]
    4438    $lib children "kdsf.werw(we12)"
    4539} {}
    4640test library-8.2.1 {children command path 2 arg} {
    47     catch {unset lib}
    48     set lib [Rappture::library rplib_test.xml]
    4941    list [catch {$lib children "input.number(min)" "wreew"} msg] $msg
    5042} {1 {wrong # args: should be "children ?-as fval? ?-type name? ?path?"}}
    51 test library-8.3.1 {children command path -as flag  no option} {
    52     catch {unset lib}
    53     set lib [Rappture::library rplib_test.xml]
     43# this test works for tcl version of rappture, different error message
     44#test library-8.3.1.1 {children command path -as flag  no option} {
     45#    list [catch {$lib children -as} msg] $msg
     46#} {1 {bad path component "-as"}}
     47test library-8.3.1.2 {children command path -as flag  no option} {
    5448    list [catch {$lib children -as} msg] $msg
    5549} {1 {bad flavor "" for -as: should be component, id, object, path, type}}
    5650test library-8.3.2 {children command path -as flag component path} {
    57     catch {unset lib}
    58     set lib [Rappture::library rplib_test.xml]
    5951    $lib children -as component "input"
    6052} {string(formula) string(name) number(min) number(max)}
    6153test library-8.3.3 {children command path -as flag id path} {
    62     catch {unset lib}
    63     set lib [Rappture::library rplib_test.xml]
    6454    $lib children -as id "input"
    6555} {formula name min max}
    6656test library-8.3.4 {children command path -as flag type path} {
    67     catch {unset lib}
    68     set lib [Rappture::library rplib_test.xml]
    6957    $lib children -as type "input"
    7058} {string string number number}
    7159test library-8.3.5 {children command path -as path type path} {
    72     catch {unset lib}
    73     set lib [Rappture::library rplib_test.xml]
    7460    $lib children -as path "input"
    75 } {.input.string(formula) .input.string(name) .input.number(min) .input.number(max)}
     61} {input.string(formula) input.string(name) input.number(min) input.number(max)}
    7662test library-8.3.6 {children command path -as object type path} {
    77     catch {unset lib}
    78     set lib [Rappture::library rplib_test.xml]
    7963    $lib children -as object "input"
    80 } {::libraryObj11 ::libraryObj12 ::libraryObj13 ::libraryObj14}
     64} {::libraryObj1 ::libraryObj2 ::libraryObj3 ::libraryObj4}
     65# this test works for old tcl bindings, different error message
     66#test library-8.3.7 {children command path -as junk type path} {
     67#    list [catch {$lib children -as junk "input"} msg] $msg
     68#} {1 {bad flavor "junk": should be component, id, object, path, type}}
     69# this test works for new tcl bindings, different error message
    8170test library-8.3.7 {children command path -as junk type path} {
    82     catch {unset lib}
    83     set lib [Rappture::library rplib_test.xml]
    8471    list [catch {$lib children -as junk "input"} msg] $msg
    8572} {1 {bad flavor "junk" for -as: should be component, id, object, path, type}}
    8673test library-8.4.1 {children command path -type number path} {
    87     catch {unset lib}
    88     set lib [Rappture::library rplib_test.xml]
    8974    $lib children -type "number" "input"
    9075} {number(min) number(max)}
    9176test library-8.4.2 {children command path -type "" path} {
    92     catch {unset lib}
    93     set lib [Rappture::library rplib_test.xml]
    9477    $lib children -type "" "input"
    9578} {string(formula) string(name) number(min) number(max)}
     79test library-8.4.2 {children command path -type "blah" path} {
     80    $lib children -type "blah" "input"
     81} {}
    9682test library-8.5.1 {children command path -junk path} {
    97     catch {unset lib}
    98     set lib [Rappture::library rplib_test.xml]
    9983    list [catch {$lib children -junk "input"} msg] $msg
    10084} {1 {bad option "-junk": should be -as, -type}}
     85test library-8.6.1 {children command 2 opts -as comp -type number, path} {
     86    $lib children -as "component" -type "number" "input"
     87} {number(min) number(max)}
     88test library-8.6.2 {children command 2 opts -as id -type number, path} {
     89    $lib children -as "id" -type "number" "input"
     90} {min max}
     91test library-8.6.3 {children command 2 opts -as type -type number, path} {
     92    $lib children -as "type" -type "number" "input"
     93} {number number}
     94test library-8.6.4 {children command 2 opts -as path -type number, path} {
     95    $lib children -as "path" -type "number" "input"
     96} {input.number(min) input.number(max)}
     97test library-8.6.5 {children command 2 opts -as object -type number, path} {
     98    $lib children -as "object" -type "number" "input"
     99} {::libraryObj5 ::libraryObj6}
    101100
    102101::tcltest::cleanupTests
  • trunk/src/tcl/tests/copy.test

    r403 r424  
    2626catch {unset lib}
    2727set lib [Rappture::library rplib_test.xml]
    28 test library-9.0.1 {copy command, 0 args} {
     28# this test works for old tcl bindings, different error message
     29#test library-9.0.1.1 {copy command, 0 args} {
     30#    list [catch {$lib copy} msg] $msg
     31#} {1 {wrong # args: should be "libraryObj0 copy path from ?arg arg ...?"}}
     32# this test works for new tcl bindings, different error message
     33test library-9.0.1.2 {copy command, 0 args} {
    2934    list [catch {$lib copy} msg] $msg
    30 } {1 {wrong # args: should be "::libraryObj0 copy <path> from ?<xmlobj>? <path>"}}
    31 test library-9.0.2 {copy command, 0 args} {
     35} {1 {wrong # args: should be "::libraryObj0 copy path from ?xmlobj? path"}}
     36# this test works for old tcl bindings, different error message
     37#test library-9.0.2.1 {copy command, 0 args} {
     38#    list [catch {$lib copy "input.number(min)"} msg] $msg
     39#} {1 {wrong # args: should be "libraryObj0 copy path from ?arg arg ...?"}}
     40# this test works for new tcl bindings, different error message
     41test library-9.0.2.2 {copy command, 0 args} {
    3242    list [catch {$lib copy "input.number(min)"} msg] $msg
    33 } {1 {wrong # args: should be "::libraryObj0 copy <path> from ?<xmlobj>? <path>"}}
    34 test library-9.0.3 {copy command, 1 arg} {
     43} {1 {wrong # args: should be "::libraryObj0 copy path from ?xmlobj? path"}}
     44# this test works for old tcl bindings, different error message
     45#test library-9.0.3.1 {copy command, 1 arg} {
     46#    list [catch {$lib copy "input.number(min)" from } msg] $msg
     47#} {1 {wrong # args: should be "copy path from ?xmlobj? path"}}
     48# this test works for new tcl bindings, different error message
     49test library-9.0.3.2 {copy command, 1 arg} {
    3550    list [catch {$lib copy "input.number(min)" from } msg] $msg
    36 } {1 {wrong # args: should be "::libraryObj0 copy <path> from ?<xmlobj>? <path>"}}
     51} {1 {wrong # args: should be "::libraryObj0 copy path from ?xmlobj? path"}}
     52# this test works for old tcl bindings
     53# does not work for new tcl bindings because the bad paths are not
     54# discovered in the binding, but in the core copy function and
     55# currently errors from the core functions are not relayed to
     56# the bindings.
    3757#test library-9.0.4 {copy command not enough arg} {
    3858#    list [catch {$lib copy "input.number(min)" from $lib} msg] $msg
    3959#} {1 {bad path component "::libraryObj0"}}
    40 test library-9.0.5 {copy command not enough arg} {
     60# this test works for old tcl bindings, different error message
     61#test library-9.0.5.1 {copy command not enough arg} {
     62#    list [catch {$lib copy "input.number(min)" from } msg] $msg
     63#} {1 {wrong # args: should be "copy path from ?xmlobj? path"}}
     64test library-9.0.5.2 {copy command not enough arg} {
    4165    list [catch {$lib copy "input.number(min)" from } msg] $msg
    42 } {1 {wrong # args: should be "::libraryObj0 copy <path> from ?<xmlobj>? <path>"}}
    43 test library-9.1.1 {copy command from -> junk} {
     66} {1 {wrong # args: should be "::libraryObj0 copy path from ?xmlobj? path"}}
     67test library-9.1.1 {copy command, bad syntax, switched from -> junk} {
    4468    list [catch {$lib copy "input.number(blah)" junk "input.number(min)"} msg] $msg
    4569} {1 {bad syntax: should be "copy path from ?xmlobj? path"}}
  • trunk/src/tcl/tests/diff.test

    r403 r424  
    2828catch {unset libDefault}
    2929catch {unset libFromGet}
     30
    3031set lib [Rappture::library rplib_test.xml]
    3132set libnew [Rappture::library rplib_test.xml]
    3233set libDefault [Rappture::library rplib_test.xml]
    3334set libFromGet [$libDefault element -as object "input.number(max)"]
    34 test library-10.0.1 {diff command, no arguments} {
     35
     36# this test works for old tcl bindings, different error message
     37#test library-10.0.1.1 {diff command, no arguments} {
     38#    list [catch {$lib diff} msg] $msg
     39#} {1 {wrong # args: should be "libraryObj0 diff libobj"}}
     40# this test works for new tcl bindings, different error message
     41test library-10.0.1.2 {diff command, no arguments} {
    3542    list [catch {$lib diff} msg] $msg
    36 } {1 {wrong # args: should be "::libraryObj0 diff <xmlobj>"}}
     43} {1 {wrong # args: should be "::libraryObj0 diff xmlobj"}}
    3744test library-10.1.1 {diff command, one argument, no difference} {
    3845    $lib diff $libnew
     
    4855    $libFromGet diff $libDefault
    4956} {+ input.string(formula) dsd234ssdf3sdf {} + input.string(name) tnerruc {} + input.number(min) 1 {} + input.number(max) 3 {}}
    50 test library-10.2.1 {diff command, two arguments, returns error} {
     57test library-10.2.1 {diff command, one argument} {
     58    set lib1021 [Rappture::library rplib_test.xml]
     59    $lib1021 put input.number(max).current "5"
     60    $libDefault diff $lib1021
     61} {c input.number(max) 3 5}
     62test library-10.2.2 {diff command, one argument} {
     63    set lib1022 [Rappture::library rplib_test.xml]
     64    $lib1022 put input.number(max).new "5"
     65    $libDefault diff $lib1022
     66} {c input.number(max) 3 5}
     67test library-10.3.1 {diff command, two arguments, returns error} {
    5168    list [catch {$lib diff $libnew $libnew} msg] $msg
    52 } {1 {wrong # args: should be "::libraryObj0 diff <xmlobj>"}}
     69} {1 {wrong # args: should be "::libraryObj0 diff xmlobj"}}
     70test library-10.3.2 {diff command, bad second arg, returns error} {
     71    list [catch {$lib diff slfd} msg] $msg
     72} {1 {invalid command name "slfd"}}
     73test library-10.4.1 {diff command, bad second arg, returns error} {
     74    set slfd 40
     75    list [catch {$lib diff $slfd} msg] $msg
     76} {1 {invalid command name "40"}}
     77# no tests for xmlobj's that are not Rappture Libraries yet
    5378
    5479::tcltest::cleanupTests
  • trunk/src/tcl/tests/element.test

    r403 r424  
    1919}
    2020catch {unset lib}
     21set lib [Rappture::library rplib_test.xml]
    2122
    2223#----------------------------------------------------------
     
    2627#----------------------------------------------------------
    2728test library-5.0.1 {element command 0 arg} {
    28     catch {unset lib}
    29     set lib [Rappture::library rplib_test.xml]
    3029    $lib element
    3130} {}
    3231test library-5.1.1 {element command path as default 1 arg} {
    33     catch {unset lib}
    34     set lib [Rappture::library rplib_test.xml]
    3532    $lib element "input"
    3633} {input}
    3734test library-5.1.2 {element command path w/ id as default 1 arg} {
    38     catch {unset lib}
    39     set lib [Rappture::library rplib_test.xml]
    4035    $lib element "input.number(min)"
    4136} {number(min)}
    4237test library-5.1.3 {element command non-existant path 1 arg} {
    43     catch {unset lib}
    44     set lib [Rappture::library rplib_test.xml]
    4538    $lib element "kdsf.werw(we12)"
    4639} {}
    4740test library-5.2.1 {element command path 2 arg} {
    48     catch {unset lib}
    49     set lib [Rappture::library rplib_test.xml]
    5041    list [catch {$lib element "input.number(min)" "wreew"} msg] $msg
    51 } {1 {wrong # args: should be "element ?-as <fval>? ?<path>?"}}
    52 test library-5.3.1 {element command path -as flag  no option} {
    53     catch {unset lib}
    54     set lib [Rappture::library rplib_test.xml]
     42} {1 {wrong # args: should be "element ?-as fval? ?path?"}}
     43# this test works for old tcl bindings, different error message
     44#test library-5.3.1.1 {element command path -as flag  no option} {
     45#    list [catch {$lib element -as} msg] $msg
     46#} {1 {bad path component "-as"}}
     47# this test works for new tcl bindings, different error message
     48test library-5.3.1.2 {element command path -as flag  no option} {
    5549    list [catch {$lib element -as} msg] $msg
    56 } {1 {bad flavor "" for -as: should be component, id, type, path, object}}
     50} {1 {bad flavor "" for -as: should be component, id, object, path, type}}
    5751test library-5.3.2 {element command path -as component, path with id} {
    58     catch {unset lib}
    59     set lib [Rappture::library rplib_test.xml]
    6052    $lib element -as component "input.number(max)"
    6153} {number(max)}
    6254test library-5.3.3 {element command path -as id, path with id} {
    63     catch {unset lib}
    64     set lib [Rappture::library rplib_test.xml]
    6555    $lib element -as id "input.number(max)"
    6656} {max}
    6757test library-5.3.4 {element command path -as type, path with id} {
    68     catch {unset lib}
    69     set lib [Rappture::library rplib_test.xml]
    7058    $lib element -as type "input.number(max)"
    7159} {number}
    7260test library-5.3.5 {element command path -as path, path with id} {
    73     catch {unset lib}
    74     set lib [Rappture::library rplib_test.xml]
    7561    $lib element -as path "input.number(max)"
    76 } {.input.number(max)}
     62} {input.number(max)}
    7763test library-5.3.6 {element command path -as object, path with id} {
    78     catch {unset lib}
    79     set lib [Rappture::library rplib_test.xml]
    8064    set ele [$lib element -as object "input.number(max)"]
    8165    list [catch {$ele isa ::Rappture::LibraryObj} msg] $msg
    8266} {0 1}
    83 test library-5.3.7 {element command path -as junk, path with id} {
    84     catch {unset lib}
    85     set lib [Rappture::library rplib_test.xml]
     67# this test works for old tcl bindings, different error message
     68#test library-5.3.7.1 {element command path -as junk, path with id} {
     69#    list [catch {$lib element -as junk "input.number(max)"} msg] $msg
     70#} {1 {bad flavor "junk": should be component, id, object, path, type}}
     71# this test works for new tcl bindings, different error message
     72test library-5.3.7.2 {element command path -as junk, path with id} {
    8673    list [catch {$lib element -as junk "input.number(max)"} msg] $msg
    87 } {1 {bad flavor "junk" for -as: should be component, id, type, path, object}}
     74} {1 {bad flavor "junk" for -as: should be component, id, object, path, type}}
    8875test library-5.3.8 {element command path -as component, path does not exist} {
    89     catch {unset lib}
    90     set lib [Rappture::library rplib_test.xml]
    9176    $lib element -as component "input.test(we)"
    9277} {}
    9378test library-5.3.9 {element command path -as id, path does not exist} {
    94     catch {unset lib}
    95     set lib [Rappture::library rplib_test.xml]
    9679    $lib element -as id "input.test(we)"
    9780} {}
    9881test library-5.3.10 {element command path -as type, path does not exist} {
    99     catch {unset lib}
    100     set lib [Rappture::library rplib_test.xml]
    10182    $lib element -as type "input.test(we)"
    10283} {}
    10384test library-5.3.11 {element command path -as path, path does not exist} {
    104     catch {unset lib}
    105     set lib [Rappture::library rplib_test.xml]
    10685    $lib element -as path "input.test(we)"
    10786} {}
    10887test library-5.3.12 {element command path -as object, path does not exist} {
    109     catch {unset lib}
    110     set lib [Rappture::library rplib_test.xml]
    11188    $lib element -as object "input.test(we)"
    11289} {}
    11390test library-5.4.1 {element command path -junk path} {
    114     catch {unset lib}
    115     set lib [Rappture::library rplib_test.xml]
    11691    list [catch {$lib element -junk "input"} msg] $msg
    11792} {1 {bad option "-junk": should be -as}}
  • trunk/src/tcl/tests/get.test

    r403 r424  
    1919}
    2020catch {unset lib}
     21set lib [Rappture::library rplib_test.xml]
    2122
    2223#----------------------------------------------------------
     
    2627#----------------------------------------------------------
    2728test get-1.0.1 {get command, zero arguments } {
    28     catch {unset lib}
    29     set lib [Rappture::library rplib_test.xml]
    3029    set val [$lib get]
    3130} {}
    3231test get-1.0.2 {get command, two arguments } {
    33     catch {unset lib}
    34     set lib [Rappture::library rplib_test.xml]
    35     list { catch [$lib get "input.number(min).default" "ggg"] msg} $msg
    36 } {i1 {wrong # args: should be ::libraryObj1 get ?<path>?}}
     32    list [ catch {$lib get "input.number(min).default" "ggg"} msg] $msg
     33} {1 {wrong # args: should be "::libraryObj0 get ?path?"}}
    3734#----------------------------------------------------------
    3835test get-1.1 {get command valid path} {
    39     catch {unset lib}
    40     set lib [Rappture::library rplib_test.xml]
    4136    set cmd [$lib get "tool.command"]
    4237} {@tool/graph @driver}
    4338#----------------------------------------------------------
    4439test get-1.1.2 {get command valid path, single level path doesnt exist} {
    45     catch {unset lib}
    46     set lib [Rappture::library rplib_test.xml]
    4740    set cmd [$lib get "dsffds"]
    4841} {}
    4942test get-1.1.3 {get command valid path, multiple levels, path doesnt exist} {
    50     catch {unset lib}
    51     set lib [Rappture::library rplib_test.xml]
    5243    set cmd [$lib get "dsffds.sdfsdf"]
    5344} {}
    5445test get-1.1.3 {get command valid path, multiple levels, with id, path doesnt exist} {
    55     catch {unset lib}
    56     set lib [Rappture::library rplib_test.xml]
    5746    set cmd [$lib get "dsffds.sdfsdf(1234)"]
    5847} {}
    5948#----------------------------------------------------------
    6049test get-1.2.1 {get command valid full path number} {
    61     catch {unset lib}
    62     set lib [Rappture::library rplib_test.xml]
    6350    set cmd [$lib get "input.number(min).default"]
    6451} {0}
    6552test get-1.2.2 {get command valid partial path number} {
    66     catch {unset lib}
    67     set lib [Rappture::library rplib_test.xml]
    6853    set cmd [$lib get "input.(min).default"]
    6954} {0}
    7055test get-1.2.3 {get command valid partial path number} {
    71     catch {unset lib}
    72     set lib [Rappture::library rplib_test.xml]
    7356    set cmd [$lib get "input.(min).current"]
    7457} {1}
    7558test get-3.2.5 {get command valid partial path number} {
    76     catch {unset lib}
    77     set lib [Rappture::library rplib_test.xml]
    7859    set cmd [$lib get "input.number.default"]
    7960    # this should grab the first occurance of number -> number(min)
    8061} {0}
    8162test get-3.2.6 {get command valid partial path number} {
    82     catch {unset lib}
    83     set lib [Rappture::library rplib_test.xml]
    8463    set cmd [$lib get "input.number.noexist"]
    8564} {}
    8665test get-3.2.7 {get command valid partial path number} {
    87     catch {unset lib}
    88     set lib [Rappture::library rplib_test.xml]
    8966    set cmd [$lib get "input.(min).noexist"]
    9067} {}
    9168test get-3.2.8 {get command invalid path number} {
    92     catch {unset lib}
    93     set lib [Rappture::library rplib_test.xml]
    9469    set cmd [$lib get "input..number"]
    9570} {}
    9671test get-3.2.9 {get command invalid path number} {
    97     catch {unset lib}
    98     set lib [Rappture::library rplib_test.xml]
    9972    set cmd [$lib get "input.().number"]
    10073} {}
    10174test get-3.2.10 {get command invalid path number} {
    102     catch {unset lib}
    103     set lib [Rappture::library rplib_test.xml]
    10475    set cmd [$lib get "input.(!!).number"]
    10576} {}
  • trunk/src/tcl/tests/isa.test

    r403 r424  
    1919}
    2020catch {unset lib}
     21set lib [Rappture::library rplib_test.xml]
    2122
    2223#----------------------------------------------------------
     
    2526#----------------------------------------------------------
    2627test library-7.0.1 {isa command 0 arg} {
    27     catch {unset lib}
    28     set lib [Rappture::library rplib_test.xml]
    2928    list [catch {$lib isa} msg] $msg
    30 } {1 {wrong # args: should be "::libraryObj0 isa <objType>"}}
     29} {1 {wrong # args: should be "::libraryObj0 isa objType"}}
    3130test library-7.1.1 {isa command 1 valid arg} {
    32     catch {unset lib}
    33     set lib [Rappture::library rplib_test.xml]
    3431    $lib isa ::Rappture::LibraryObj
    3532} {1}
    3633test library-7.1.2 {isa command 1 invalid arg} {
    37     catch {unset lib}
    38     set lib [Rappture::library rplib_test.xml]
    3934    $lib isa ::Rappture::Curve
    4035} {0}
    4136test library-7.1.3 {isa command 1 invalid arg} {
    42     catch {unset lib}
    43     set lib [Rappture::library rplib_test.xml]
    4437    $lib isa sdfsdf
    4538} {0}
    4639test library-7.2.1 {isa command 2 args} {
    47     catch {unset lib}
    48     set lib [Rappture::library rplib_test.xml]
    4940    list [catch {$lib isa ::Rappture::LibraryObj ::Rappture::LibraryObj} msg] $msg
    50 } {1 {wrong # args: should be "::libraryObj4 isa <objType>"}}
     41} {1 {wrong # args: should be "::libraryObj0 isa objType"}}
    5142
    5243
  • trunk/src/tcl/tests/parent.test

    r403 r424  
    1818    namespace import -force ::tcltest::*
    1919}
     20
    2021catch {unset lib}
     22set lib [Rappture::library rplib_test.xml]
    2123
    2224#----------------------------------------------------------
     
    2527#----------------------------------------------------------
    2628test library-6.0.1 {parent command 0 arg} {
    27     catch {unset lib}
    28     set lib [Rappture::library rplib_test.xml]
    2929    $lib parent
    3030} {}
    3131test library-6.1.1 {parent command path as default 1 arg} {
    32     catch {unset lib}
    33     set lib [Rappture::library rplib_test.xml]
    3432    $lib parent "input"
    3533} {}
    3634test library-6.1.2 {parent command path w/ id as default 1 arg} {
    37     catch {unset lib}
    38     set lib [Rappture::library rplib_test.xml]
    3935    $lib parent "input.number(min)"
    4036} {input}
    4137test library-6.1.3 {parent command non-existant path 1 arg} {
    42     catch {unset lib}
    43     set lib [Rappture::library rplib_test.xml]
    4438    $lib parent "kdsf.werw(we12)"
    4539} {}
    4640test library-6.2.1 {parent command path 2 arg} {
    47     catch {unset lib}
    48     set lib [Rappture::library rplib_test.xml]
    4941    list [catch {$lib parent "input.number(min)" "wreew"} msg] $msg
    5042} {1 {wrong # args: should be "parent ?-as <fval>? ?<path>?"}}
    5143test library-6.3.1 {parent command path -as flag  no option} {
    52     catch {unset lib}
    53     set lib [Rappture::library rplib_test.xml]
    5444    list [catch {$lib parent -as} msg] $msg
    55 } {1 {bad flavor "" for -as: should be component, id, type, path, object}}
     45} {1 {bad flavor "" for -as: should be component, id, object, path, type}}
    5646test library-6.3.2 {parent command path -as flag component path with id} {
    57     catch {unset lib}
    58     set lib [Rappture::library rplib_test.xml]
    5947    $lib parent -as component "input.number(max).default"
    6048} {number(max)}
    6149test library-6.3.3 {parent command path -as flag id path with id} {
    62     catch {unset lib}
    63     set lib [Rappture::library rplib_test.xml]
    6450    $lib parent -as id "input.number(max).default"
    6551} {max}
    6652test library-6.3.4 {parent command path -as flag type path with id} {
    67     catch {unset lib}
    68     set lib [Rappture::library rplib_test.xml]
    6953    $lib parent -as type "input.number(max).default"
    7054} {number}
    7155test library-6.3.5 {parent command path -as path type path with id} {
    72     catch {unset lib}
    73     set lib [Rappture::library rplib_test.xml]
    7456    $lib parent -as path "input.number(max).default"
    75 } {.input.number(max)}
     57} {input.number(max)}
    7658test library-6.3.6 {parent command path -as object type path with id} {
    77     catch {unset lib}
    78     set lib [Rappture::library rplib_test.xml]
    7959    set libNew [$lib parent -as object "input.number(max).default"]
    8060    list [catch {$libNew isa ::Rappture::LibraryObj} msg] $msg
    8161} {0 1}
    8262test library-6.3.7 {parent command path -as junk type path with id} {
    83     catch {unset lib}
    84     set lib [Rappture::library rplib_test.xml]
    8563    list [catch {$lib parent -as junk "input.number(max)"} msg] $msg
    86 } {1 {bad flavor "junk" for -as: should be component, id, object, path, type}}
     64} {1 {bad flavor "junk": should be component, id, object, path, type}}
    8765test library-6.3.8 {parent command path -as component, path does not exist} {
    88     catch {unset lib}
    89     set lib [Rappture::library rplib_test.xml]
    9066    $lib parent -as component "input.test(we).current"
    9167} {}
    9268test library-6.3.9 {parent command path -as id, path does not exist} {
    93     catch {unset lib}
    94     set lib [Rappture::library rplib_test.xml]
    9569    $lib parent -as id "input.test(we).current"
    9670} {}
    9771test library-6.3.10 {parent command path -as type, path does not exist} {
    98     catch {unset lib}
    99     set lib [Rappture::library rplib_test.xml]
    10072    $lib parent -as type "input.test(we).current"
    10173} {}
    10274test library-6.3.11 {parent command path -as path, path does not exist} {
    103     catch {unset lib}
    104     set lib [Rappture::library rplib_test.xml]
    10575    $lib parent -as path "input.test(we).current"
    10676} {}
    10777test library-6.3.12 {parent command path -as object, path does not exist} {
    108     catch {unset lib}
    109     set lib [Rappture::library rplib_test.xml]
    11078    $lib parent -as object "input.test(we).current"
    111 } {::libraryObj18}
     79} {}
    11280test library-6.4.1 {parent command path -junk path} {
    113     catch {unset lib}
    114     set lib [Rappture::library rplib_test.xml]
    11581    list [catch {$lib parent -junk "input"} msg] $msg
    11682} {1 {bad option "-junk": should be -as}}
  • trunk/src/tcl/tests/put.test

    r403 r424  
    107107    # $libPut xml
    108108} {1 {expected boolean value but got "junk"}}
    109 test library-4.2.5 {put command test append = "1"} {
     109test library-4.2.6 {put command test append = "1"} {
    110110    catch {unset libPut}
    111111    set libPut [Rappture::library rplib_test.xml]
     
    118118    set rslt
    119119} {0 {} val1val2}
    120 test library-4.2.5 {put command test append = "0"} {
     120test library-4.2.7 {put command test append = "0"} {
    121121    catch {unset libPut}
    122122    set libPut [Rappture::library rplib_test.xml]
     
    129129    set rslt
    130130} {0 {} val2}
    131 test library-4.2.5 {put command test append = "true"} {
     131test library-4.2.8 {put command test append = "true"} {
    132132    catch {unset libPut}
    133133    set libPut [Rappture::library rplib_test.xml]
     
    140140    set rslt
    141141} {0 {} val1val2}
    142 test library-4.2.5 {put command test append = "false"} {
     142test library-4.2.9 {put command test append = "false"} {
    143143    catch {unset libPut}
    144144    set libPut [Rappture::library rplib_test.xml]
Note: See TracChangeset for help on using the changeset viewer.