os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/lreplace.test
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
# Commands covered:  lreplace
sl@0
     2
#
sl@0
     3
# This file contains a collection of tests for one or more of the Tcl
sl@0
     4
# built-in commands.  Sourcing this file into Tcl runs the tests and
sl@0
     5
# generates output for errors.  No output means no errors were found.
sl@0
     6
#
sl@0
     7
# Copyright (c) 1991-1993 The Regents of the University of California.
sl@0
     8
# Copyright (c) 1994 Sun Microsystems, Inc.
sl@0
     9
# Copyright (c) 1998-1999 by Scriptics Corporation.
sl@0
    10
#
sl@0
    11
# See the file "license.terms" for information on usage and redistribution
sl@0
    12
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
sl@0
    13
#
sl@0
    14
# RCS: @(#) $Id: lreplace.test,v 1.7 2000/04/10 17:19:01 ericm Exp $
sl@0
    15
sl@0
    16
if {[lsearch [namespace children] ::tcltest] == -1} {
sl@0
    17
    package require tcltest
sl@0
    18
    namespace import -force ::tcltest::*
sl@0
    19
}
sl@0
    20
sl@0
    21
test lreplace-1.1 {lreplace command} {
sl@0
    22
    lreplace {1 2 3 4 5} 0 0 a
sl@0
    23
} {a 2 3 4 5}
sl@0
    24
test lreplace-1.2 {lreplace command} {
sl@0
    25
    lreplace {1 2 3 4 5} 1 1 a
sl@0
    26
} {1 a 3 4 5}
sl@0
    27
test lreplace-1.3 {lreplace command} {
sl@0
    28
    lreplace {1 2 3 4 5} 2 2 a
sl@0
    29
} {1 2 a 4 5}
sl@0
    30
test lreplace-1.4 {lreplace command} {
sl@0
    31
    lreplace {1 2 3 4 5} 3 3 a
sl@0
    32
} {1 2 3 a 5}
sl@0
    33
test lreplace-1.5 {lreplace command} {
sl@0
    34
    lreplace {1 2 3 4 5} 4 4 a
sl@0
    35
} {1 2 3 4 a}
sl@0
    36
test lreplace-1.6 {lreplace command} {
sl@0
    37
    lreplace {1 2 3 4 5} 4 5 a
sl@0
    38
} {1 2 3 4 a}
sl@0
    39
test lreplace-1.7 {lreplace command} {
sl@0
    40
    lreplace {1 2 3 4 5} -1 -1 a
sl@0
    41
} {a 1 2 3 4 5}
sl@0
    42
test lreplace-1.8 {lreplace command} {
sl@0
    43
    lreplace {1 2 3 4 5} 2 end a b c d
sl@0
    44
} {1 2 a b c d}
sl@0
    45
test lreplace-1.9 {lreplace command} {
sl@0
    46
    lreplace {1 2 3 4 5} 0 3
sl@0
    47
} {5}
sl@0
    48
test lreplace-1.10 {lreplace command} {
sl@0
    49
    lreplace {1 2 3 4 5} 0 4
sl@0
    50
} {}
sl@0
    51
test lreplace-1.11 {lreplace command} {
sl@0
    52
    lreplace {1 2 3 4 5} 0 1
sl@0
    53
} {3 4 5}
sl@0
    54
test lreplace-1.12 {lreplace command} {
sl@0
    55
    lreplace {1 2 3 4 5} 2 3
sl@0
    56
} {1 2 5}
sl@0
    57
test lreplace-1.13 {lreplace command} {
sl@0
    58
    lreplace {1 2 3 4 5} 3 end
sl@0
    59
} {1 2 3}
sl@0
    60
test lreplace-1.14 {lreplace command} {
sl@0
    61
    lreplace {1 2 3 4 5} -1 4 a b c
sl@0
    62
} {a b c}
sl@0
    63
test lreplace-1.15 {lreplace command} {
sl@0
    64
    lreplace {a b "c c" d e f} 3 3
sl@0
    65
} {a b {c c} e f}
sl@0
    66
test lreplace-1.16 {lreplace command} {
sl@0
    67
    lreplace { 1 2 3 4 5} 0 0 a
sl@0
    68
} {a 2 3 4 5}
sl@0
    69
test lreplace-1.17 {lreplace command} {
sl@0
    70
    lreplace {1 2 3 4 "5 6"} 4 4 a
sl@0
    71
} {1 2 3 4 a}
sl@0
    72
test lreplace-1.18 {lreplace command} {
sl@0
    73
    lreplace {1 2 3 4 {5 6}} 4 4 a
sl@0
    74
} {1 2 3 4 a}
sl@0
    75
test lreplace-1.19 {lreplace command} {
sl@0
    76
    lreplace {1 2 3 4} 2 end x y z
sl@0
    77
} {1 2 x y z}
sl@0
    78
test lreplace-1.20 {lreplace command} {
sl@0
    79
    lreplace {1 2 3 4} end end a
sl@0
    80
} {1 2 3 a}
sl@0
    81
test lreplace-1.21 {lreplace command} {
sl@0
    82
    lreplace {1 2 3 4} end 3 a
sl@0
    83
} {1 2 3 a}
sl@0
    84
test lreplace-1.22 {lreplace command} {
sl@0
    85
    lreplace {1 2 3 4} end end
sl@0
    86
} {1 2 3}
sl@0
    87
test lreplace-1.23 {lreplace command} {
sl@0
    88
    lreplace {1 2 3 4} 2 -1 xy
sl@0
    89
} {1 2 xy 3 4}
sl@0
    90
test lreplace-1.24 {lreplace command} {
sl@0
    91
    lreplace {1 2 3 4} end -1 z
sl@0
    92
} {1 2 3 z 4}
sl@0
    93
test lreplace-1.25 {lreplace command} {
sl@0
    94
    concat \"[lreplace {\}\     hello} end end]\"
sl@0
    95
} {"\}\ "}
sl@0
    96
test lreplace-1.26 {lreplace command} {
sl@0
    97
    catch {unset foo}
sl@0
    98
    set foo {a b}
sl@0
    99
    list [set foo [lreplace $foo end end]] \
sl@0
   100
        [set foo [lreplace $foo end end]] \
sl@0
   101
        [set foo [lreplace $foo end end]]
sl@0
   102
} {a {} {}}
sl@0
   103
sl@0
   104
sl@0
   105
test lreplace-2.1 {lreplace errors} {
sl@0
   106
    list [catch lreplace msg] $msg
sl@0
   107
} {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
sl@0
   108
test lreplace-2.2 {lreplace errors} {
sl@0
   109
    list [catch {lreplace a b} msg] $msg
sl@0
   110
} {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
sl@0
   111
test lreplace-2.3 {lreplace errors} {
sl@0
   112
    list [catch {lreplace x a 10} msg] $msg
sl@0
   113
} {1 {bad index "a": must be integer or end?-integer?}}
sl@0
   114
test lreplace-2.4 {lreplace errors} {
sl@0
   115
    list [catch {lreplace x 10 x} msg] $msg
sl@0
   116
} {1 {bad index "x": must be integer or end?-integer?}}
sl@0
   117
test lreplace-2.5 {lreplace errors} {
sl@0
   118
    list [catch {lreplace x 10 1x} msg] $msg
sl@0
   119
} {1 {bad index "1x": must be integer or end?-integer?}}
sl@0
   120
test lreplace-2.6 {lreplace errors} {
sl@0
   121
    list [catch {lreplace x 3 2} msg] $msg
sl@0
   122
} {1 {list doesn't contain element 3}}
sl@0
   123
test lreplace-2.7 {lreplace errors} {
sl@0
   124
    list [catch {lreplace x 1 1} msg] $msg
sl@0
   125
} {1 {list doesn't contain element 1}}
sl@0
   126
sl@0
   127
test lreplace-3.1 {lreplace won't modify shared argument objects} {
sl@0
   128
    proc p {} {
sl@0
   129
        lreplace "a b c" 1 1 "x y"
sl@0
   130
        return "a b c"
sl@0
   131
    }
sl@0
   132
    p
sl@0
   133
} "a b c"
sl@0
   134
sl@0
   135
# cleanup
sl@0
   136
catch {unset foo}
sl@0
   137
::tcltest::cleanupTests
sl@0
   138
return