home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / devel / tcl / tclx7_31.z / tclx7_31 / tcldev / tclX7.3a-p1 / tests / lmatch.test < prev    next >
Encoding:
Text File  |  1994-01-23  |  3.2 KB  |  105 lines

  1. #
  2. # lmatch.test
  3. #
  4. # Tests for the lmatch command.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1993 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #
  15. # Based on test code that is
  16. # Copyright (c) 1991-1993 The Regents of the University of California.
  17. # All rights reserved.
  18. #
  19. # Permission is hereby granted, without written agreement and without
  20. # license or royalty fees, to use, copy, modify, and distribute this
  21. # software and its documentation for any purpose, provided that the
  22. # above copyright notice and the following two paragraphs appear in
  23. # all copies of this software.
  24. #
  25. # IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  26. # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  27. # OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  28. # CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. #
  30. # THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  31. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  32. # AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  33. # ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  34. # PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  35. #
  36.  
  37. if {[info procs test] != "test"} then {source testlib.tcl}
  38.  
  39. set x {abcd bbcd 123 234 345 445}
  40.  
  41. Test lmatch-1.1 {lmatch command} {
  42.     lmatch $x 123
  43. } 0 "123"
  44.  
  45. Test lmatch-1.2 {lmatch command} {
  46.     lmatch $x 3456
  47. } 0 ""
  48.  
  49. Test lmatch-1.3 {lmatch command} {
  50.     lmatch $x *5
  51. } 0 "345 445"
  52.  
  53. Test lmatch-1.4 {lmatch command} {
  54.     lmatch $x *bc*
  55. } 0 "abcd bbcd"
  56.  
  57. Test lmatch-2.1 {search modes} {
  58.     lmatch -exact {xyz bbcc *bc*} *bc*
  59. } 0 "*bc*"
  60.  
  61. Test lmatch-2.2 {search modes} {
  62.     lmatch -exact {b.x ^bc xy bcx ^bc} ^bc
  63. } 0 "^bc ^bc"
  64.  
  65. Test lmatch-2.3 {search modes} {
  66.     lmatch -regexp {xyz bbcc *bc*} *bc*
  67. } 1 {couldn't compile regular expression pattern: ?+* follows nothing}
  68.  
  69. Test lmatch-2.4 {search modes} {
  70.     lmatch -regexp {b.x ^bc xy bcx bca} ^bc
  71. } 0 "bcx bca"
  72.  
  73. Test lmatch-2.5 {search modes} {
  74.     lmatch -glob {xyz bbcc *bc* abcd} *bc*
  75. } 0 "bbcc *bc* abcd"
  76.  
  77. Test lmatch-2.6 {search modes} {
  78.     lmatch -glob {b.x ^bc xy bcx} ^bc
  79. } 0 "^bc"
  80.  
  81. Test lmatch-2.7 {search modes} {
  82.     lmatch -glib {b.x bx xy bcx} b.x
  83. } 1 {bad search mode "-glib": must be -exact, -glob, or -regexp}
  84.  
  85. Test lmatch-3.1 {lmatch errors} {
  86.     lmatch
  87. } 1 {wrong # args: should be "lmatch ?mode? list pattern"}
  88.  
  89. Test lmatch-3.2 {lmatch errors} {
  90.     lmatch a
  91. } 1 {wrong # args: should be "lmatch ?mode? list pattern"}
  92.  
  93. Test lmatch-3.3 {lmatch errors} {
  94.     lmatch a b c
  95. } 1 {bad search mode "a": must be -exact, -glob, or -regexp}
  96.  
  97. Test lmatch-3.4 {lmatch errors} {
  98.     lmatch a b c d
  99. } 1 {wrong # args: should be "lmatch ?mode? list pattern"}
  100.  
  101. Test lmatch-3.5 {lmatch errors} {
  102.     lmatch "\{" b
  103. } 1 {unmatched open brace in list}
  104.  
  105.