blob: c6fac0a283d41a8307cb99e492cc076e4bee9ea6 (
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
|
# This file is a Tcl script to test out the procedures in the file
# tkUtil.c.
#
# Copyright © 1994 The Regents of the University of California.
# Copyright © 1994 Sun Microsystems, Inc.
# Copyright © 1998-1999 Scriptics Corporation.
# All rights reserved.
#
# TESTFILE INITIALIZATION
#
package require tcltest 2.2; # needed in mode -singleproc 0
# Load the main script main.tcl, which takes care of:
# - setup for the application and the root window
# - importing commands from the tcltest namespace
# - loading of the testutils mechanism along with its utility procs
# - loading of Tk specific test constraints (additionally to constraints
# provided by the package tcltest)
source [file join [tcltest::configure -testdir] main.tcl]
# Ensure a pristine initial window state
resetWindows
#
# COMMON TEST SETUP
#
listbox .l -width 20 -height 5 -relief sunken -bd 2
pack .l
.l insert 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
update
#
# TESTS
#
test util-1.1 {Tk_GetScrollInfo procedure} -body {
.l yview moveto a b
} -returnCodes error -result {wrong # args: should be ".l yview moveto fraction"}
test util-1.2 {Tk_GetScrollInfo procedure} -body {
.l yview moveto xyz
} -returnCodes error -result {expected floating-point number but got "xyz"}
test util-1.3 {Tk_GetScrollInfo procedure} -body {
.l yview 0
.l yview moveto .5
.l yview
} -result {0.5 0.75}
test util-1.4 {Tk_GetScrollInfo procedure} -body {
.l yview scroll a
} -returnCodes error -result {wrong # args: should be ".l yview scroll number pages|units"}
test util-1.5 {Tk_GetScrollInfo procedure} -body {
.l yview scroll a b c
} -returnCodes error -result {wrong # args: should be ".l yview scroll number pages|units"}
test util-1.6 {Tk_GetScrollInfo procedure} -body {
.l yview scroll xyz units
} -returnCodes error -result {expected floating-point number but got "xyz"}
test util-1.7 {Tk_GetScrollInfo procedure} -body {
.l yview 0
.l yview scroll 2 pages
.l nearest 0
} -result 6
test util-1.8 {Tk_GetScrollInfo procedure} -body {
.l yview 15
.l yview scroll -2 pages
.l nearest 0
} -result 9
test util-1.9 {Tk_GetScrollInfo procedure} -body {
.l yview 0
.l yview scroll 2 units
.l nearest 0
} -result 2
test util-1.10 {Tk_GetScrollInfo procedure} -body {
.l yview 15
.l yview scroll -2 units
.l nearest 0
} -result 13
test util-1.11 {Tk_GetScrollInfo procedure} -body {
.l yview scroll 3 zips
} -returnCodes error -result {bad argument "zips": must be pages or units}
test util-1.12 {Tk_GetScrollInfo procedure} -body {
.l yview dropdead 3 times
} -returnCodes error -result {unknown option "dropdead": must be moveto or scroll}
#
# TESTFILE CLEANUP
#
cleanupTests
|