Tcl Source Code

Artifact [a64834db96]
Login

Artifact a64834db96d7e4224ab801fc02e80d67cf1b1f7f:

Attachment "cmdIL.test-patch" to ticket [1366484fff] added by afredd 2006-10-24 23:20:23.
--- cmdIL.test-orig	2006-10-24 14:16:17.559960200 +0100
+++ cmdIL.test	2006-10-24 15:12:42.919500000 +0100
@@ -170,7 +170,7 @@
     list [catch {lsort -integer -index 2 {{20 10} {15 30 40}}} msg] $msg
 } {1 {element 2 missing from sublist "20 10"}}
 test cmdIL-3.4 {SortCompare procedure, -index option} {
-    list [catch {lsort -integer -index 2 "{a b c} \\\{"} msg] $msg
+    list [catch {lsort -integer -index 2 "{1 2 3} \\\{"} msg] $msg
 } {1 {unmatched open brace in list}}
 test cmdIL-3.5 {SortCompare procedure, -index option} {
     list [catch {lsort -integer -index 2 {{20 10 13} {15}}} msg] $msg
@@ -245,6 +245,43 @@
 test cmdIL-3.19 {SortCompare procedure, -decreasing option} {
     lsort -decreasing -integer {35 21 0x20 30 023 100 8}
 } {100 35 0x20 30 21 023 8}
+test cmdIL-3.20 {SortCompare procedure, -index option} {
+    list [catch {lsort -integer -index 2 "{1 2 3} {a b c}"} msg] $msg
+} {1 {expected integer but got "c"}}
+test cmdIL-3.21 {SortCompare procedure, single element list special case} {
+    list [catch {lsort -integer not_an_integer} msg] $msg
+} {0 not_an_integer}
+test cmdIL-3.22 {SortCompare procedure, single element list special case} {
+    list [catch {lsort -real not_a_real} msg] $msg
+} {0 not_a_real}
+test cmdIL-3.23 {SortCompare procedure, -command procedure can call lsort} -body {
+    proc cmp1 {a b} {
+    	if {$a eq $b} { return 0 }
+	if {[lsort -command cmp2 [list $a $b]] eq "$a $b"} { return -1 }
+	return 1
+    }
+    proc cmp2 {a b} {
+    	string compare $a $b
+    }
+    lsort -command cmp1 {a b c a b c a b c}
+} -cleanup {
+    rename cmp1 ""
+    rename cmp2 ""
+} -result {a a a b b b c c c}
+test cmdIL-3.24 {SortCompare procedure, -nocase implementation} {
+    if {[lsort -nocase {@ `}] ne "@ `"} { return 1 }
+    if {[lsort -nocase {` @}] ne "@ `"} { return 2 }
+    return 0
+} {0}
+# XXX This is known to fail. See patch SW#1236896.
+test cmdIL-3.25 {SortCompare procedure, compare non-ASCII strings using -nocase} {
+    set u "\uC0" ;# upper case a with grave
+    set l "\uE0" ;# lower case a with grave
+    if {[lsort -nocase [list $u $l]] ne [list $u $l]} { return 1 }
+    if {[lsort -nocase [list $l $u]] ne [list $l $u]} { return 2 }
+    return 0
+} {0}
+
 
 test cmdIL-4.1 {DictionaryCompare procedure, numerics, leading zeros} {
     lsort -dictionary {a003b a03b}