#
# arrayproc.test
#
# Tests for tcl.tlib array routines.
#---------------------------------------------------------------------------
# Copyright 1992-1999 Karl Lehenbauer and Mark Diekhans.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies.  Karl Lehenbauer and
# Mark Diekhans make no representations about the suitability of this
# software for any purpose.  It is provided "as is" without express or
# implied warranty.
#------------------------------------------------------------------------------
# $Id: arrayproc.test,v 1.1.1.1 1999/06/28 20:35:24 damon Exp $
#------------------------------------------------------------------------------
#

if [cequal [info procs Test] {}] {source testlib.tcl}
eval $SAVED_UNKNOWN


set testArray(foo) bar
set testArray(snap) frammistan
set testArray(0) zero
set testArray(william) dafoe

Test for_array_keys-1.1 {for_array_keys command} {
    for_array_keys key testArray {
        lappend result $key
    }
    lsort $result
} 0 "0 foo snap william"

Test for_array_keys-1.2 {errors in for_array_keys command} {
    list [catch {
        for_array_keys key testArray {
            error fakeResult fakeInfo fakeCode
        }
    } msg] $msg [crange $errorInfo 0 7] $errorCode
} 0 {1 fakeResult fakeInfo fakeCode}

Test for_array_keys-1.3 {break in for_array_keys command} {
    set cnt 0
    list [catch {
        for_array_keys key testArray {
            incr cnt
            break
        }
    } msg] $msg $cnt
} 0 {0 {} 1}

Test for_array_keys-1.4 {break in for_array_keys command} {
    set cnt 0
    list [catch {
        for_array_keys key testArray {
            incr cnt
            continue
            incr cnt 20
        }
    } msg] $msg $cnt
} 0 {0 {} 4}

Test for_array_keys-1.5 {return in for_array_keys command} {
    proc for_array_keys_test {testArrayVar cntVar} {
        upvar $testArrayVar testArray $cntVar cnt
        for_array_keys key testArray {
            incr cnt
            return abcd
        }
    }
    set cnt 0
    list [catch {for_array_keys_test testArray cnt} msg] $msg $cnt
} 0 {0 abcd 1}
rename for_array_keys_test {}

unset testArray
unset result
rename unknown {}



