os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/split.test
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 # Commands covered:  split
     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-1996 Sun Microsystems, Inc.
     9 # Copyright (c) 1998-1999 by Scriptics Corporation.
    10 #
    11 # See the file "license.terms" for information on usage and redistribution
    12 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    13 #
    14 # RCS: @(#) $Id: split.test,v 1.8 2002/11/12 02:25:24 hobbs Exp $
    15 
    16 if {[lsearch [namespace children] ::tcltest] == -1} {
    17     package require tcltest
    18     namespace import -force ::tcltest::*
    19 }
    20 
    21 test split-1.1 {basic split commands} {
    22     split "a\n b\t\r c\n "
    23 } {a {} b {} {} c {} {}}
    24 test split-1.2 {basic split commands} {
    25     split "word 1xyzword 2zword 3" xyz
    26 } {{word 1} {} {} {word 2} {word 3}}
    27 test split-1.3 {basic split commands} {
    28     split "12345" {}
    29 } {1 2 3 4 5}
    30 test split-1.4 {basic split commands} {
    31     split "a\}b\[c\{\]\$"
    32 } "a\\}b\\\[c\\{\\\]\\\$"
    33 test split-1.5 {basic split commands} {
    34     split {} {}
    35 } {}
    36 test split-1.6 {basic split commands} {
    37     split {}
    38 } {}
    39 test split-1.7 {basic split commands} {
    40     split {   }
    41 } {{} {} {} {}}
    42 test split-1.8 {basic split commands} {
    43     proc foo {} {
    44         set x {}
    45         foreach f [split {]\n} {}] {
    46             append x $f
    47         }
    48         return $x	
    49     }
    50     foo
    51 } {]\n}
    52 test split-1.9 {basic split commands} {
    53     proc foo {} {
    54         set x ab\000c
    55         set y [split $x {}]
    56         return $y
    57     }
    58     foo
    59 } "a b \000 c"
    60 test split-1.10 {basic split commands} {
    61     split "a0ab1b2bbb3\000c4" ab\000c
    62 } {{} 0 {} 1 2 {} {} 3 {} 4}
    63 test split-1.11 {basic split commands} {
    64     split "12,3,45" {,}
    65 } {12 3 45}
    66 test split-1.12 {basic split commands} {
    67     split "\u0001ab\u0001cd\u0001\u0001ef\u0001" \1
    68 } {{} ab cd {} ef {}}
    69 test split-1.13 {basic split commands} {
    70     split "12,34,56," {,}
    71 } {12 34 56 {}}
    72 test split-1.14 {basic split commands} {
    73     split ",12,,,34,56," {,}
    74 } {{} 12 {} {} 34 56 {}}
    75 
    76 test split-2.1 {split errors} {
    77     list [catch split msg] $msg $errorCode
    78 } {1 {wrong # args: should be "split string ?splitChars?"} NONE}
    79 test split-2.2 {split errors} {
    80     list [catch {split a b c} msg] $msg $errorCode
    81 } {1 {wrong # args: should be "split string ?splitChars?"} NONE}
    82 
    83 # cleanup
    84 catch {rename foo {}}
    85 ::tcltest::cleanupTests
    86 return
    87 
    88 
    89 
    90 
    91 
    92 
    93 
    94 
    95 
    96 
    97 
    98