home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / tests / indexObj.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  2.2 KB  |  69 lines  |  [TEXT/ALFA]

  1. # This file is a Tcl script to test out the the procedures in file
  2. # tkIndexObj.c, which implement indexed table lookups.  The tests here
  3. # are organized in the standard fashion for Tcl tests.
  4. #
  5. # Copyright (c) 1997 Sun Microsystems, Inc.
  6. #
  7. # See the file "license.terms" for information on usage and redistribution
  8. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  9. #
  10. # @(#) indexObj.test 1.3 97/06/23 18:23:09
  11.  
  12. if {[info procs test] != "test"} {
  13.     source defs
  14. }
  15.  
  16. if {[info commands testindexobj] == {}} {
  17.     puts "This application hasn't been compiled with the \"testindexobj\""
  18.     puts "command, so I can't test Tcl_GetIndexFromObj etc."
  19.     return 
  20. }
  21.  
  22. test indexObj-1.1 {exact match} {
  23.     testindexobj 1 1 xyz abc def xyz alm
  24. } {2}
  25. test indexObj-1.2 {exact match} {
  26.     testindexobj 1 1 abc abc def xyz alm
  27. } {0}
  28. test indexObj-1.3 {exact match} {
  29.     testindexobj 1 1 alm abc def xyz alm
  30. } {3}
  31. test indexObj-1.4 {unique abbreviation} {
  32.     testindexobj 1 1 xy abc def xalb xyz alm
  33. } {3}
  34. test indexObj-1.5 {multiple abbreviations and exact match} {
  35.     testindexobj 1 1 x abc def xalb xyz alm x
  36. } {5}
  37. test indexObj-1.6 {forced exact match} {
  38.     testindexobj 1 0 xy abc def xalb xy alm
  39. } {3}
  40. test indexObj-1.7 {forced exact match} {
  41.     testindexobj 1 0 x abc def xalb xyz alm x
  42. } {5}
  43.  
  44. test indexObj-2.1 {no match} {
  45.     list [catch {testindexobj 1 1 dddd abc def xalb xyz alm x} msg] $msg
  46. } {1 {bad token "dddd": must be abc, def, xalb, xyz, alm, or x}}
  47. test indexObj-2.2 {no match} {
  48.     list [catch {testindexobj 1 1 dddd abc} msg] $msg
  49. } {1 {bad token "dddd": must be abc}}
  50. test indexObj-2.3 {no match: no abbreviations} {
  51.     list [catch {testindexobj 1 0 xy abc def xalb xyz alm} msg] $msg
  52. } {1 {bad token "xy": must be abc, def, xalb, xyz, or alm}}
  53. test indexObj-2.4 {ambiguous value} {
  54.     list [catch {testindexobj 1 1 d dumb daughter a c} msg] $msg
  55. } {1 {ambiguous token "d": must be dumb, daughter, a, or c}}
  56. test indexObj-2.5 {omit error message} {
  57.     list [catch {testindexobj 0 1 d x} msg] $msg
  58. } {1 {}}
  59.  
  60. test indexObj-3.1 {cache result to skip next lookup} {
  61.     testindexobj check 42
  62. } {42}
  63.  
  64. test indexObj-4.1 {free old internal representation} {
  65.     set x {a b}
  66.     lindex $x 1
  67.     testindexobj 1 1 $x abc def {a b} zzz
  68. } {2}
  69.