1 | # Commands covered: Rappture::library |
---|
2 | # |
---|
3 | # This file contains a collection of tests for one of the Rappture Tcl |
---|
4 | # commands. Sourcing this file into Tcl runs the tests and |
---|
5 | # generates output for errors. No output means no errors were found. |
---|
6 | # |
---|
7 | # ====================================================================== |
---|
8 | # AUTHOR: Derrick Kearney, Purdue University |
---|
9 | # Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
10 | # |
---|
11 | # See the file "license.terms" for information on usage and redistribution |
---|
12 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
13 | |
---|
14 | |
---|
15 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
16 | package require tcltest |
---|
17 | package require Rappture |
---|
18 | namespace import -force ::tcltest::* |
---|
19 | } |
---|
20 | |
---|
21 | catch {unset lib} |
---|
22 | set lib [Rappture::library rplib_test.xml] |
---|
23 | |
---|
24 | #---------------------------------------------------------- |
---|
25 | # parent command |
---|
26 | # parent "?-as <fval>? ?<path>?" |
---|
27 | #---------------------------------------------------------- |
---|
28 | test library-6.0.1 {parent command 0 arg} { |
---|
29 | $lib parent |
---|
30 | } {} |
---|
31 | test library-6.1.1 {parent command path as default 1 arg} { |
---|
32 | $lib parent "input" |
---|
33 | } {} |
---|
34 | test library-6.1.2 {parent command path w/ id as default 1 arg} { |
---|
35 | $lib parent "input.number(min)" |
---|
36 | } {input} |
---|
37 | test library-6.1.3 {parent command non-existant path 1 arg} { |
---|
38 | $lib parent "kdsf.werw(we12)" |
---|
39 | } {} |
---|
40 | test library-6.2.1 {parent command path 2 arg} { |
---|
41 | list [catch {$lib parent "input.number(min)" "wreew"} msg] $msg |
---|
42 | } {1 {wrong # args: should be "parent ?-as fval? ?path?"}} |
---|
43 | test library-6.3.1 {parent command path -as flag no option} { |
---|
44 | list [catch {$lib parent -as} msg] $msg |
---|
45 | } {1 {bad path component "-as"}} |
---|
46 | test library-6.3.2 {parent command path -as flag component path with id} { |
---|
47 | $lib parent -as component "input.number(max).default" |
---|
48 | } {number(max)} |
---|
49 | test library-6.3.3 {parent command path -as flag id path with id} { |
---|
50 | $lib parent -as id "input.number(max).default" |
---|
51 | } {max} |
---|
52 | test library-6.3.4 {parent command path -as flag type path with id} { |
---|
53 | $lib parent -as type "input.number(max).default" |
---|
54 | } {number} |
---|
55 | test library-6.3.5 {parent command path -as path type path with id} { |
---|
56 | $lib parent -as path "input.number(max).default" |
---|
57 | } {input.number(max)} |
---|
58 | test library-6.3.6 {parent command path -as object type path with id} { |
---|
59 | set libNew [$lib parent -as object "input.number(max).default"] |
---|
60 | list [catch {$libNew isa ::Rappture::LibraryObj} msg] $msg |
---|
61 | } {0 1} |
---|
62 | test library-6.3.7 {parent command path -as junk type path with id} { |
---|
63 | list [catch {$lib parent -as junk "input.number(max)"} msg] $msg |
---|
64 | } {1 {bad flavor "junk": should be component, id, object, path, type}} |
---|
65 | test library-6.3.8 {parent command path -as component, path does not exist} { |
---|
66 | $lib parent -as component "input.test(we).current" |
---|
67 | } {} |
---|
68 | test library-6.3.9 {parent command path -as id, path does not exist} { |
---|
69 | $lib parent -as id "input.test(we).current" |
---|
70 | } {} |
---|
71 | test library-6.3.10 {parent command path -as type, path does not exist} { |
---|
72 | $lib parent -as type "input.test(we).current" |
---|
73 | } {} |
---|
74 | test library-6.3.11 {parent command path -as path, path does not exist} { |
---|
75 | $lib parent -as path "input.test(we).current" |
---|
76 | } {} |
---|
77 | test library-6.3.12 {parent command path -as object, path does not exist} { |
---|
78 | $lib parent -as object "input.test(we).current" |
---|
79 | } {} |
---|
80 | test library-6.4.1 {parent command path -junk path} { |
---|
81 | list [catch {$lib parent -junk "input"} msg] $msg |
---|
82 | } {1 {bad option "-junk": should be -as}} |
---|
83 | |
---|
84 | ::tcltest::cleanupTests |
---|
85 | return |
---|