summaryrefslogtreecommitdiffstats
path: root/tests/util.test
blob: d3d5c91bbc305051acb3c8f8ff0567ff8d4a4d28 (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
# This file is a Tcl script to test out the procedures in the file
# tkUtil.c.  It is organized in the standard fashion for Tcl tests.
#
# Copyright (c) 1994 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# RCS: @(#) $Id: util.test,v 1.3 1999/04/16 01:51:42 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 .

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
test util-1.1 {Tk_GetScrollInfo procedure} {
    list [catch {.l yview moveto a b} msg] $msg
} {1 {wrong # args: should be ".l yview moveto fraction"}}
test util-1.2 {Tk_GetScrollInfo procedure} {
    list [catch {.l yview moveto xyz} msg] $msg
} {1 {expected floating-point number but got "xyz"}}
test util-1.3 {Tk_GetScrollInfo procedure} {
    .l yview 0
    .l yview moveto .5
    .l yview
} {0.5 0.75}
test util-1.4 {Tk_GetScrollInfo procedure} {
    list [catch {.l yview scroll a} msg] $msg
} {1 {wrong # args: should be ".l yview scroll number units|pages"}}
test util-1.5 {Tk_GetScrollInfo procedure} {
    list [catch {.l yview scroll a b c} msg] $msg
} {1 {wrong # args: should be ".l yview scroll number units|pages"}}
test util-1.6 {Tk_GetScrollInfo procedure} {
    list [catch {.l yview scroll xyz units} msg] $msg
} {1 {expected integer but got "xyz"}}
test util-1.7 {Tk_GetScrollInfo procedure} {
    .l yview 0
    .l yview scroll 2 pages
    .l nearest 0
} {6}
test util-1.8 {Tk_GetScrollInfo procedure} {
    .l yview 15
    .l yview scroll -2 pages
    .l nearest 0
} {9}
test util-1.9 {Tk_GetScrollInfo procedure} {
    .l yview 0
    .l yview scroll 2 units
    .l nearest 0
} {2}
test util-1.10 {Tk_GetScrollInfo procedure} {
    .l yview 15
    .l yview scroll -2 units
    .l nearest 0
} {13}
test util-1.11 {Tk_GetScrollInfo procedure} {
    list [catch {.l yview scroll 3 zips} msg] $msg
} {1 {bad argument "zips": must be units or pages}}
test util-1.12 {Tk_GetScrollInfo procedure} {
    list [catch {.l yview dropdead 3 times} msg] $msg
} {1 {unknown option "dropdead": must be moveto or scroll}}

# cleanup
::tcltest::cleanupTests
return