blob: 08d72cf336c199b9ea7f976451cb2cf4cdc74e50 (
plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# This file is a Tcl script to test out procedures to write postscript
# for canvases to files and channels. It exercises the procedure
# TkCanvPostscriptCmd in generic/tkCanvPs.c
#
# Copyright (c) 1995 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# RCS: @(#) $Id: canvPs.test,v 1.3 1999/04/16 01:51:34 stanton Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
}
foreach i [winfo children .] {
destroy $i
}
wm geometry . {}
raise .
canvas .c -width 400 -height 300 -bd 2 -relief sunken
.c create rectangle 20 20 80 80 -fill red
pack .c
update
test canvPs-1.1 {test writing to a file} {unixOrPc} {
removeFile foo.ps
.c postscript -file foo.ps
file exists foo.ps
} 1
test canvPs-1.2 {test writing to a file, idempotency} {unixOrPc} {
removeFile foo.ps
removeFile bar.ps
.c postscript -file foo.ps
.c postscript -file bar.ps
set status ok
if {[file size bar.ps] != [file size foo.ps]} {
set status broken
}
set status
} ok
test canvPs-2.1 {test writing to a channel} {unixOrPc} {
removeFile foo.ps
set chan [open foo.ps w]
fconfigure $chan -translation lf
.c postscript -channel $chan
close $chan
file exists foo.ps
} 1
test canvPs-2.2 {test writing to channel, idempotency} {unixOrPc} {
removeFile foo.ps
removeFile bar.ps
set c1 [open foo.ps w]
set c2 [open bar.ps w]
fconfigure $c1 -translation lf
fconfigure $c2 -translation lf
.c postscript -channel $c1
.c postscript -channel $c2
close $c1
close $c2
set status ok
if {[file size bar.ps] != [file size foo.ps]} {
set status broken
}
set status
} ok
test canvPs-2.3 {test writing to channel and file, same output} {unixOnly} {
removeFile foo.ps
removeFile bar.ps
set c1 [open foo.ps w]
fconfigure $c1 -translation lf
.c postscript -channel $c1
close $c1
.c postscript -file bar.ps
set status ok
if {[file size foo.ps] != [file size bar.ps]} {
set status broken
}
set status
} ok
test canvPs-2.4 {test writing to channel and file, same output} {pcOnly} {
removeFile foo.ps
removeFile bar.ps
set c1 [open foo.ps w]
fconfigure $c1 -translation crlf
.c postscript -channel $c1
close $c1
.c postscript -file bar.ps
set status ok
if {[file size foo.ps] != [file size bar.ps]} {
set status broken
}
set status
} ok
# cleanup
removeFile foo.ps
removeFile bar.ps
foreach i [winfo children .] {
destroy $i
}
::tcltest::cleanupTests
return
|