home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tcl7.4 / tests / get.test < prev    next >
Encoding:
Text File  |  1995-02-14  |  2.5 KB  |  73 lines

  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 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. # @(#) get.test 1.1 95/02/14 13:15:15
  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. if $doNonPortableTests {
  41.     test get-1.7 {Tcl_GetInt procedure} {
  42.     set x 44
  43.     list [catch {incr x 4294967296} msg] $msg $errorCode
  44.     } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
  45.     test get-1.8 {Tcl_GetInt procedure} {
  46.     set x 0
  47.     list [catch {incr x 4294967294} msg] $msg
  48.     } {0 -2}
  49.     test get-1.8 {Tcl_GetInt procedure} {
  50.     set x 0
  51.     list [catch {incr x +4294967294} msg] $msg
  52.     } {0 -2}
  53.     test get-1.9 {Tcl_GetInt procedure} {
  54.     set x 0
  55.     list [catch {incr x -4294967294} msg] $msg
  56.     } {0 2}
  57. }
  58.  
  59. test get-2.1 {Tcl_GetInt procedure} {
  60.     format %g 1.23
  61. } {1.23}
  62. test get-2.2 {Tcl_GetInt procedure} {
  63.     format %g {      1.23     }
  64. } {1.23}
  65. test get-2.3 {Tcl_GetInt procedure} {
  66.     list [catch {format %g clip} msg] $msg
  67. } {1 {expected floating-point number but got "clip"}}
  68. if $doNonPortableTests {
  69.     test get-2.4 {Tcl_GetInt procedure} {
  70.     list [catch {format %g .000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001} msg] $msg $errorCode
  71.     } {1 {floating-point value too small to represent} {ARITH UNDERFLOW {floating-point value too small to represent}}}
  72. }
  73.