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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Commands covered:  lsearch
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: lsearch.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
set x {abcd bbcd 123 234 345}
18
test lsearch-1.1 {lsearch command} {
19
    lsearch $x 123
20
} 2
21
test lsearch-1.2 {lsearch command} {
22
    lsearch $x 3456
23
} -1
24
test lsearch-1.3 {lsearch command} {
25
    lsearch $x *5
26
} 4
27
test lsearch-1.4 {lsearch command} {
28
    lsearch $x *bc*
29
} 0
30
 
31
test lsearch-2.1 {search modes} {
32
    lsearch -exact {xyz bbcc *bc*} *bc*
33
} 2
34
test lsearch-2.2 {search modes} {
35
    lsearch -exact {b.x ^bc xy bcx} ^bc
36
} 1
37
test lsearch-2.3 {search modes} {
38
    lsearch -exact {foo bar cat} ba
39
} -1
40
test lsearch-2.4 {search modes} {
41
    lsearch -exact {foo bar cat} bart
42
} -1
43
test lsearch-2.5 {search modes} {
44
    lsearch -exact {foo bar cat} bar
45
} 1
46
test lsearch-2.6 {search modes} {
47
    list [catch {lsearch -regexp {xyz bbcc *bc*} *bc*} msg] $msg
48
} {1 {couldn't compile regular expression pattern: ?+* follows nothing}}
49
test lsearch-2.7 {search modes} {
50
    lsearch -regexp {b.x ^bc xy bcx} ^bc
51
} 3
52
test lsearch-2.8 {search modes} {
53
    lsearch -glob {xyz bbcc *bc*} *bc*
54
} 1
55
test lsearch-2.9 {search modes} {
56
    lsearch -glob {b.x ^bc xy bcx} ^bc
57
} 1
58
test lsearch-2.10 {search modes} {
59
    list [catch {lsearch -glib {b.x bx xy bcx} b.x} msg] $msg
60
} {1 {bad search mode "-glib": must be -exact, -glob, -regexp, -dictionary, or -nocase}}
61
 
62
test lsearch-3.1 {lsearch errors} {
63
    list [catch lsearch msg] $msg
64
} {1 {wrong # args: should be "lsearch ?mode? list pattern"}}
65
test lsearch-3.2 {lsearch errors} {
66
    list [catch {lsearch a} msg] $msg
67
} {1 {wrong # args: should be "lsearch ?mode? list pattern"}}
68
test lsearch-3.3 {lsearch errors} {
69
    list [catch {lsearch a b c} msg] $msg
70
} {1 {bad search mode "a": must be -exact, -glob, -regexp, -dictionary, or -nocase}}
71
test lsearch-3.4 {lsearch errors} {
72
    list [catch {lsearch a b c d} msg] $msg
73
} {1 {wrong # args: should be "lsearch ?mode? list pattern"}}
74
test lsearch-3.5 {lsearch errors} {
75
    list [catch {lsearch "\{" b} msg] $msg
76
} {1 {unmatched open brace in list}}
77
 
78
test lsearch-4.1 {binary data} {
79
    lsearch -exact [list foo one\000two bar] bar
80
} 2
81
test lsearch-4.2 {binary data} {
82
    set x one
83
    append x \x00
84
    append x two
85
    lsearch -exact [list foo one\000two bar] $x
86
} 1

powered by: WebSVN 2.1.0

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