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 / get.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  2.6 KB  |  73 lines  |  [TEXT/ALFA]

  1. # Commands covered:  none
  2. #
  3. # This file contains a collection of tests for the procedures in the
  4. # file tclGet.c.  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) 1995-1996 Sun Microsystems, Inc.
  8. #
  9. # See the file "license.terms" for information on usage and redistribution
  10. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11. #
  12. # SCCS: @(#) get.test 1.6 96/10/08 17:39:21
  13.  
  14. if {[string compare test [info procs test]] == 1} then {source defs}
  15.  
  16. test get-1.1 {Tcl_GetInt procedure} {
  17.     set x 44
  18.     incr x {       22}
  19. } {66}
  20. test get-1.2 {Tcl_GetInt procedure} {
  21.     set x 44
  22.     incr x -3
  23. } {41}
  24. test get-1.3 {Tcl_GetInt procedure} {
  25.     set x 44
  26.     incr x +8
  27. } {52}
  28. test get-1.4 {Tcl_GetInt procedure} {
  29.     set x 44
  30.     list [catch {incr x foo} msg] $msg
  31. } {1 {expected integer but got "foo"}}
  32. test get-1.5 {Tcl_GetInt procedure} {
  33.     set x 44
  34.     list [catch {incr x {16     }} msg] $msg
  35. } {0 60}
  36. test get-1.6 {Tcl_GetInt procedure} {
  37.     set x 44
  38.     list [catch {incr x {16     x}} msg] $msg
  39. } {1 {expected integer but got "16     x"}}
  40.  
  41. # The following tests are non-portable because they depend on
  42. # word size.  
  43.  
  44. test get-1.7 {Tcl_GetInt procedure} {nonPortable unixOnly} {
  45.     set x 44
  46.     list [catch {incr x 4294967296} msg] $msg $errorCode
  47. } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
  48. test get-1.8 {Tcl_GetInt procedure} {nonPortable} {
  49.     set x 0
  50.     list [catch {incr x 4294967294} msg] $msg
  51. } {0 -2}
  52. test get-1.9 {Tcl_GetInt procedure} {nonPortable} {
  53.     set x 0
  54.     list [catch {incr x +4294967294} msg] $msg
  55. } {0 -2}
  56. test get-1.10 {Tcl_GetInt procedure} {nonPortable} {
  57.     set x 0
  58.     list [catch {incr x -4294967294} msg] $msg
  59. } {0 2}
  60.  
  61. test get-2.1 {Tcl_GetInt procedure} {
  62.     format %g 1.23
  63. } {1.23}
  64. test get-2.2 {Tcl_GetInt procedure} {
  65.     format %g {      1.23     }
  66. } {1.23}
  67. test get-2.3 {Tcl_GetInt procedure} {
  68.     list [catch {format %g clip} msg] $msg
  69. } {1 {expected floating-point number but got "clip"}}
  70. test get-2.4 {Tcl_GetInt procedure} {nonPortable} {
  71.     list [catch {format %g .000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001} msg] $msg $errorCode
  72. } {1 {floating-point value too small to represent} {ARITH UNDERFLOW {floating-point value too small to represent}}}
  73.