Diff
Not logged in

Differences From Artifact [fd58459808]:

To Artifact [42d7e93603]:


1
2
3
4
5
6
7
8

9
10
11
12
13

14

15


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

34
35

36

37
38
39
40





41
42
43

44
45
46
47



48
49
50
51
52
53
54
55
56
1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

36


37
38
39




40
41
42
43
44



45




46
47
48


49
50
51
52
53
54
55








+




-
+

+
-
+
+

















-
+
-
-
+

+
-
-
-
-
+
+
+
+
+
-
-
-
+
-
-
-
-
+
+
+
-
-







# Commands covered:  source
#
# 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) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: source.test,v 1.2 1998/09/14 18:40:13 stanton Exp $
# RCS: @(#) $Id: source.test,v 1.3 1999/04/16 00:47:34 stanton Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
if {[string compare test [info procs test]] == 1} then {source defs}
    source [file join [pwd] [file dirname [info script]] defs.tcl]
}

test source-1.1 {source command} {
    set x "old x value"
    set y "old y value"
    set z "old z value"
    makeFile {
	set x 22
	set y 33
	set z 44
    } source.file
    source source.file
    list $x $y $z
} {22 33 44}
test source-1.2 {source command} {
    makeFile {list result} source.file
    source source.file
} result

test source-1.3 {source command} {
# The mac version of source returns a different result for
# the next two tests.
    set y {\ }

    set fd [open source.file w]
if {$tcl_platform(platform) == "macintosh"} {
    set retMsg1 {1 {wrong # args: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
    set retMsg2 {1 {bad argument: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
} else {
    fconfigure $fd -translation lf
    puts -nonewline $fd "list a b c "
    puts $fd [string index $y 0]
    puts $fd "d e f"
    close $fd
    set retMsg1 {1 {wrong # args: should be "source fileName"}}
    set retMsg2 {1 {wrong # args: should be "source fileName"}}
}

test source-2.1 {source error conditions} {
    list [catch {source} msg] $msg
} $retMsg1
test source-2.2 {source error conditions} {
    source source.file
} {a b c d e f}

    list [catch {source a b} msg] $msg
} $retMsg2
test source-2.3 {source error conditions} {
    makeFile {
	set x 146
	error "error in sourced file"
	set y $x
    } source.file
    list [catch {source source.file} msg] $msg $errorInfo
128
129
130
131
132
133
134
135

136
137
138

139
140
141

142
143
144
145
146
147
148
127
128
129
130
131
132
133

134
135
136

137
138
139

140
141
142
143
144
145
146
147







-
+


-
+


-
+







    list [catch {source -rsrc _no_exist_} msg] $msg
} [list 1 "The resource \"_no_exist_\" could not be loaded from application."]
test source-4.2 {source error conditions} {macOnly} {
    list [catch {source -rsrcid bad_id} msg] $msg
} [list 1 "expected integer but got \"bad_id\""]
test source-4.3 {source error conditions} {macOnly} {
    list [catch {source -rsrc rsrcName fileName extra} msg] $msg
} $retMsg1
} {1 {wrong # args: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
test source-4.4 {source error conditions} {macOnly} {
    list [catch {source non_switch rsrcName} msg] $msg
} $retMsg2
} {1 {bad argument: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
test source-4.5 {source error conditions} {macOnly} {
    list [catch {source -bad_switch argument} msg] $msg
} $retMsg2
} {1 {bad argument: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
test source-5.1 {source resource files} {macOnly} {
    list [catch {source -rsrc rsrcName bad_file} msg] $msg
} [list 1 "Error finding the file: \"bad_file\"."]
test source-5.2 {source resource files} {macOnly} {
    makeFile {return} source.file
    list [catch {source -rsrc rsrcName source.file} msg] $msg
} [list 1 "Error reading the file: \"source.file\"."]
176
177
178
179
180
181
182

183



184
185

186
187









175
176
177
178
179
180
181
182

183
184
185
186

187
188

189
190
191
192
193
194
195
196
197







+
-
+
+
+

-
+

-
+
+
+
+
+
+
+
+
+
test source-6.1 {source is binary ok} {
    set x {}
    makeFile [list set x "a b\0c"] source.file
    source source.file
    string length $x
} 5

# cleanup
catch {removeFile source.file}
catch {::tcltest::removeFile source.file}
::tcltest::cleanupTests
return

# Generate null final value


concat {}