archie/tcl7.6/tests/resource.test
2024-05-27 16:40:40 +02:00

46 lines
1.7 KiB
Plaintext

# Commands covered: resource
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1996 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# SCCS: @(#) resource.test 1.1 96/10/08 14:35:23
# Only run this test on Macintosh systems
if {$tcl_platform(platform) != "macintosh"} {
return
}
if {[string compare test [info procs test]] == 1} then {source defs}
test resource-1.1 {resource tests} {
list [catch {resource} msg] $msg
} {1 {wrong # args: should be "resource option ?arg ...?"}}
test resource-1.2 {resource tests} {
list [catch {resource _bad_} msg] $msg
} {1 {unknown option "_bad_": should be close, getSTR, getSTR#, getTEXT, list, open or types}}
# resource open & close tests
test resource-2.1 {resource open & close tests} {
list [catch {resource open} msg] $msg
} {1 {wrong # args: should be "resource open fileName"}}
test resource-2.2 {resource open & close tests} {
list [catch {resource open _bad_file_} msg] $msg
} {1 {path doesn't lead to a file}}
test resource-2.3 {resource open & close tests} {
testWriteTextResource -rsrc fileRsrcName -file rsrc.file {error "don't source me"}
set id [resource open rsrc.file]
resource close $id
} {}
test resource-2.4 {resource open & close tests} {
list [catch {resource close _bad_resource_} msg] $msg
} {1 {invalid resource file reference "_bad_resource_"}}
# Clean up and return
catch {file delete rsrc.file}
return