diff options
author | hobbs <hobbs@noemail.net> | 1999-12-21 23:58:22 (GMT) |
---|---|---|
committer | hobbs <hobbs@noemail.net> | 1999-12-21 23:58:22 (GMT) |
commit | bd4a1ec2cc32c8b4b43af4e479eb92b9096d850f (patch) | |
tree | 5cea2af338ce8c6767de6246e1b8fc27842d9cab /tests | |
parent | e83b3d7b1b65fc19ce1da261ec638dbc844425e2 (diff) | |
download | tcl-bd4a1ec2cc32c8b4b43af4e479eb92b9096d850f.zip tcl-bd4a1ec2cc32c8b4b43af4e479eb92b9096d850f.tar.gz tcl-bd4a1ec2cc32c8b4b43af4e479eb92b9096d850f.tar.bz2 |
* tests/cmdIL.test:
* generic/tclCmdIL.c: added -unique option to lsort
FossilOrigin-Name: cffdbd72e307c9b9faffacda02626985805a43e0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cmdIL.test | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/tests/cmdIL.test b/tests/cmdIL.test index f4fc9a3..7e53974 100644 --- a/tests/cmdIL.test +++ b/tests/cmdIL.test @@ -8,7 +8,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: cmdIL.test,v 1.9 1999/06/26 03:54:11 jenn Exp $ +# RCS: @(#) $Id: cmdIL.test,v 1.10 1999/12/21 23:58:22 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -20,7 +20,7 @@ test cmdIL-1.1 {Tcl_LsortObjCmd procedure} { } {1 {wrong # args: should be "lsort ?options? list"}} test cmdIL-1.2 {Tcl_LsortObjCmd procedure} { list [catch {lsort -foo {1 3 2 5}} msg] $msg -} {1 {bad option "-foo": must be -ascii, -command, -decreasing, -dictionary, -increasing, -index, -integer, or -real}} +} {1 {bad option "-foo": must be -ascii, -command, -decreasing, -dictionary, -increasing, -index, -integer, -real, or -unique}} test cmdIL-1.3 {Tcl_LsortObjCmd procedure, default options} { lsort {d e c b a \{ d35 d300} } {a b c d d300 d35 e \{} @@ -75,6 +75,13 @@ test cmdIL-1.18 {Tcl_LsortObjCmd procedure, bogus list} { test cmdIL-1.19 {Tcl_LsortObjCmd procedure, empty list} { lsort {} } {} +test cmdIL-1.22 {Tcl_LsortObjCmd procedure, unique sort} { + lsort -integer -unique {3 1 2 3 1 4 3} +} {1 2 3 4} +test cmdIL-1.23 {Tcl_LsortObjCmd procedure, unique sort with index} { + # lsort -unique should return the last unique item + lsort -unique -index 0 {{a b} {c b} {a c} {d a}} +} {{a c} {c b} {d a}} # Can't think of any good tests for the MergeSort and MergeLists # procedures, except a bunch of random lists to sort. @@ -84,12 +91,12 @@ test cmdIL-2.1 {MergeSort and MergeLists procedures} { set r 1435753299 proc rand {} { global r - set r [expr (16807 * $r) % (0x7fffffff)] + set r [expr {(16807 * $r) % (0x7fffffff)}] } for {set i 0} {$i < 150} {incr i} { set x {} for {set j 0} {$j < $i} {incr j} { - lappend x [expr [rand] & 0xfff] + lappend x [expr {[rand] & 0xfff}] } set y [lsort -integer $x] set old -1 @@ -181,7 +188,7 @@ test cmdIL-3.17 {SortCompare procedure, -command option, non-integer result} { } {1 {-compare command returned non-numeric result}} test cmdIL-3.18 {SortCompare procedure, -command option} { proc cmp {a b} { - expr $b - $a + expr {$b - $a} } lsort -command cmp {48 6 18 22 21 35 36} } {48 36 35 22 21 18 6} |