source: trunk/src/tcl/tests/diff.test @ 424

Last change on this file since 424 was 424, checked in by dkearney, 18 years ago

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

File size: 3.3 KB
Line 
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
15if {[lsearch [namespace children] ::tcltest] == -1} {
16    package require tcltest
17    package require Rappture
18    namespace import -force ::tcltest::*
19}
20catch {unset lib}
21
22#----------------------------------------------------------
23# diff command
24# diff "<xmlobj>"
25#----------------------------------------------------------
26catch {unset lib}
27catch {unset libnew}
28catch {unset libDefault}
29catch {unset libFromGet}
30
31set lib [Rappture::library rplib_test.xml]
32set libnew [Rappture::library rplib_test.xml]
33set libDefault [Rappture::library rplib_test.xml]
34set 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
41test 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"}}
44test library-10.1.1 {diff command, one argument, no difference} {
45    $lib diff $libnew
46} {}
47test 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} {}}
51test 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 {}}
54test 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 {}}
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} {
68    list [catch {$lib diff $libnew $libnew} msg] $msg
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
78
79::tcltest::cleanupTests
80return
Note: See TracBrowser for help on using the repository browser.