Diff
Not logged in

Differences From Artifact [797a59bc53]:

To Artifact [56581adf03]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14

15
16
17
18
19
20
21
1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21













-
+







# Commands covered:  list
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.

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

# First, a bunch of individual tests

test list-1.1 {basic tests} {list a b c} {a b c}
87
88
89
90
91
92
93
94

95
96
97
98
99
100
101



102
103

104
105

106
107
108
109
110
111

112
113
114
115
116
117
118


119
120

121
122
123
124
125
126
127
87
88
89
90
91
92
93

94
95
96
97
98



99
100
101
102

103
104

105
106
107
108
109
110

111
112
113
114
115
116


117
118
119

120
121
122
123
124
125
126
127







-
+




-
-
-
+
+
+

-
+

-
+





-
+





-
-
+
+

-
+







lcheck list-2.9  {a b} { ab} {ab }
lcheck list-2.10 a{ a{b \{ab
lcheck list-2.11 a} a}b }ab
lcheck list-2.12 a\\} {a \}b} {a \{c}
lcheck list-2.13 xyz \\ 1\\\n2
lcheck list-2.14 "{ab}\\" "{ab}xy" abc

concat {}
concat ""

# Check that tclListObj.c's SetListFromAny handles possible overlarge
# string rep lengths in the source object.

proc slowsort list {
    set result {}
    set last [expr [llength $list] - 1]
proc slowsort {list} {
    set result ""
    set last [expr {[llength $list] - 1}]
    while {$last > 0} {
	set minIndex [expr [llength $list] - 1]
        set minIndex [expr {[llength $list] - 1}]
	set min [lindex $list $last]
	set i [expr $minIndex-1]
        set i [expr {$minIndex - 1}]
	while {$i >= 0} {
	    if {[string compare [lindex $list $i] $min] < 0} {
		set minIndex $i
		set min [lindex $list $i]
	    }
	    set i [expr $i-1]
	    set i [expr {$i - 1}]
	}
	set result [concat $result [list $min]]
	if {$minIndex == 0} {
	    set list [lrange $list 1 end]
	} else {
	    set list [concat [lrange $list 0 [expr $minIndex-1]] \
			  [lrange $list [expr $minIndex+1] end]]
	    set list [concat [lrange $list 0 [expr {$minIndex - 1}]] \
		        [lrange $list [expr {$minIndex + 1}] end]]
	}
	set last [expr $last-1]
        set last [expr {$last - 1}]
    }
    return [concat $result $list]
}
test list-3.1 {SetListFromAny and lrange/concat results} {
    slowsort {fred julie alex carol bill annie}
} {alex annie bill carol fred julie}