diff options
Diffstat (limited to 'tests/platform.test')
| -rw-r--r-- | tests/platform.test | 55 | 
1 files changed, 39 insertions, 16 deletions
| diff --git a/tests/platform.test b/tests/platform.test index 2236311..5838a41 100644 --- a/tests/platform.test +++ b/tests/platform.test @@ -1,4 +1,4 @@ -# The file tests the tcl_platform variable +# The file tests the tcl_platform variable and platform package.  #  # This file contains a collection of tests for one or more of the Tcl  # built-in commands.  Sourcing this file into Tcl runs the tests and @@ -8,15 +8,24 @@  #  # See the file "license.terms" for information on usage and redistribution  # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -# -# RCS: @(#)  -if {[lsearch [namespace children] ::tcltest] == -1} { -    package require tcltest -    namespace import -force ::tcltest::* -} +package require tcltest 2 + +namespace eval ::tcl::test::platform { +    namespace import ::tcltest::testConstraint +    namespace import ::tcltest::test +    namespace import ::tcltest::cleanupTests + +    variable ::tcl_platform + +::tcltest::loadTestedCommands +catch [list package require -exact Tcltest [info patchlevel]] -testConstraint testWinCPUID [llength [info commands testwincpuid]] +testConstraint testCPUID [llength [info commands testcpuid]] + +test platform-1.0 {tcl_platform(engine)} { +  set tcl_platform(engine) +} {Tcl}  test platform-1.1 {TclpSetVariables: tcl_platform} {      interp create i @@ -25,7 +34,7 @@ test platform-1.1 {TclpSetVariables: tcl_platform} {      set result [i eval {lsort [array names tcl_platform]}]      interp delete i      set result -} {byteOrder machine os osVersion platform user wordSize} +} {byteOrder engine machine os osVersion pathSeparator platform pointerSize user wordSize}  # Test assumes twos-complement arithmetic, which is true of virtually  # everything these days.  Note that this does *not* use wide(), and @@ -38,22 +47,36 @@ test platform-2.1 {tcl_platform(wordSize) indicates size of native word} {      list [expr {$result < 0}] [expr {$result ^ int($result - 1)}]  } {1 -1} -# On Windows, test that the CPU ID works +# On Windows/UNIX, test that the CPU ID works -test platform-3.1 {CPU ID on Windows } \ -    -constraints testWinCPUID \ -    -body {		 -	set cpudata [testwincpuid 0] +test platform-3.1 {CPU ID on Windows/UNIX} \ +    -constraints testCPUID \ +    -body { +	set cpudata [testcpuid 0]  	binary format iii \  	    [lindex $cpudata 1] \  	    [lindex $cpudata 3] \ -	    [lindex $cpudata 2]  +	    [lindex $cpudata 2]      } \      -match regexp \      -result {^(?:AuthenticAMD|CentaurHauls|CyrixInstead|GenuineIntel)$} +# The platform package makes very few promises, but does promise that the +# format of string it produces consists of two non-empty words separated by a +# hyphen. +package require platform +test platform-4.1 {format of platform::identify result} -match regexp -body { +    platform::identify +} -result {^([^-]+-)+[^-]+$} +test platform-4.2 {format of platform::generic result} -match regexp -body { +    platform::generic +} -result {^([^-]+-)+[^-]+$} +  # cleanup -::tcltest::cleanupTests +cleanupTests + +} +namespace delete ::tcl::test::platform  return  # Local Variables: | 
