- Timestamp:
- May 1, 2006 11:16:11 PM (18 years ago)
- Location:
- trunk/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/RpLibrary.cc
r400 r424 237 237 238 238 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()); 241 241 } 242 242 else { 243 //path.str(_node2comp(snode));244 path.str("." + _node2comp(snode));243 path.str(_node2comp(snode)); 244 // path.str("." + _node2comp(snode)); 245 245 } 246 246 … … 495 495 } 496 496 497 /* 497 498 if (path.empty()) { 498 499 // an empty path returns the current RpLibrary 499 500 return this; 500 501 } 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 } 508 519 } 509 520 … … 513 524 /**********************************************************************/ 514 525 // 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 /** 519 528 */ 520 529 … … 529 538 530 539 RpLibrary* ele = NULL; 540 std::string pathBack = ""; 531 541 532 542 RpLibrary* child = NULL; … … 546 556 child = NULL; 547 557 558 if ((*iter).empty()) { 559 pathBack = ""; 560 } 561 else { 562 pathBack = *iter + "."; 563 } 564 548 565 while ( ele && (child = ele->children("",child)) != NULL ) { 549 566 childList.push_back(child->nodeComp()); 567 delete child; 550 568 } 551 569 … … 556 574 557 575 childType = child->nodeType(); 558 childPath = child->node Path();576 childPath = child->nodeComp(); 559 577 if ( (childType == "group") || (childType == "phase") ) { 560 578 // add this path to the queue for paths to search 561 queue.push_back( childPath);579 queue.push_back(pathBack+childPath); 562 580 } 563 581 else if (childType == "structure") { 564 582 // add this path to the return list 565 retList.push_back( child->nodeComp());583 retList.push_back(pathBack+child->nodeComp()); 566 584 567 585 // check to see if there is a ".current.parameters" node 568 586 // if so, add them to the queue list for paths to search 569 paramsPath = childPath + ".current.parameters";587 paramsPath = "current.parameters"; 570 588 if (child->element(paramsPath) != NULL) { 571 queue.push_back( paramsPath);589 queue.push_back((pathBack+child->nodeComp()+"."+paramsPath)); 572 590 } 573 591 } 574 592 else { 575 593 // add this path to the return list 576 retList.push_back( child->nodeComp());594 retList.push_back(pathBack+child->nodeComp()); 577 595 578 596 // look for embedded groups and phases … … 586 604 queue.push_back(cchildPath); 587 605 } 606 delete cchild; 588 607 } 589 608 } … … 591 610 childList.erase(childIter); 592 611 childIter = childList.begin(); 612 delete child; 593 613 } 594 614 … … 629 649 return retList; 630 650 } 651 631 652 632 653 thisv = this->entities(path); … … 642 663 } 643 664 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; 650 672 651 673 if (otherIter == otherv.end()) { … … 660 682 else { 661 683 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; 668 691 669 692 thisVal = this->value(thisSpath); … … 689 712 while ( otherIter != otherv.end() ) { 690 713 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; 697 721 698 722 otherVal = otherLib->value(otherSpath); … … 803 827 RpLibrary* retLib = NULL; 804 828 std::string parentPath = ""; 805 std::string::size_type pos = 0; 829 // std::string::size_type pos = 0; 830 scew_element* ele = NULL; 806 831 scew_element* retNode = NULL; 807 832 … … 813 838 if (path.empty()) { 814 839 // 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); 828 849 if (retNode) { 829 850 // allocate a new rappture library object for the node … … 831 852 } 832 853 } 854 else { 855 // path was not found by _find 856 } 857 833 858 834 859 return retLib; … … 848 873 { 849 874 RpLibrary* value = NULL; 850 RpLibrary* child = NULL;875 // RpLibrary* child = NULL; 851 876 852 877 if (!this->root) { … … 867 892 } 868 893 869 while ( (child = value->children("",child)) ) { 870 this->put(toPath, child); 871 } 894 this->put(toPath, value); 895 delete value; 872 896 873 897 return (*this); … … 880 904 // 881 905 // The lookup is reset when you send a NULL rpChilNode. 906 // User is responsible for deleting returned values 882 907 // 883 908 /** … … 996 1021 // this was static so user never has to delete the retLib. 997 1022 // should be replaced by a smart pointer 998 static RpLibrary* retLib = NULL; 1023 // static RpLibrary* retLib = NULL; 1024 RpLibrary* retLib = NULL; 999 1025 int myChildCount = 0; 1000 1026 scew_element* parentNode = NULL; … … 1042 1068 1043 1069 // clean up old memory 1044 delete retLib;1070 // delete retLib; 1045 1071 1046 1072 if ( (childNode = scew_element_next(parentNode,childNode)) ) { … … 1361 1387 // path did not exist and was not created. 1362 1388 } 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 */1374 1389 1375 1390 return *this; -
trunk/src/tcl/src/RpLibraryTclInterface.cc
r403 r424 51 51 static int RpTclLibRemove _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 52 52 int argc, const char *argv[] )); 53 /* 53 54 static int RpTclLibResult _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 54 55 int argc, const char *argv[] )); 55 56 static int RpTclLibValue _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 56 57 int argc, const char *argv[] )); 58 */ 57 59 static int RpTclLibXml _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 58 60 int argc, const char *argv[] )); … … 77 79 "?-as <fval>? ?-type <name>? ?<path>?",}, 78 80 {"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",}, 85 87 {"parent", 2, (Blt_Op)RpTclLibParent, 2, 5, "?-as <fval>? ?<path>?",}, 86 88 {"put", 2, (Blt_Op)RpTclLibPut, 2, 8, … … 447 449 // evaluate the "-as" flag on the returned node 448 450 retStr = (node->*asProc)(); 451 // remove the object, keep memory clean 452 delete node; 449 453 } 450 454 else { … … 484 488 int nextarg = 2; // start parsing using the '2'th argument 485 489 int argsLeft = 0; // temp variable for calculation 486 int noerr 490 int noerr = 0; // err flag for Tcl_GetCommandInfo 487 491 Tcl_CmdInfo info; // pointer to the command info 488 492 … … 494 498 Tcl_AppendResult(interp, 495 499 "wrong # args: should be \"", 496 argv[0], " path from ?<xmlobj>? path\"",500 argv[0], "copy path from ?xmlobj? path\"", 497 501 (char*)NULL); 498 502 return TCL_ERROR; … … 544 548 // call the rappture library copy function 545 549 ((RpLibrary*) cdata)->copy(toPath, fromPath, fromObj); 546 547 // delete the fromObj pointer ???548 550 549 551 // clear any previous result in the interpreter … … 602 604 // there was an error getting the command info 603 605 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(), "\"", 607 607 (char*)NULL); 608 608 return TCL_ERROR; … … 612 612 Tcl_ResetResult(interp); 613 613 Tcl_AppendResult(interp, 614 "wrong # args: should be \"diff <xmlobj>\"",614 "wrong # args: should be \"diff xmlobj\"", 615 615 (char*)NULL); 616 616 return TCL_ERROR; … … 708 708 else { 709 709 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", 711 711 (char*)NULL); 712 712 return TCL_ERROR; … … 715 715 else { 716 716 Tcl_AppendResult(interp, "bad flavor \"\" for -as:", 717 " should be component, id, type, path, object",717 " should be component, id, object, path, type", 718 718 (char*)NULL); 719 719 return TCL_ERROR; … … 731 731 if (argsLeft > 1) { 732 732 Tcl_AppendResult(interp, 733 "wrong # args: should be \"element ?-as <fval>? ?<path>?\"",733 "wrong # args: should be \"element ?-as fval? ?path?\"", 734 734 (char*)NULL); 735 735 return TCL_ERROR; … … 752 752 // evaluate the "-as" flag on the returned node 753 753 retStr = (node->*asProc)(); 754 // remove the object, keep memory clean 755 delete node; 754 756 } 755 757 else { … … 840 842 Tcl_ResetResult(interp); 841 843 Tcl_AppendResult(interp, 842 "wrong # args: should be \"info <infoType>\"",844 "wrong # args: should be \"info objType\"", 843 845 (char*)NULL); 844 846 return TCL_ERROR; … … 897 899 Tcl_ResetResult(interp); 898 900 Tcl_AppendResult(interp, 899 "wrong # args: should be \"isa <objType>\"",901 "wrong # args: should be \"isa objType\"", 900 902 (char*)NULL); 901 903 return TCL_ERROR; … … 988 990 else { 989 991 Tcl_AppendResult(interp, "bad flavor \"", argv[nextarg], 990 "\": should be component, id, type, path, object",992 "\": should be component, id, object, path, type", 991 993 (char*)NULL); 992 994 return TCL_ERROR; … … 995 997 else { 996 998 Tcl_AppendResult(interp, "bad flavor \"\" for -as: ", 997 "should be component, id, type, path, object",999 "should be component, id, object, path, type", 998 1000 (char*)NULL); 999 1001 return TCL_ERROR; … … 1032 1034 // evaluate the "-as" flag on the returned node 1033 1035 retStr = (node->*asProc)(); 1036 // remove the object, keep memory clean 1037 delete node; 1034 1038 } 1035 1039 else { … … 1080 1084 if (nextarg < argc && *argv[nextarg] == '-') { 1081 1085 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); 1096 1094 return TCL_ERROR; 1097 1095 } 1096 // nextarg++; 1098 1097 } 1099 1098 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); 1103 1104 return TCL_ERROR; 1104 1105 } 1105 1106 } 1106 1107 else if (strncmp(argv[nextarg],"-id",3) == 0) { 1107 id = std::string(argv[++nextarg]);1108 1108 nextarg++; 1109 id = std::string(argv[nextarg]); 1110 // nextarg++; 1109 1111 } 1110 1112 else { … … 1113 1115 return TCL_ERROR; 1114 1116 } 1117 nextarg++; 1115 1118 } 1116 1119 } … … 1214 1217 } 1215 1218 1219 /* 1216 1220 int 1217 1221 RpTclLibResult ( ClientData cdata, … … 1239 1243 return TCL_OK; 1240 1244 } 1245 */ 1241 1246 1242 1247 /**********************************************************************/ … … 1255 1260 */ 1256 1261 1262 /* 1257 1263 int 1258 1264 RpTclLibValue ( ClientData cdata, … … 1331 1337 return TCL_OK; 1332 1338 } 1339 */ 1333 1340 1334 1341 /**********************************************************************/ -
trunk/src/tcl/tests/children.test
r403 r424 24 24 # children "?-as <fval>? ?-type <name>? ?<path>?" 25 25 #---------------------------------------------------------- 26 catch {unset lib} 27 set lib [Rappture::library rplib_test.xml] 26 28 test library-8.0.1 {children command 0 arg} { 27 catch {unset lib}28 set lib [Rappture::library rplib_test.xml]29 29 $lib children 30 30 } {tool input output} 31 31 test 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]34 32 $lib children "input" 35 33 } {string(formula) string(name) number(min) number(max)} 36 34 test 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]39 35 $lib children "input.number(min)" 40 36 } {about default current} 41 37 test library-8.1.3 {children command non-existant path 1 arg} { 42 catch {unset lib}43 set lib [Rappture::library rplib_test.xml]44 38 $lib children "kdsf.werw(we12)" 45 39 } {} 46 40 test library-8.2.1 {children command path 2 arg} { 47 catch {unset lib}48 set lib [Rappture::library rplib_test.xml]49 41 list [catch {$lib children "input.number(min)" "wreew"} msg] $msg 50 42 } {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"}} 47 test library-8.3.1.2 {children command path -as flag no option} { 54 48 list [catch {$lib children -as} msg] $msg 55 49 } {1 {bad flavor "" for -as: should be component, id, object, path, type}} 56 50 test library-8.3.2 {children command path -as flag component path} { 57 catch {unset lib}58 set lib [Rappture::library rplib_test.xml]59 51 $lib children -as component "input" 60 52 } {string(formula) string(name) number(min) number(max)} 61 53 test library-8.3.3 {children command path -as flag id path} { 62 catch {unset lib}63 set lib [Rappture::library rplib_test.xml]64 54 $lib children -as id "input" 65 55 } {formula name min max} 66 56 test library-8.3.4 {children command path -as flag type path} { 67 catch {unset lib}68 set lib [Rappture::library rplib_test.xml]69 57 $lib children -as type "input" 70 58 } {string string number number} 71 59 test library-8.3.5 {children command path -as path type path} { 72 catch {unset lib}73 set lib [Rappture::library rplib_test.xml]74 60 $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)} 76 62 test library-8.3.6 {children command path -as object type path} { 77 catch {unset lib}78 set lib [Rappture::library rplib_test.xml]79 63 $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 81 70 test library-8.3.7 {children command path -as junk type path} { 82 catch {unset lib}83 set lib [Rappture::library rplib_test.xml]84 71 list [catch {$lib children -as junk "input"} msg] $msg 85 72 } {1 {bad flavor "junk" for -as: should be component, id, object, path, type}} 86 73 test library-8.4.1 {children command path -type number path} { 87 catch {unset lib}88 set lib [Rappture::library rplib_test.xml]89 74 $lib children -type "number" "input" 90 75 } {number(min) number(max)} 91 76 test library-8.4.2 {children command path -type "" path} { 92 catch {unset lib}93 set lib [Rappture::library rplib_test.xml]94 77 $lib children -type "" "input" 95 78 } {string(formula) string(name) number(min) number(max)} 79 test library-8.4.2 {children command path -type "blah" path} { 80 $lib children -type "blah" "input" 81 } {} 96 82 test library-8.5.1 {children command path -junk path} { 97 catch {unset lib}98 set lib [Rappture::library rplib_test.xml]99 83 list [catch {$lib children -junk "input"} msg] $msg 100 84 } {1 {bad option "-junk": should be -as, -type}} 85 test 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)} 88 test library-8.6.2 {children command 2 opts -as id -type number, path} { 89 $lib children -as "id" -type "number" "input" 90 } {min max} 91 test library-8.6.3 {children command 2 opts -as type -type number, path} { 92 $lib children -as "type" -type "number" "input" 93 } {number number} 94 test 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)} 97 test library-8.6.5 {children command 2 opts -as object -type number, path} { 98 $lib children -as "object" -type "number" "input" 99 } {::libraryObj5 ::libraryObj6} 101 100 102 101 ::tcltest::cleanupTests -
trunk/src/tcl/tests/copy.test
r403 r424 26 26 catch {unset lib} 27 27 set 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 33 test library-9.0.1.2 {copy command, 0 args} { 29 34 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 41 test library-9.0.2.2 {copy command, 0 args} { 32 42 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 49 test library-9.0.3.2 {copy command, 1 arg} { 35 50 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. 37 57 #test library-9.0.4 {copy command not enough arg} { 38 58 # list [catch {$lib copy "input.number(min)" from $lib} msg] $msg 39 59 #} {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"}} 64 test library-9.0.5.2 {copy command not enough arg} { 41 65 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"}} 67 test library-9.1.1 {copy command, bad syntax, switched from -> junk} { 44 68 list [catch {$lib copy "input.number(blah)" junk "input.number(min)"} msg] $msg 45 69 } {1 {bad syntax: should be "copy path from ?xmlobj? path"}} -
trunk/src/tcl/tests/diff.test
r403 r424 28 28 catch {unset libDefault} 29 29 catch {unset libFromGet} 30 30 31 set lib [Rappture::library rplib_test.xml] 31 32 set libnew [Rappture::library rplib_test.xml] 32 33 set libDefault [Rappture::library rplib_test.xml] 33 34 set 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 41 test library-10.0.1.2 {diff command, no arguments} { 35 42 list [catch {$lib diff} msg] $msg 36 } {1 {wrong # args: should be "::libraryObj0 diff <xmlobj>"}}43 } {1 {wrong # args: should be "::libraryObj0 diff xmlobj"}} 37 44 test library-10.1.1 {diff command, one argument, no difference} { 38 45 $lib diff $libnew … … 48 55 $libFromGet diff $libDefault 49 56 } {+ 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} { 57 test 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} 62 test 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} 67 test library-10.3.1 {diff command, two arguments, returns error} { 51 68 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"}} 70 test 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"}} 73 test 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 53 78 54 79 ::tcltest::cleanupTests -
trunk/src/tcl/tests/element.test
r403 r424 19 19 } 20 20 catch {unset lib} 21 set lib [Rappture::library rplib_test.xml] 21 22 22 23 #---------------------------------------------------------- … … 26 27 #---------------------------------------------------------- 27 28 test library-5.0.1 {element command 0 arg} { 28 catch {unset lib}29 set lib [Rappture::library rplib_test.xml]30 29 $lib element 31 30 } {} 32 31 test library-5.1.1 {element command path as default 1 arg} { 33 catch {unset lib}34 set lib [Rappture::library rplib_test.xml]35 32 $lib element "input" 36 33 } {input} 37 34 test 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]40 35 $lib element "input.number(min)" 41 36 } {number(min)} 42 37 test library-5.1.3 {element command non-existant path 1 arg} { 43 catch {unset lib}44 set lib [Rappture::library rplib_test.xml]45 38 $lib element "kdsf.werw(we12)" 46 39 } {} 47 40 test library-5.2.1 {element command path 2 arg} { 48 catch {unset lib}49 set lib [Rappture::library rplib_test.xml]50 41 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 48 test library-5.3.1.2 {element command path -as flag no option} { 55 49 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}} 57 51 test library-5.3.2 {element command path -as component, path with id} { 58 catch {unset lib}59 set lib [Rappture::library rplib_test.xml]60 52 $lib element -as component "input.number(max)" 61 53 } {number(max)} 62 54 test library-5.3.3 {element command path -as id, path with id} { 63 catch {unset lib}64 set lib [Rappture::library rplib_test.xml]65 55 $lib element -as id "input.number(max)" 66 56 } {max} 67 57 test library-5.3.4 {element command path -as type, path with id} { 68 catch {unset lib}69 set lib [Rappture::library rplib_test.xml]70 58 $lib element -as type "input.number(max)" 71 59 } {number} 72 60 test library-5.3.5 {element command path -as path, path with id} { 73 catch {unset lib}74 set lib [Rappture::library rplib_test.xml]75 61 $lib element -as path "input.number(max)" 76 } { .input.number(max)}62 } {input.number(max)} 77 63 test library-5.3.6 {element command path -as object, path with id} { 78 catch {unset lib}79 set lib [Rappture::library rplib_test.xml]80 64 set ele [$lib element -as object "input.number(max)"] 81 65 list [catch {$ele isa ::Rappture::LibraryObj} msg] $msg 82 66 } {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 72 test library-5.3.7.2 {element command path -as junk, path with id} { 86 73 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}} 88 75 test 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]91 76 $lib element -as component "input.test(we)" 92 77 } {} 93 78 test 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]96 79 $lib element -as id "input.test(we)" 97 80 } {} 98 81 test 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]101 82 $lib element -as type "input.test(we)" 102 83 } {} 103 84 test 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]106 85 $lib element -as path "input.test(we)" 107 86 } {} 108 87 test 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]111 88 $lib element -as object "input.test(we)" 112 89 } {} 113 90 test library-5.4.1 {element command path -junk path} { 114 catch {unset lib}115 set lib [Rappture::library rplib_test.xml]116 91 list [catch {$lib element -junk "input"} msg] $msg 117 92 } {1 {bad option "-junk": should be -as}} -
trunk/src/tcl/tests/get.test
r403 r424 19 19 } 20 20 catch {unset lib} 21 set lib [Rappture::library rplib_test.xml] 21 22 22 23 #---------------------------------------------------------- … … 26 27 #---------------------------------------------------------- 27 28 test get-1.0.1 {get command, zero arguments } { 28 catch {unset lib}29 set lib [Rappture::library rplib_test.xml]30 29 set val [$lib get] 31 30 } {} 32 31 test 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?"}} 37 34 #---------------------------------------------------------- 38 35 test get-1.1 {get command valid path} { 39 catch {unset lib}40 set lib [Rappture::library rplib_test.xml]41 36 set cmd [$lib get "tool.command"] 42 37 } {@tool/graph @driver} 43 38 #---------------------------------------------------------- 44 39 test 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]47 40 set cmd [$lib get "dsffds"] 48 41 } {} 49 42 test 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]52 43 set cmd [$lib get "dsffds.sdfsdf"] 53 44 } {} 54 45 test 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]57 46 set cmd [$lib get "dsffds.sdfsdf(1234)"] 58 47 } {} 59 48 #---------------------------------------------------------- 60 49 test get-1.2.1 {get command valid full path number} { 61 catch {unset lib}62 set lib [Rappture::library rplib_test.xml]63 50 set cmd [$lib get "input.number(min).default"] 64 51 } {0} 65 52 test get-1.2.2 {get command valid partial path number} { 66 catch {unset lib}67 set lib [Rappture::library rplib_test.xml]68 53 set cmd [$lib get "input.(min).default"] 69 54 } {0} 70 55 test get-1.2.3 {get command valid partial path number} { 71 catch {unset lib}72 set lib [Rappture::library rplib_test.xml]73 56 set cmd [$lib get "input.(min).current"] 74 57 } {1} 75 58 test get-3.2.5 {get command valid partial path number} { 76 catch {unset lib}77 set lib [Rappture::library rplib_test.xml]78 59 set cmd [$lib get "input.number.default"] 79 60 # this should grab the first occurance of number -> number(min) 80 61 } {0} 81 62 test get-3.2.6 {get command valid partial path number} { 82 catch {unset lib}83 set lib [Rappture::library rplib_test.xml]84 63 set cmd [$lib get "input.number.noexist"] 85 64 } {} 86 65 test get-3.2.7 {get command valid partial path number} { 87 catch {unset lib}88 set lib [Rappture::library rplib_test.xml]89 66 set cmd [$lib get "input.(min).noexist"] 90 67 } {} 91 68 test get-3.2.8 {get command invalid path number} { 92 catch {unset lib}93 set lib [Rappture::library rplib_test.xml]94 69 set cmd [$lib get "input..number"] 95 70 } {} 96 71 test get-3.2.9 {get command invalid path number} { 97 catch {unset lib}98 set lib [Rappture::library rplib_test.xml]99 72 set cmd [$lib get "input.().number"] 100 73 } {} 101 74 test get-3.2.10 {get command invalid path number} { 102 catch {unset lib}103 set lib [Rappture::library rplib_test.xml]104 75 set cmd [$lib get "input.(!!).number"] 105 76 } {} -
trunk/src/tcl/tests/isa.test
r403 r424 19 19 } 20 20 catch {unset lib} 21 set lib [Rappture::library rplib_test.xml] 21 22 22 23 #---------------------------------------------------------- … … 25 26 #---------------------------------------------------------- 26 27 test library-7.0.1 {isa command 0 arg} { 27 catch {unset lib}28 set lib [Rappture::library rplib_test.xml]29 28 list [catch {$lib isa} msg] $msg 30 } {1 {wrong # args: should be "::libraryObj0 isa <objType>"}}29 } {1 {wrong # args: should be "::libraryObj0 isa objType"}} 31 30 test library-7.1.1 {isa command 1 valid arg} { 32 catch {unset lib}33 set lib [Rappture::library rplib_test.xml]34 31 $lib isa ::Rappture::LibraryObj 35 32 } {1} 36 33 test library-7.1.2 {isa command 1 invalid arg} { 37 catch {unset lib}38 set lib [Rappture::library rplib_test.xml]39 34 $lib isa ::Rappture::Curve 40 35 } {0} 41 36 test library-7.1.3 {isa command 1 invalid arg} { 42 catch {unset lib}43 set lib [Rappture::library rplib_test.xml]44 37 $lib isa sdfsdf 45 38 } {0} 46 39 test library-7.2.1 {isa command 2 args} { 47 catch {unset lib}48 set lib [Rappture::library rplib_test.xml]49 40 list [catch {$lib isa ::Rappture::LibraryObj ::Rappture::LibraryObj} msg] $msg 50 } {1 {wrong # args: should be "::libraryObj 4 isa <objType>"}}41 } {1 {wrong # args: should be "::libraryObj0 isa objType"}} 51 42 52 43 -
trunk/src/tcl/tests/parent.test
r403 r424 18 18 namespace import -force ::tcltest::* 19 19 } 20 20 21 catch {unset lib} 22 set lib [Rappture::library rplib_test.xml] 21 23 22 24 #---------------------------------------------------------- … … 25 27 #---------------------------------------------------------- 26 28 test library-6.0.1 {parent command 0 arg} { 27 catch {unset lib}28 set lib [Rappture::library rplib_test.xml]29 29 $lib parent 30 30 } {} 31 31 test library-6.1.1 {parent command path as default 1 arg} { 32 catch {unset lib}33 set lib [Rappture::library rplib_test.xml]34 32 $lib parent "input" 35 33 } {} 36 34 test 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]39 35 $lib parent "input.number(min)" 40 36 } {input} 41 37 test library-6.1.3 {parent command non-existant path 1 arg} { 42 catch {unset lib}43 set lib [Rappture::library rplib_test.xml]44 38 $lib parent "kdsf.werw(we12)" 45 39 } {} 46 40 test library-6.2.1 {parent command path 2 arg} { 47 catch {unset lib}48 set lib [Rappture::library rplib_test.xml]49 41 list [catch {$lib parent "input.number(min)" "wreew"} msg] $msg 50 42 } {1 {wrong # args: should be "parent ?-as <fval>? ?<path>?"}} 51 43 test library-6.3.1 {parent command path -as flag no option} { 52 catch {unset lib}53 set lib [Rappture::library rplib_test.xml]54 44 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}} 56 46 test 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]59 47 $lib parent -as component "input.number(max).default" 60 48 } {number(max)} 61 49 test 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]64 50 $lib parent -as id "input.number(max).default" 65 51 } {max} 66 52 test 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]69 53 $lib parent -as type "input.number(max).default" 70 54 } {number} 71 55 test 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]74 56 $lib parent -as path "input.number(max).default" 75 } { .input.number(max)}57 } {input.number(max)} 76 58 test 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]79 59 set libNew [$lib parent -as object "input.number(max).default"] 80 60 list [catch {$libNew isa ::Rappture::LibraryObj} msg] $msg 81 61 } {0 1} 82 62 test 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]85 63 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}} 87 65 test 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]90 66 $lib parent -as component "input.test(we).current" 91 67 } {} 92 68 test 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]95 69 $lib parent -as id "input.test(we).current" 96 70 } {} 97 71 test 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]100 72 $lib parent -as type "input.test(we).current" 101 73 } {} 102 74 test 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]105 75 $lib parent -as path "input.test(we).current" 106 76 } {} 107 77 test 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]110 78 $lib parent -as object "input.test(we).current" 111 } { ::libraryObj18}79 } {} 112 80 test library-6.4.1 {parent command path -junk path} { 113 catch {unset lib}114 set lib [Rappture::library rplib_test.xml]115 81 list [catch {$lib parent -junk "input"} msg] $msg 116 82 } {1 {bad option "-junk": should be -as}} -
trunk/src/tcl/tests/put.test
r403 r424 107 107 # $libPut xml 108 108 } {1 {expected boolean value but got "junk"}} 109 test library-4.2. 5{put command test append = "1"} {109 test library-4.2.6 {put command test append = "1"} { 110 110 catch {unset libPut} 111 111 set libPut [Rappture::library rplib_test.xml] … … 118 118 set rslt 119 119 } {0 {} val1val2} 120 test library-4.2. 5{put command test append = "0"} {120 test library-4.2.7 {put command test append = "0"} { 121 121 catch {unset libPut} 122 122 set libPut [Rappture::library rplib_test.xml] … … 129 129 set rslt 130 130 } {0 {} val2} 131 test library-4.2. 5{put command test append = "true"} {131 test library-4.2.8 {put command test append = "true"} { 132 132 catch {unset libPut} 133 133 set libPut [Rappture::library rplib_test.xml] … … 140 140 set rslt 141 141 } {0 {} val1val2} 142 test library-4.2. 5{put command test append = "false"} {142 test library-4.2.9 {put command test append = "false"} { 143 143 catch {unset libPut} 144 144 set libPut [Rappture::library rplib_test.xml]
Note: See TracChangeset
for help on using the changeset viewer.