summaryrefslogtreecommitdiffstats
path: root/tests/registry.test
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2008-11-29 14:44:24 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2008-11-29 14:44:24 (GMT)
commitc2e6687a1fb90743f1c56b21cde68e1344b202cc (patch)
treecf87a9bcf31c6c6dbe83a6e6a2c68cf5401ae14c /tests/registry.test
parenta083198d1f3f7108b6455c4dad72ac0d85a2015a (diff)
downloadtcl-c2e6687a1fb90743f1c56b21cde68e1344b202cc.zip
tcl-c2e6687a1fb90743f1c56b21cde68e1344b202cc.tar.gz
tcl-c2e6687a1fb90743f1c56b21cde68e1344b202cc.tar.bz2
Moved a number of tests to the newer style.
Diffstat (limited to 'tests/registry.test')
-rw-r--r--tests/registry.test224
1 files changed, 122 insertions, 102 deletions
diff --git a/tests/registry.test b/tests/registry.test
index 46b49ba..62c9d84 100644
--- a/tests/registry.test
+++ b/tests/registry.test
@@ -10,7 +10,7 @@
# Copyright (c) 1997 by Sun Microsystems, Inc. All rights reserved.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
-# RCS: @(#) $Id: registry.test,v 1.23 2008/11/12 13:32:28 patthoyts Exp $
+# RCS: @(#) $Id: registry.test,v 1.24 2008/11/29 14:44:24 patthoyts Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -463,153 +463,173 @@ test registry-6.20 {GetValue: values with Unicode strings with embedded nulls} {
set result
} "foo ba r baz"
-test registry-7.1 {GetValueNames: bad key} {win reg english} {
+test registry-7.1 {GetValueNames: bad key} -constraints {win reg english} -setup {
registry delete HKEY_CURRENT_USER\\TclFoobar
- list [catch {registry values HKEY_CURRENT_USER\\TclFoobar} msg] $msg
-} {1 {unable to open key: The system cannot find the file specified.}}
-test registry-7.2 {GetValueNames} {win reg} {
+} -body {
+ registry values HKEY_CURRENT_USER\\TclFoobar
+} -returnCodes error -result {unable to open key: The system cannot find the file specified.}
+test registry-7.2 {GetValueNames} -constraints {win reg} -setup {
registry delete HKEY_CURRENT_USER\\TclFoobar
registry set HKEY_CURRENT_USER\\TclFoobar baz foobar
- set result [registry values HKEY_CURRENT_USER\\TclFoobar]
+} -body {
+ registry values HKEY_CURRENT_USER\\TclFoobar
+} -cleanup {
registry delete HKEY_CURRENT_USER\\TclFoobar
- set result
-} baz
-test registry-7.3 {GetValueNames} {win reg} {
+} -result baz
+test registry-7.3 {GetValueNames} -constraints {win reg} -setup {
registry delete HKEY_CURRENT_USER\\TclFoobar
registry set HKEY_CURRENT_USER\\TclFoobar baz foobar1
registry set HKEY_CURRENT_USER\\TclFoobar blat foobar2
registry set HKEY_CURRENT_USER\\TclFoobar {} foobar3
- set result [lsort [registry values HKEY_CURRENT_USER\\TclFoobar]]
+} -body {
+ lsort [registry values HKEY_CURRENT_USER\\TclFoobar]
+} -cleanup {
registry delete HKEY_CURRENT_USER\\TclFoobar
- set result
-} {{} baz blat}
-test registry-7.4 {GetValueNames: remote key} {win reg nonPortable english} {
+} -result {{} baz blat}
+test registry-7.4 {GetValueNames: remote key} -constraints {win reg nonPortable english} -body {
set hostname [info hostname]
registry set \\\\$hostname\\HKEY_CURRENT_USER\\TclFoobar baz blat
set result [registry values \\\\$hostname\\HKEY_CURRENT_USER\\TclFoobar]
registry delete \\\\$hostname\\HKEY_CURRENT_USER\\TclFoobar
set result
-} baz
-test registry-7.5 {GetValueNames: empty key} {win reg} {
+} -result baz
+test registry-7.5 {GetValueNames: empty key} -constraints {win reg} -setup {
registry delete HKEY_CURRENT_USER\\TclFoobar
registry set HKEY_CURRENT_USER\\TclFoobar
- set result [registry values HKEY_CURRENT_USER\\TclFoobar]
+} -body {
+ registry values HKEY_CURRENT_USER\\TclFoobar
+} -cleanup {
registry delete HKEY_CURRENT_USER\\TclFoobar
- set result
-} {}
-test registry-7.6 {GetValueNames: patterns} {win reg} {
+} -result {}
+test registry-7.6 {GetValueNames: patterns} -constraints {win reg} -setup {
registry delete HKEY_CURRENT_USER\\TclFoobar
registry set HKEY_CURRENT_USER\\TclFoobar baz foobar1
registry set HKEY_CURRENT_USER\\TclFoobar blat foobar2
registry set HKEY_CURRENT_USER\\TclFoobar foo foobar3
- set result [lsort [registry values HKEY_CURRENT_USER\\TclFoobar b*]]
+} -body {
+ lsort [registry values HKEY_CURRENT_USER\\TclFoobar b*]
+} -cleanup {
registry delete HKEY_CURRENT_USER\\TclFoobar
- set result
-} {baz blat}
-test registry-7.7 {GetValueNames: names with spaces} {win reg} {
+} -result {baz blat}
+test registry-7.7 {GetValueNames: names with spaces} -constraints {win reg} -setup {
registry delete HKEY_CURRENT_USER\\TclFoobar
registry set HKEY_CURRENT_USER\\TclFoobar baz\ bar foobar1
registry set HKEY_CURRENT_USER\\TclFoobar blat foobar2
registry set HKEY_CURRENT_USER\\TclFoobar foo foobar3
- set result [lsort [registry values HKEY_CURRENT_USER\\TclFoobar b*]]
+} -body {
+ lsort [registry values HKEY_CURRENT_USER\\TclFoobar b*]
+} -cleanup {
registry delete HKEY_CURRENT_USER\\TclFoobar
- set result
-} {{baz bar} blat}
+} -result {{baz bar} blat}
-test registry-8.1 {OpenSubKey} {win reg nonPortable english} {
- # This test will only succeed if the current user does not have registry
- # access on the specified machine.
- list [catch {registry keys {\\mom\HKEY_LOCAL_MACHINE}} msg] $msg
-} {1 {unable to open key: Access is denied.}}
-test registry-8.2 {OpenSubKey} {win reg} {
+test registry-8.1 {OpenSubKey} -constraints {win reg nonPortable english} \
+ -body {
+ # This test will only succeed if the current user does not have
+ # registry access on the specified machine.
+ registry keys {\\mom\HKEY_LOCAL_MACHINE}
+ } -returnCodes error -result "unable to open key: Access is denied."
+test registry-8.2 {OpenSubKey} -constraints {win reg} -setup {
registry delete HKEY_CURRENT_USER\\TclFoobar
registry set HKEY_CURRENT_USER\\TclFoobar
- set result [registry keys HKEY_CURRENT_USER TclFoobar]
+} -body {
+ registry keys HKEY_CURRENT_USER TclFoobar
+} -cleanup {
registry delete HKEY_CURRENT_USER\\TclFoobar
- set result
-} TclFoobar
-test registry-8.3 {OpenSubKey} {win reg english} {
+} -result {TclFoobar}
+test registry-8.3 {OpenSubKey} -constraints {win reg english} -setup {
registry delete HKEY_CURRENT_USER\\TclFoobar
- list [catch {registry keys HKEY_CURRENT_USER\\TclFoobar} msg] $msg
-} {1 {unable to open key: The system cannot find the file specified.}}
+} -body {
+ registry keys HKEY_CURRENT_USER\\TclFoobar
+} -returnCodes error \
+ -result "unable to open key: The system cannot find the file specified."
-test registry-9.1 {ParseKeyName: bad keys} {win reg} {
- list [catch {registry values \\} msg] $msg
-} "1 {bad key \"\\\": must start with a valid root}"
-test registry-9.2 {ParseKeyName: bad keys} {win reg} {
- list [catch {registry values \\foobar} msg] $msg
-} {1 {bad key "\foobar": must start with a valid root}}
-test registry-9.3 {ParseKeyName: bad keys} {win reg} {
- list [catch {registry values \\\\} msg] $msg
-} {1 {bad root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
-test registry-9.4 {ParseKeyName: bad keys} {win reg} {
- list [catch {registry values \\\\\\} msg] $msg
-} {1 {bad root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
-test registry-9.5 {ParseKeyName: bad keys} {win reg english nt} {
- list [catch {registry values \\\\\\HKEY_CLASSES_ROOT} msg] $msg
-} {1 {unable to open key: The network address is invalid.}}
-test registry-9.6 {ParseKeyName: bad keys} {win reg} {
- list [catch {registry values \\\\gaspode} msg] $msg
-} {1 {bad root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
-test registry-9.7 {ParseKeyName: bad keys} {win reg} {
- list [catch {registry values foobar} msg] $msg
-} {1 {bad root name "foobar": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
-test registry-9.8 {ParseKeyName: null keys} {win reg} {
- list [catch {registry delete HKEY_CLASSES_ROOT\\} msg] $msg
-} {1 {bad key: cannot delete root keys}}
-test registry-9.9 {ParseKeyName: null keys} {win reg english} {
- list [catch {registry keys HKEY_CLASSES_ROOT\\TclFoobar\\baz} msg] $msg
-} {1 {unable to open key: The system cannot find the file specified.}}
+test registry-9.1 {ParseKeyName: bad keys} -constraints {win reg} -body {
+ registry values \\
+} -returnCodes error -result "bad key \"\\\": must start with a valid root"
+test registry-9.2 {ParseKeyName: bad keys} -constraints {win reg} -body {
+ registry values \\foobar
+} -returnCodes error -result {bad key "\foobar": must start with a valid root}
+test registry-9.3 {ParseKeyName: bad keys} -constraints {win reg} -body {
+ registry values \\\\
+} -returnCodes error -result {bad root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}
+test registry-9.4 {ParseKeyName: bad keys} -constraints {win reg} -body {
+ registry values \\\\\\
+} -returnCodes error -result {bad root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}
+test registry-9.5 {ParseKeyName: bad keys} -constraints {win reg english nt} -body {
+ registry values \\\\\\HKEY_CLASSES_ROOT
+} -returnCodes error -result {unable to open key: The network address is invalid.}
+test registry-9.6 {ParseKeyName: bad keys} -constraints {win reg} -body {
+ registry values \\\\gaspode
+} -returnCodes error -result {bad root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}
+test registry-9.7 {ParseKeyName: bad keys} -constraints {win reg} -body {
+ registry values foobar
+} -returnCodes error -result {bad root name "foobar": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}
+test registry-9.8 {ParseKeyName: null keys} -constraints {win reg} -body {
+ registry delete HKEY_CLASSES_ROOT\\
+} -returnCodes error -result {bad key: cannot delete root keys}
+test registry-9.9 {ParseKeyName: null keys} \
+ -constraints {win reg english} \
+ -body {registry keys HKEY_CLASSES_ROOT\\TclFoobar\\baz} \
+ -returnCodes error \
+ -result {unable to open key: The system cannot find the file specified.}
-test registry-10.1 {RecursiveDeleteKey} {win reg} {
+test registry-10.1 {RecursiveDeleteKey} -constraints {win reg} -setup {
registry delete HKEY_CURRENT_USER\\TclFoobar
+} -body {
registry set HKEY_CURRENT_USER\\TclFoobar\\test1
registry set HKEY_CURRENT_USER\\TclFoobar\\test2\\test3
registry delete HKEY_CURRENT_USER\\TclFoobar
set result [registry keys HKEY_CURRENT_USER TclFoobar]
set result
-} {}
-test registry-10.2 {RecursiveDeleteKey} {win reg} {
+} -result {}
+test registry-10.2 {RecursiveDeleteKey} -constraints {win reg} -setup {
registry delete HKEY_CURRENT_USER\\TclFoobar
registry set HKEY_CURRENT_USER\\TclFoobar\\test1
registry set HKEY_CURRENT_USER\\TclFoobar\\test2\\test3
- set result [registry delete HKEY_CURRENT_USER\\TclFoobar\\test2\\test4]
+} -body {
+ registry delete HKEY_CURRENT_USER\\TclFoobar\\test2\\test4
+} -cleanup {
registry delete HKEY_CURRENT_USER\\TclFoobar
- set result
-} {}
+} -result {}
-test registry-11.1 {SetValue: recursive creation} {win reg} {
- registry delete HKEY_CURRENT_USER\\TclFoobar
- registry set HKEY_CURRENT_USER\\TclFoobar\\baz blat foobar
- set result [registry get HKEY_CURRENT_USER\\TclFoobar\\baz blat]
-} foobar
-test registry-11.2 {SetValue: modification} {win reg} {
- registry delete HKEY_CURRENT_USER\\TclFoobar
- registry set HKEY_CURRENT_USER\\TclFoobar\\baz blat foobar
- registry set HKEY_CURRENT_USER\\TclFoobar\\baz blat frob
- set result [registry get HKEY_CURRENT_USER\\TclFoobar\\baz blat]
-} frob
-test registry-11.3 {SetValue: failure} {win reg nonPortable english} {
- # This test will only succeed if the current user does not have registry
- # access on the specified machine.
- list [catch {registry set {\\mom\HKEY_CURRENT_USER\TclFoobar} bar foobar} msg] $msg
-} {1 {unable to open key: Access is denied.}}
+test registry-11.1 {SetValue: recursive creation} \
+ -constraints {win reg} -setup {
+ registry delete HKEY_CURRENT_USER\\TclFoobar
+ } -body {
+ registry set HKEY_CURRENT_USER\\TclFoobar\\baz blat foobar
+ set result [registry get HKEY_CURRENT_USER\\TclFoobar\\baz blat]
+ } -result {foobar}
+test registry-11.2 {SetValue: modification} -constraints {win reg} \
+ -setup {
+ registry delete HKEY_CURRENT_USER\\TclFoobar
+ } -body {
+ registry set HKEY_CURRENT_USER\\TclFoobar\\baz blat foobar
+ registry set HKEY_CURRENT_USER\\TclFoobar\\baz blat frob
+ set result [registry get HKEY_CURRENT_USER\\TclFoobar\\baz blat]
+ } -result {frob}
+test registry-11.3 {SetValue: failure} \
+ -constraints {win reg nonPortable english} \
+ -body {
+ # This test will only succeed if the current user does not have
+ # registry access on the specified machine.
+ registry set {\\mom\HKEY_CURRENT_USER\TclFoobar} bar foobar
+ } -returnCodes error -result {unable to open key: Access is denied.}
-test registry-12.1 {BroadcastValue} {win reg} {
- list [catch {registry broadcast} msg] $msg
-} {1 {wrong # args: should be "registry broadcast keyName ?-timeout millisecs?"}}
-test registry-12.2 {BroadcastValue} {win reg} {
- list [catch {registry broadcast "" -time} msg] $msg
-} {1 {wrong # args: should be "registry broadcast keyName ?-timeout millisecs?"}}
-test registry-12.3 {BroadcastValue} {win reg} {
- list [catch {registry broadcast "" - 500} msg] $msg
-} {1 {wrong # args: should be "registry broadcast keyName ?-timeout millisecs?"}}
-test registry-12.4 {BroadcastValue} {win reg} {
- list [catch {registry broadcast {Environment}} msg] $msg
-} {0 {1 0}}
-test registry-12.5 {BroadcastValue} {win reg} {
- list [catch {registry b {}} msg] $msg
-} {0 {1 0}}
+test registry-12.1 {BroadcastValue} -constraints {win reg} -body {
+ registry broadcast
+} -returnCodes error -result "wrong # args: should be \"registry broadcast keyName ?-timeout millisecs?\""
+test registry-12.2 {BroadcastValue} -constraints {win reg} -body {
+ registry broadcast "" -time
+} -returnCodes error -result "wrong # args: should be \"registry broadcast keyName ?-timeout millisecs?\""
+test registry-12.3 {BroadcastValue} -constraints {win reg} -body {
+ registry broadcast "" - 500
+} -returnCodes error -result "wrong # args: should be \"registry broadcast keyName ?-timeout millisecs?\""
+test registry-12.4 {BroadcastValue} -constraints {win reg} -body {
+ registry broadcast {Environment}
+} -result {1 0}
+test registry-12.5 {BroadcastValue} -constraints {win reg} -body {
+ registry b {}
+} -result {1 0}
# cleanup
::tcltest::cleanupTests