summaryrefslogtreecommitdiffstats
path: root/tcllib/modules/math/constants.test
blob: 280fb8c093ce5c134bc4b5dcf4c27aeda249be6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- 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