summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/cmdIL.test17
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}