OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [tests/] [linsert.test] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Commands covered:  linsert
2
#
3
# This file contains a collection of tests for one or more of the Tcl
4
# built-in commands.  Sourcing this file into Tcl runs the tests and
5
# generates output for errors.  No output means no errors were found.
6
#
7
# Copyright (c) 1991-1993 The Regents of the University of California.
8
# Copyright (c) 1994 Sun Microsystems, Inc.
9
#
10
# See the file "license.terms" for information on usage and redistribution
11
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
#
13
# RCS: @(#) $Id: linsert.test,v 1.1.1.1 2002-01-16 10:25:36 markom Exp $
14
 
15
if {[string compare test [info procs test]] == 1} then {source defs}
16
 
17
catch {unset lis}
18
catch {rename p ""}
19
 
20
test linsert-1.1 {linsert command} {
21
    linsert {1 2 3 4 5} 0 a
22
} {a 1 2 3 4 5}
23
test linsert-1.2 {linsert command} {
24
    linsert {1 2 3 4 5} 1 a
25
} {1 a 2 3 4 5}
26
test linsert-1.3 {linsert command} {
27
    linsert {1 2 3 4 5} 2 a
28
} {1 2 a 3 4 5}
29
test linsert-1.4 {linsert command} {
30
    linsert {1 2 3 4 5} 3 a
31
} {1 2 3 a 4 5}
32
test linsert-1.5 {linsert command} {
33
    linsert {1 2 3 4 5} 4 a
34
} {1 2 3 4 a 5}
35
test linsert-1.6 {linsert command} {
36
    linsert {1 2 3 4 5} 5 a
37
} {1 2 3 4 5 a}
38
test linsert-1.7 {linsert command} {
39
    linsert {1 2 3 4 5} 2 one two \{three \$four
40
} {1 2 one two \{three {$four} 3 4 5}
41
test linsert-1.8 {linsert command} {
42
    linsert {\{one \$two \{three \ four \ five} 2 a b c
43
} {\{one {$two} a b c \{three { four} { five}}
44
test linsert-1.9 {linsert command} {
45
    linsert {{1 2} {3 4} {5 6} {7 8}} 2 {x y} {a b}
46
} {{1 2} {3 4} {x y} {a b} {5 6} {7 8}}
47
test linsert-1.10 {linsert command} {
48
    linsert {} 2 a b c
49
} {a b c}
50
test linsert-1.11 {linsert command} {
51
    linsert {} 2 {}
52
} {{}}
53
test linsert-1.12 {linsert command} {
54
    linsert {a b "c c" d e} 3 1
55
} {a b {c c} 1 d e}
56
test linsert-1.13 {linsert command} {
57
    linsert { a b c d} 0 1 2
58
} {1 2 a b c d}
59
test linsert-1.14 {linsert command} {
60
    linsert {a b c {d e f}} 4 1 2
61
} {a b c {d e f} 1 2}
62
test linsert-1.15 {linsert command} {
63
    linsert {a b c \{\  abc} 4 q r
64
} {a b c \{\  q r abc}
65
test linsert-1.16 {linsert command} {
66
    linsert {a b c \{ abc} 4 q r
67
} {a b c \{ q r abc}
68
test linsert-1.17 {linsert command} {
69
    linsert {a b c} end q r
70
} {a b c q r}
71
test linsert-1.18 {linsert command} {
72
    linsert {a} end q r
73
} {a q r}
74
test linsert-1.19 {linsert command} {
75
    linsert {} end q r
76
} {q r}
77
 
78
test linsert-2.1 {linsert errors} {
79
    list [catch linsert msg] $msg
80
} {1 {wrong # args: should be "linsert list index element ?element ...?"}}
81
test linsert-2.2 {linsert errors} {
82
    list [catch {linsert a b} msg] $msg
83
} {1 {wrong # args: should be "linsert list index element ?element ...?"}}
84
test linsert-2.3 {linsert errors} {
85
    list [catch {linsert a 12x 2} msg] $msg
86
} {1 {bad index "12x": must be integer or "end"}}
87
test linsert-2.4 {linsert errors} {
88
    list [catch {linsert \{ 12 2} msg] $msg
89
} {1 {unmatched open brace in list}}
90
 
91
test linsert-3.1 {linsert won't modify shared argument objects} {
92
    proc p {} {
93
        linsert "a b c" 1 "x y"
94
        return "a b c"
95
    }
96
    p
97
} "a b c"
98
test linsert-3.2 {linsert won't modify shared argument objects} {
99
    catch {unset lis}
100
    set lis [format "a \"%s\" c" "b"]
101
    linsert $lis 0 [string length $lis]
102
} "7 a b c"
103
 
104
catch {unset lis}
105
catch {rename p ""}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.