1# This file is a Tcl script to test out the procedures in the file 2# tkUtil.c. It is organized in the standard fashion for Tcl tests. 3# 4# Copyright (c) 1994 The Regents of the University of California. 5# Copyright (c) 1994 Sun Microsystems, Inc. 6# Copyright (c) 1998-1999 by Scriptics Corporation. 7# All rights reserved. 8# 9# RCS: @(#) $Id: util.test,v 1.5 2002/07/13 20:28:36 dgp Exp $ 10 11package require tcltest 2.1 12namespace import -force tcltest::configure 13namespace import -force tcltest::testsDirectory 14configure -testdir [file join [pwd] [file dirname [info script]]] 15configure -loadfile [file join [testsDirectory] constraints.tcl] 16tcltest::loadTestedCommands 17 18listbox .l -width 20 -height 5 -relief sunken -bd 2 19pack .l 20.l insert 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 21update 22test util-1.1 {Tk_GetScrollInfo procedure} { 23 list [catch {.l yview moveto a b} msg] $msg 24} {1 {wrong # args: should be ".l yview moveto fraction"}} 25test util-1.2 {Tk_GetScrollInfo procedure} { 26 list [catch {.l yview moveto xyz} msg] $msg 27} {1 {expected floating-point number but got "xyz"}} 28test util-1.3 {Tk_GetScrollInfo procedure} { 29 .l yview 0 30 .l yview moveto .5 31 .l yview 32} {0.5 0.75} 33test util-1.4 {Tk_GetScrollInfo procedure} { 34 list [catch {.l yview scroll a} msg] $msg 35} {1 {wrong # args: should be ".l yview scroll number units|pages"}} 36test util-1.5 {Tk_GetScrollInfo procedure} { 37 list [catch {.l yview scroll a b c} msg] $msg 38} {1 {wrong # args: should be ".l yview scroll number units|pages"}} 39test util-1.6 {Tk_GetScrollInfo procedure} { 40 list [catch {.l yview scroll xyz units} msg] $msg 41} {1 {expected integer but got "xyz"}} 42test util-1.7 {Tk_GetScrollInfo procedure} { 43 .l yview 0 44 .l yview scroll 2 pages 45 .l nearest 0 46} {6} 47test util-1.8 {Tk_GetScrollInfo procedure} { 48 .l yview 15 49 .l yview scroll -2 pages 50 .l nearest 0 51} {9} 52test util-1.9 {Tk_GetScrollInfo procedure} { 53 .l yview 0 54 .l yview scroll 2 units 55 .l nearest 0 56} {2} 57test util-1.10 {Tk_GetScrollInfo procedure} { 58 .l yview 15 59 .l yview scroll -2 units 60 .l nearest 0 61} {13} 62test util-1.11 {Tk_GetScrollInfo procedure} { 63 list [catch {.l yview scroll 3 zips} msg] $msg 64} {1 {bad argument "zips": must be units or pages}} 65test util-1.12 {Tk_GetScrollInfo procedure} { 66 list [catch {.l yview dropdead 3 times} msg] $msg 67} {1 {unknown option "dropdead": must be moveto or scroll}} 68 69# cleanup 70::tcltest::cleanupTests 71return 72 73 74 75 76 77 78 79 80 81 82 83 84 85