# -*- tcl -*-
# constants.test --
#    Test cases for the ::math::constants package
#
# This file contains a collection of tests for one or more of the Tcllib
# procedures.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2004 by Arjen Markus. All rights reserved.
#
# RCS: @(#) $Id: constants.test,v 1.10 2008/03/23 04:39:48 andreas_kupries Exp $

# -------------------------------------------------------------------------

source [file join \
	[file dirname [file dirname [file join [pwd] [info script]]]] \
	devtools testutilities.tcl]

testsNeedTcl     8.2
testsNeedTcltest 2.1

support {
    useLocal math.tcl math
}
testing {
    useLocal constants.tcl math::constants
}

# -------------------------------------------------------------------------

#
# Test: do we get the constants into our namespace?
#
test "Constants-1.0" "Get constants into our namespace" -body {
    ::math::constants::constants pi e
    expr {[info exists pi] && [info exists e]}
} -result 1

test "Constants-1.1" "Get constants with the right values" -body {
    #
    # Only needed once!
    #
    #::math::constants::constants pi e
    set result1 [expr {abs($pi-4.0*atan(1.0))<1.0e-10?1:0}]
    set result2 [expr {abs($e-exp(1.0))<1.0e-10?1:0}]
    expr {$result1+$result2}

    # Note: this should enough accuracy!
} -result 2

#
# No tests for print-constants defined ...
#

# End of test cases
testsuiteCleanup
