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 | |
---|
22 | #---------------------------------------------------------- |
---|
23 | # diff command |
---|
24 | # diff "<xmlobj>" |
---|
25 | #---------------------------------------------------------- |
---|
26 | catch {unset lib} |
---|
27 | catch {unset libnew} |
---|
28 | catch {unset libDefault} |
---|
29 | catch {unset libFromGet} |
---|
30 | |
---|
31 | set lib [Rappture::library rplib_test.xml] |
---|
32 | set libnew [Rappture::library rplib_test.xml] |
---|
33 | set libDefault [Rappture::library rplib_test.xml] |
---|
34 | set libFromGet [$libDefault element -as object "input.number(max)"] |
---|
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} { |
---|
42 | list [catch {$lib diff} msg] $msg |
---|
43 | } {1 {wrong # args: should be "::libraryObj0 diff xmlobj"}} |
---|
44 | test library-10.1.1 {diff command, one argument, no difference} { |
---|
45 | $lib diff $libnew |
---|
46 | } {} |
---|
47 | test library-10.1.2 {diff command, one argument, with difference} { |
---|
48 | $lib put "input.string(difftest).current" "this is a diff test" |
---|
49 | $lib diff $libnew |
---|
50 | } {- input.string(difftest) {this is a diff test} {}} |
---|
51 | test library-10.1.3 {diff command, one argument, no "input" in argument} { |
---|
52 | $libDefault diff $libFromGet |
---|
53 | } {- input.string(formula) dsd234ssdf3sdf {} - input.string(name) tnerruc {} - input.number(min) 1 {} - input.number(max) 3 {}} |
---|
54 | test library-10.1.4 {diff command, one argument, no "input" in libFromGet} { |
---|
55 | $libFromGet diff $libDefault |
---|
56 | } {+ input.string(formula) dsd234ssdf3sdf {} + input.string(name) tnerruc {} + input.number(min) 1 {} + input.number(max) 3 {}} |
---|
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} { |
---|
68 | list [catch {$lib diff $libnew $libnew} msg] $msg |
---|
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 |
---|
78 | |
---|
79 | ::tcltest::cleanupTests |
---|
80 | return |
---|