Skip to content
Tcl Source Code Artifact [25369339fe]
Login

Artifact [25369339fe]

Artifact 25369339fe5eba11b7a65c5b9d1c9b75da951c013bd8f22fc40b81925d5ec07d:


# Copyright © 2021 Nathan Coulter

# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.

if {"::tcltest" ni [namespace children]} {
    package require tcltest 2.5
    namespace import -force ::tcltest::*
}

::tcltest::loadTestedCommands
testConstraint testindexhex [expr {[namespace which testindexhex] ne {}}] 

variable list
variable res

test {list lindex constant} {INST_LIST_INDEX_IMM} \
    -constraints testindexhex \
    -body {
	set list [testindexhex]
	lindex $list 731
    } -cleanup {
	catch {unset list}
    } -result 2db 


test {list lindex constant end} {INST_LIST_INDEX_IMM} \
    -constraints testindexhex \
    -body {
	set list [testindexhex]
	lindex $list end
    } -cleanup {
	catch {unset list}
	catch {unset res}
    } -returnCodes 1 -result {list length indeterminate}



test {list lindex dynamic} {INST_LIST_INDEX} \
    -constraints testindexhex \
    -body {
	set list [testindexhex]
	set val [expr {731 + 0}]
	after 100
	lindex $list $val 
    } -cleanup {
	catch {unset list}
    } -result 2db 


test {list lindex dynamic end} {INST_LIST_INDEX} \
    -constraints testindexhex \
    -body {
	set list [testindexhex]
	append index e n d
	lindex $list $index
    } -cleanup {
	catch {unset list}
	catch {unset res}
    } -returnCodes 1 -result {list length indeterminate}


test {list lindex drill} {} \
    -constraints testindexhex \
    -body {
	set list [testindexhex]
	lindex $list 731 0 0 0
    } -cleanup {
	catch {unset list}
    } -result 2db 


test {list lrange} {} \
    -constraints testindexhex \
    -body {
	set list [testindexhex]
	lrange $list 10 15
    } -cleanup {
	catch {unset list}
    } -result {a b c d e f}


# cleanup
::tcltest::cleanupTests
return