8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 by Scriptics Corporation.
# Contributions from Don Porter, NIST, 2003. (not subject to US copyright)
#
# 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.9 2003/09/05 21:52:12 dgp Exp $
if {[catch {package require tcltest 2.0.2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2.0.2 required."
return
}
namespace eval ::tcl::test::source {
|
|
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 by Scriptics Corporation.
# Contributions from Don Porter, NIST, 2003. (not subject to US copyright)
#
# 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.10 2003/10/07 21:45:39 dgp Exp $
if {[catch {package require tcltest 2.0.2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2.0.2 required."
return
}
namespace eval ::tcl::test::source {
|
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
string length $x
} -cleanup {
removeFile source.file
} -result 2
test source-7.1 {source -encoding test} -setup {
set sourcefile [makeFile {} source.file]
removeFile source.file
set f [open $sourcefile w]
fconfigure $f -encoding utf-8
puts $f "set symbol(square-root) \u221A; set x correct"
close $f
} -body {
set x unset
source -encoding utf-8 $sourcefile
set x
} -cleanup {
removeFile source.file
} -result correct
test source-7.2 {source -encoding test} -setup {
# This tests for bad interactions between [source -encoding]
# and use of the Control-Z character (\u001A) as a cross-platform
# EOF character by [source]. Here we write out and the [source] a
# file that contains the byte \x1A, although not the character \u001A in
# the indicated encoding.
set sourcefile [makeFile {} source.file]
removeFile source.file
set f [open $sourcefile w]
fconfigure $f -encoding unicode
puts $f "set symbol(square-root) \u221A; set x correct"
close $f
} -body {
set x unset
source -encoding unicode $sourcefile
|
|
|
|
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
string length $x
} -cleanup {
removeFile source.file
} -result 2
test source-7.1 {source -encoding test} -setup {
set sourcefile [makeFile {} source.file]
file delete $sourcefile
set f [open $sourcefile w]
fconfigure $f -encoding utf-8
puts $f "set symbol(square-root) \u221A; set x correct"
close $f
} -body {
set x unset
source -encoding utf-8 $sourcefile
set x
} -cleanup {
removeFile source.file
} -result correct
test source-7.2 {source -encoding test} -setup {
# This tests for bad interactions between [source -encoding]
# and use of the Control-Z character (\u001A) as a cross-platform
# EOF character by [source]. Here we write out and the [source] a
# file that contains the byte \x1A, although not the character \u001A in
# the indicated encoding.
set sourcefile [makeFile {} source.file]
file delete $sourcefile
set f [open $sourcefile w]
fconfigure $f -encoding unicode
puts $f "set symbol(square-root) \u221A; set x correct"
close $f
} -body {
set x unset
source -encoding unicode $sourcefile
|
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
source -encoding no-such-encoding $sourcefile
} -cleanup {
removeFile source.file
} -returnCodes 1 -match glob -result {unknown encoding*}
test source-7.5 {source -encoding: correct operation} -setup {
set sourcefile [makeFile {} source.file]
removeFile source.file
set f [open $sourcefile w]
fconfigure $f -encoding utf-8
puts $f "proc \u20ac {} {return foo}"
close $f
} -body {
source -encoding utf-8 $sourcefile
\u20ac
} -cleanup {
removeFile source.file
rename \u20ac {}
} -result foo
test source-7.6 {source -encoding: mismatch encoding error} -setup {
set sourcefile [makeFile {} source.file]
removeFile source.file
set f [open $sourcefile w]
fconfigure $f -encoding utf-8
puts $f "proc \u20ac {} {return foo}"
close $f
} -body {
source -encoding ascii $sourcefile
\u20ac
|
|
|
|
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
source -encoding no-such-encoding $sourcefile
} -cleanup {
removeFile source.file
} -returnCodes 1 -match glob -result {unknown encoding*}
test source-7.5 {source -encoding: correct operation} -setup {
set sourcefile [makeFile {} source.file]
file delete $sourcefile
set f [open $sourcefile w]
fconfigure $f -encoding utf-8
puts $f "proc \u20ac {} {return foo}"
close $f
} -body {
source -encoding utf-8 $sourcefile
\u20ac
} -cleanup {
removeFile source.file
rename \u20ac {}
} -result foo
test source-7.6 {source -encoding: mismatch encoding error} -setup {
set sourcefile [makeFile {} source.file]
file delete $sourcefile
set f [open $sourcefile w]
fconfigure $f -encoding utf-8
puts $f "proc \u20ac {} {return foo}"
close $f
} -body {
source -encoding ascii $sourcefile
\u20ac
|