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-2006 Purdue Research Foundation |
---|
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 | catch {unset lib} |
---|
21 | set lib [Rappture::library rplib_test.xml] |
---|
22 | |
---|
23 | #---------------------------------------------------------- |
---|
24 | # element command |
---|
25 | # element "?-as <fval>? ?<path>?" |
---|
26 | # <fval> can be component, id, type, path, object |
---|
27 | #---------------------------------------------------------- |
---|
28 | test library-5.0.1 {element command 0 arg} { |
---|
29 | $lib element |
---|
30 | } {} |
---|
31 | test library-5.1.1 {element command path as default 1 arg} { |
---|
32 | $lib element "input" |
---|
33 | } {input} |
---|
34 | test library-5.1.2 {element command path w/ id as default 1 arg} { |
---|
35 | $lib element "input.number(min)" |
---|
36 | } {number(min)} |
---|
37 | test library-5.1.3 {element command non-existant path 1 arg} { |
---|
38 | $lib element "kdsf.werw(we12)" |
---|
39 | } {} |
---|
40 | test library-5.2.1 {element command path 2 arg} { |
---|
41 | list [catch {$lib element "input.number(min)" "wreew"} msg] $msg |
---|
42 | } {1 {wrong # args: should be "element ?-as fval? ?path?"}} |
---|
43 | test library-5.3.1.1 {element command path -as flag no option} { |
---|
44 | list [catch {$lib element -as} msg] $msg |
---|
45 | } {1 {bad path component "-as"}} |
---|
46 | test library-5.3.2 {element command path -as component, path with id} { |
---|
47 | $lib element -as component "input.number(max)" |
---|
48 | } {number(max)} |
---|
49 | test library-5.3.3 {element command path -as id, path with id} { |
---|
50 | $lib element -as id "input.number(max)" |
---|
51 | } {max} |
---|
52 | test library-5.3.4 {element command path -as type, path with id} { |
---|
53 | $lib element -as type "input.number(max)" |
---|
54 | } {number} |
---|
55 | test library-5.3.5 {element command path -as path, path with id} { |
---|
56 | $lib element -as path "input.number(max)" |
---|
57 | } {input.number(max)} |
---|
58 | test library-5.3.6 {element command path -as object, path with id} { |
---|
59 | set ele [$lib element -as object "input.number(max)"] |
---|
60 | list [catch {$ele isa ::Rappture::LibraryObj} msg] $msg |
---|
61 | } {0 1} |
---|
62 | test library-5.3.7.1 {element command path -as junk, path with id} { |
---|
63 | list [catch {$lib element -as junk "input.number(max)"} msg] $msg |
---|
64 | } {1 {bad flavor "junk": should be component, id, object, path, type}} |
---|
65 | test library-5.3.8 {element command path -as component, path does not exist} { |
---|
66 | $lib element -as component "input.test(we)" |
---|
67 | } {} |
---|
68 | test library-5.3.9 {element command path -as id, path does not exist} { |
---|
69 | $lib element -as id "input.test(we)" |
---|
70 | } {} |
---|
71 | test library-5.3.10 {element command path -as type, path does not exist} { |
---|
72 | $lib element -as type "input.test(we)" |
---|
73 | } {} |
---|
74 | test library-5.3.11 {element command path -as path, path does not exist} { |
---|
75 | $lib element -as path "input.test(we)" |
---|
76 | } {} |
---|
77 | test library-5.3.12 {element command path -as object, path does not exist} { |
---|
78 | $lib element -as object "input.test(we)" |
---|
79 | } {} |
---|
80 | test library-5.4.1 {element command path -junk path} { |
---|
81 | list [catch {$lib element -junk "input"} msg] $msg |
---|
82 | } {1 {bad option "-junk": should be -as}} |
---|
83 | |
---|
84 | ::tcltest::cleanupTests |
---|
85 | return |
---|