os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/linsert.test
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/linsert.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,115 @@
1.4 +# Commands covered: linsert
1.5 +#
1.6 +# This file contains a collection of tests for one or more of the Tcl
1.7 +# built-in commands. Sourcing this file into Tcl runs the tests and
1.8 +# generates output for errors. No output means no errors were found.
1.9 +#
1.10 +# Copyright (c) 1991-1993 The Regents of the University of California.
1.11 +# Copyright (c) 1994 Sun Microsystems, Inc.
1.12 +# Copyright (c) 1998-1999 by Scriptics Corporation.
1.13 +#
1.14 +# See the file "license.terms" for information on usage and redistribution
1.15 +# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1.16 +#
1.17 +# RCS: @(#) $Id: linsert.test,v 1.8 2000/04/10 17:19:01 ericm Exp $
1.18 +
1.19 +if {[lsearch [namespace children] ::tcltest] == -1} {
1.20 + package require tcltest
1.21 + namespace import -force ::tcltest::*
1.22 +}
1.23 +
1.24 +catch {unset lis}
1.25 +catch {rename p ""}
1.26 +
1.27 +test linsert-1.1 {linsert command} {
1.28 + linsert {1 2 3 4 5} 0 a
1.29 +} {a 1 2 3 4 5}
1.30 +test linsert-1.2 {linsert command} {
1.31 + linsert {1 2 3 4 5} 1 a
1.32 +} {1 a 2 3 4 5}
1.33 +test linsert-1.3 {linsert command} {
1.34 + linsert {1 2 3 4 5} 2 a
1.35 +} {1 2 a 3 4 5}
1.36 +test linsert-1.4 {linsert command} {
1.37 + linsert {1 2 3 4 5} 3 a
1.38 +} {1 2 3 a 4 5}
1.39 +test linsert-1.5 {linsert command} {
1.40 + linsert {1 2 3 4 5} 4 a
1.41 +} {1 2 3 4 a 5}
1.42 +test linsert-1.6 {linsert command} {
1.43 + linsert {1 2 3 4 5} 5 a
1.44 +} {1 2 3 4 5 a}
1.45 +test linsert-1.7 {linsert command} {
1.46 + linsert {1 2 3 4 5} 2 one two \{three \$four
1.47 +} {1 2 one two \{three {$four} 3 4 5}
1.48 +test linsert-1.8 {linsert command} {
1.49 + linsert {\{one \$two \{three \ four \ five} 2 a b c
1.50 +} {\{one {$two} a b c \{three { four} { five}}
1.51 +test linsert-1.9 {linsert command} {
1.52 + linsert {{1 2} {3 4} {5 6} {7 8}} 2 {x y} {a b}
1.53 +} {{1 2} {3 4} {x y} {a b} {5 6} {7 8}}
1.54 +test linsert-1.10 {linsert command} {
1.55 + linsert {} 2 a b c
1.56 +} {a b c}
1.57 +test linsert-1.11 {linsert command} {
1.58 + linsert {} 2 {}
1.59 +} {{}}
1.60 +test linsert-1.12 {linsert command} {
1.61 + linsert {a b "c c" d e} 3 1
1.62 +} {a b {c c} 1 d e}
1.63 +test linsert-1.13 {linsert command} {
1.64 + linsert { a b c d} 0 1 2
1.65 +} {1 2 a b c d}
1.66 +test linsert-1.14 {linsert command} {
1.67 + linsert {a b c {d e f}} 4 1 2
1.68 +} {a b c {d e f} 1 2}
1.69 +test linsert-1.15 {linsert command} {
1.70 + linsert {a b c \{\ abc} 4 q r
1.71 +} {a b c \{\ q r abc}
1.72 +test linsert-1.16 {linsert command} {
1.73 + linsert {a b c \{ abc} 4 q r
1.74 +} {a b c \{ q r abc}
1.75 +test linsert-1.17 {linsert command} {
1.76 + linsert {a b c} end q r
1.77 +} {a b c q r}
1.78 +test linsert-1.18 {linsert command} {
1.79 + linsert {a} end q r
1.80 +} {a q r}
1.81 +test linsert-1.19 {linsert command} {
1.82 + linsert {} end q r
1.83 +} {q r}
1.84 +test linsert-1.20 {linsert command, use of end-int index} {
1.85 + linsert {a b c d} end-2 e f
1.86 +} {a b e f c d}
1.87 +
1.88 +test linsert-2.1 {linsert errors} {
1.89 + list [catch linsert msg] $msg
1.90 +} {1 {wrong # args: should be "linsert list index element ?element ...?"}}
1.91 +test linsert-2.2 {linsert errors} {
1.92 + list [catch {linsert a b} msg] $msg
1.93 +} {1 {wrong # args: should be "linsert list index element ?element ...?"}}
1.94 +test linsert-2.3 {linsert errors} {
1.95 + list [catch {linsert a 12x 2} msg] $msg
1.96 +} {1 {bad index "12x": must be integer or end?-integer?}}
1.97 +test linsert-2.4 {linsert errors} {
1.98 + list [catch {linsert \{ 12 2} msg] $msg
1.99 +} {1 {unmatched open brace in list}}
1.100 +
1.101 +test linsert-3.1 {linsert won't modify shared argument objects} {
1.102 + proc p {} {
1.103 + linsert "a b c" 1 "x y"
1.104 + return "a b c"
1.105 + }
1.106 + p
1.107 +} "a b c"
1.108 +test linsert-3.2 {linsert won't modify shared argument objects} {
1.109 + catch {unset lis}
1.110 + set lis [format "a \"%s\" c" "b"]
1.111 + linsert $lis 0 [string length $lis]
1.112 +} "7 a b c"
1.113 +
1.114 +# cleanup
1.115 +catch {unset lis}
1.116 +catch {rename p ""}
1.117 +::tcltest::cleanupTests
1.118 +return