cmdr
Hex Artifact Content
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

Artifact e3c42c15d37c4c7a4a87224e1c0c756e03624269:


0000: 23 20 2d 2a 2d 20 74 63 6c 20 2d 2a 2d 20 74 63  # -*- tcl -*- tc
0010: 6c 2e 74 6b 2f 2f 44 53 4c 20 74 63 6c 74 65 73  l.tk//DSL tcltes
0020: 74 2f 2f 45 4e 2f 2f 32 2e 30 0a 23 20 23 20 23  t//EN//2.0.# # #
0030: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
0040: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
0050: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
0060: 23 23 23 23 23 23 23 23 0a 23 23 20 54 65 73 74  ########.## Test
0070: 69 6e 67 20 74 68 65 20 63 6d 64 72 3a 3a 76 61  ing the cmdr::va
0080: 6c 69 64 61 74 65 20 70 61 63 6b 61 67 65 20 28  lidate package (
0090: 73 75 62 3a 20 69 6e 74 65 67 65 72 29 2e 0a 0a  sub: integer)...
00a0: 6b 74 20 63 68 65 63 6b 20 54 63 6c 20 20 20 20  kt check Tcl    
00b0: 20 38 2e 35 0a 6b 74 20 63 68 65 63 6b 20 74 63   8.5.kt check tc
00c0: 6c 74 65 73 74 20 32 0a 0a 6b 74 20 72 65 71 75  ltest 2..kt requ
00d0: 69 72 65 20 73 75 70 70 6f 72 74 20 64 65 62 75  ire support debu
00e0: 67 0a 6b 74 20 72 65 71 75 69 72 65 20 73 75 70  g.kt require sup
00f0: 70 6f 72 74 20 64 65 62 75 67 3a 3a 63 61 6c 6c  port debug::call
0100: 65 72 0a 0a 6b 74 20 6c 6f 63 61 6c 20 20 20 73  er..kt local   s
0110: 75 70 70 6f 72 74 20 63 6d 64 72 3a 3a 76 61 6c  upport cmdr::val
0120: 69 64 61 74 65 3a 3a 63 6f 6d 6d 6f 6e 0a 6b 74  idate::common.kt
0130: 20 6c 6f 63 61 6c 20 20 20 74 65 73 74 69 6e 67   local   testing
0140: 20 63 6d 64 72 3a 3a 76 61 6c 69 64 61 74 65 0a   cmdr::validate.
0150: 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23  .# # ## ### ####
0160: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23  # ######## #####
0170: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
0180: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23  ##############.#
0190: 23 20 42 61 73 69 63 20 41 50 49 2e 0a 0a 73 65  # Basic API...se
01a0: 74 20 76 74 79 70 65 20 63 6d 64 72 3a 3a 76 61  t vtype cmdr::va
01b0: 6c 69 64 61 74 65 3a 3a 69 6e 74 65 67 65 72 0a  lidate::integer.
01c0: 73 65 74 20 76 74 64 65 66 20 30 0a 6b 74 20 73  set vtdef 0.kt s
01d0: 6f 75 72 63 65 20 76 74 79 70 65 2e 74 63 6c 0a  ource vtype.tcl.
01e0: 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23  .# # ## ### ####
01f0: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23  # ######## #####
0200: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
0210: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23  ##############.#
0220: 23 20 53 70 65 63 69 66 69 63 20 62 65 68 61 76  # Specific behav
0230: 69 6f 75 72 20 2d 20 76 61 6c 69 64 61 74 69 6f  iour - validatio
0240: 6e 0a 0a 74 65 73 74 20 76 74 2d 24 7b 76 74 79  n..test vt-${vty
0250: 70 65 7d 2d 76 61 6c 69 64 61 74 65 2d 32 2e 30  pe}-validate-2.0
0260: 20 22 24 76 74 79 70 65 20 76 61 6c 69 64 61 74   "$vtype validat
0270: 65 2c 20 66 61 69 6c 22 20 2d 62 6f 64 79 20 7b  e, fail" -body {
0280: 0a 20 20 20 20 24 76 74 79 70 65 20 76 61 6c 69  .    $vtype vali
0290: 64 61 74 65 20 50 20 62 6f 67 75 73 0a 7d 20 2d  date P bogus.} -
02a0: 72 65 74 75 72 6e 43 6f 64 65 73 20 65 72 72 6f  returnCodes erro
02b0: 72 20 2d 72 65 73 75 6c 74 20 7b 45 78 70 65 63  r -result {Expec
02c0: 74 65 64 20 61 6e 20 69 6e 74 65 67 65 72 20 66  ted an integer f
02d0: 6f 72 20 54 20 22 50 22 2c 20 67 6f 74 20 22 62  or T "P", got "b
02e0: 6f 67 75 73 22 7d 0a 0a 74 65 73 74 20 76 74 2d  ogus"}..test vt-
02f0: 24 7b 76 74 79 70 65 7d 2d 76 61 6c 69 64 61 74  ${vtype}-validat
0300: 65 2d 32 2e 31 20 22 24 76 74 79 70 65 20 76 61  e-2.1 "$vtype va
0310: 6c 69 64 61 74 65 2c 20 66 61 69 6c 2c 20 73 74  lidate, fail, st
0320: 72 69 63 74 22 20 2d 62 6f 64 79 20 7b 0a 20 20  rict" -body {.  
0330: 20 20 24 76 74 79 70 65 20 76 61 6c 69 64 61 74    $vtype validat
0340: 65 20 50 20 7b 7d 0a 7d 20 2d 72 65 74 75 72 6e  e P {}.} -return
0350: 43 6f 64 65 73 20 65 72 72 6f 72 20 2d 72 65 73  Codes error -res
0360: 75 6c 74 20 7b 45 78 70 65 63 74 65 64 20 61 6e  ult {Expected an
0370: 20 69 6e 74 65 67 65 72 20 66 6f 72 20 54 20 22   integer for T "
0380: 50 22 2c 20 67 6f 74 20 22 22 7d 0a 0a 74 65 73  P", got ""}..tes
0390: 74 20 76 74 2d 24 7b 76 74 79 70 65 7d 2d 76 61  t vt-${vtype}-va
03a0: 6c 69 64 61 74 65 2d 32 2e 32 20 22 24 76 74 79  lidate-2.2 "$vty
03b0: 70 65 20 76 61 6c 69 64 61 74 65 2c 20 6f 6b 2c  pe validate, ok,
03c0: 20 64 65 63 69 6d 61 6c 22 20 2d 62 6f 64 79 20   decimal" -body 
03d0: 7b 0a 20 20 20 20 24 76 74 79 70 65 20 76 61 6c  {.    $vtype val
03e0: 69 64 61 74 65 20 50 20 33 33 0a 7d 20 2d 72 65  idate P 33.} -re
03f0: 73 75 6c 74 20 33 33 0a 0a 74 65 73 74 20 76 74  sult 33..test vt
0400: 2d 24 7b 76 74 79 70 65 7d 2d 76 61 6c 69 64 61  -${vtype}-valida
0410: 74 65 2d 32 2e 33 20 22 24 76 74 79 70 65 20 76  te-2.3 "$vtype v
0420: 61 6c 69 64 61 74 65 2c 20 6f 6b 2c 20 6f 63 74  alidate, ok, oct
0430: 61 6c 22 20 2d 62 6f 64 79 20 7b 0a 20 20 20 20  al" -body {.    
0440: 24 76 74 79 70 65 20 76 61 6c 69 64 61 74 65 20  $vtype validate 
0450: 50 20 30 31 30 0a 7d 20 2d 72 65 73 75 6c 74 20  P 010.} -result 
0460: 38 0a 0a 74 65 73 74 20 76 74 2d 24 7b 76 74 79  8..test vt-${vty
0470: 70 65 7d 2d 76 61 6c 69 64 61 74 65 2d 32 2e 34  pe}-validate-2.4
0480: 20 22 24 76 74 79 70 65 20 76 61 6c 69 64 61 74   "$vtype validat
0490: 65 2c 20 6f 6b 2c 20 68 65 78 22 20 2d 62 6f 64  e, ok, hex" -bod
04a0: 79 20 7b 0a 20 20 20 20 24 76 74 79 70 65 20 76  y {.    $vtype v
04b0: 61 6c 69 64 61 74 65 20 50 20 30 78 66 66 0a 7d  alidate P 0xff.}
04c0: 20 2d 72 65 73 75 6c 74 20 32 35 35 0a 0a 74 65   -result 255..te
04d0: 73 74 20 76 74 2d 24 7b 76 74 79 70 65 7d 2d 76  st vt-${vtype}-v
04e0: 61 6c 69 64 61 74 65 2d 32 2e 35 20 22 24 76 74  alidate-2.5 "$vt
04f0: 79 70 65 20 76 61 6c 69 64 61 74 65 2c 20 6f 6b  ype validate, ok
0500: 2c 20 6e 65 67 61 74 69 76 65 22 20 2d 62 6f 64  , negative" -bod
0510: 79 20 7b 0a 20 20 20 20 24 76 74 79 70 65 20 76  y {.    $vtype v
0520: 61 6c 69 64 61 74 65 20 50 20 2d 32 0a 7d 20 2d  alidate P -2.} -
0530: 72 65 73 75 6c 74 20 2d 32 0a 0a 23 20 23 20 23  result -2..# # #
0540: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
0550: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
0560: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
0570: 23 23 23 23 23 23 23 23 0a 63 6c 65 61 6e 75 70  ########.cleanup
0580: 54 65 73 74 73 0a 72 65 74 75 72 6e 0a           Tests.return.