sl@0: # Commands covered: incr sl@0: # sl@0: # This file contains the original set of tests for Tcl's incr command. sl@0: # Since the incr command is now compiled, a new set of tests covering sl@0: # the new implementation is in the file "incr.test". Sourcing this file sl@0: # into Tcl runs the tests and generates output for errors. sl@0: # No output means no errors were found. sl@0: # sl@0: # Copyright (c) 1991-1993 The Regents of the University of California. sl@0: # Copyright (c) 1994-1996 Sun Microsystems, Inc. sl@0: # Copyright (c) 1998-1999 by Scriptics Corporation. sl@0: # sl@0: # See the file "license.terms" for information on usage and redistribution sl@0: # of this file, and for a DISCLAIMER OF ALL WARRANTIES. sl@0: # sl@0: # RCS: @(#) $Id: incr-old.test,v 1.6.2.1 2003/03/27 13:11:13 dkf Exp $ sl@0: sl@0: if {[lsearch [namespace children] ::tcltest] == -1} { sl@0: package require tcltest sl@0: namespace import -force ::tcltest::* sl@0: } sl@0: sl@0: catch {unset x} sl@0: sl@0: test incr-old-1.1 {basic incr operation} { sl@0: set x 23 sl@0: list [incr x] $x sl@0: } {24 24} sl@0: test incr-old-1.2 {basic incr operation} { sl@0: set x 106 sl@0: list [incr x -5] $x sl@0: } {101 101} sl@0: test incr-old-1.3 {basic incr operation} { sl@0: set x " -106" sl@0: list [incr x 1] $x sl@0: } {-105 -105} sl@0: test incr-old-1.4 {basic incr operation} { sl@0: set x " +106" sl@0: list [incr x 1] $x sl@0: } {107 107} sl@0: sl@0: test incr-old-2.1 {incr errors} { sl@0: list [catch incr msg] $msg sl@0: } {1 {wrong # args: should be "incr varName ?increment?"}} sl@0: test incr-old-2.2 {incr errors} { sl@0: list [catch {incr a b c} msg] $msg sl@0: } {1 {wrong # args: should be "incr varName ?increment?"}} sl@0: test incr-old-2.3 {incr errors} { sl@0: catch {unset x} sl@0: list [catch {incr x} msg] $msg $errorInfo sl@0: } {1 {can't read "x": no such variable} {can't read "x": no such variable sl@0: (reading value of variable to increment) sl@0: invoked from within sl@0: "incr x"}} sl@0: test incr-old-2.4 {incr errors} { sl@0: set x abc sl@0: list [catch {incr x} msg] $msg $errorInfo sl@0: } {1 {expected integer but got "abc"} {expected integer but got "abc" sl@0: while executing sl@0: "incr x"}} sl@0: test incr-old-2.5 {incr errors} { sl@0: set x 123 sl@0: list [catch {incr x 1a} msg] $msg $errorInfo sl@0: } {1 {expected integer but got "1a"} {expected integer but got "1a" sl@0: (reading increment) sl@0: invoked from within sl@0: "incr x 1a"}} sl@0: test incr-old-2.6 {incr errors} { sl@0: proc readonly args {error "variable is read-only"} sl@0: set x 123 sl@0: trace var x w readonly sl@0: list [catch {incr x 1} msg] $msg $errorInfo sl@0: } {1 {can't set "x": variable is read-only} {can't set "x": variable is read-only sl@0: while executing sl@0: "incr x 1"}} sl@0: catch {unset x} sl@0: test incr-old-2.7 {incr errors} { sl@0: set x - sl@0: list [catch {incr x 1} msg] $msg sl@0: } {1 {expected integer but got "-"}} sl@0: test incr-old-2.8 {incr errors} { sl@0: set x { - } sl@0: list [catch {incr x 1} msg] $msg sl@0: } {1 {expected integer but got " - "}} sl@0: test incr-old-2.9 {incr errors} { sl@0: set x + sl@0: list [catch {incr x 1} msg] $msg sl@0: } {1 {expected integer but got "+"}} sl@0: test incr-old-2.10 {incr errors} { sl@0: set x {20 x} sl@0: list [catch {incr x 1} msg] $msg sl@0: } {1 {expected integer but got "20 x"}} sl@0: sl@0: # cleanup sl@0: ::tcltest::cleanupTests sl@0: return