########################################################################
# $Header: /var/local/cvsroot/4Suite/test/Xml/Xslt/Exslt/test_math.py,v 1.3 2005/12/28 02:38:18 jkloth Exp $
"""Tests for EXSLT Math"""
from Xml.Xslt import test_harness
SOURCE = """
2
12.0
100
"""
TESTS = []
# math:max()
def test_Max(tester):
sty = """\
2
12.0
100
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "number 100"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:max()')
return
TESTS.append(test_Max)
# math:min()
def test_Min(tester):
sty = """\
2
12.0
100
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "number 2"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:min()')
return
TESTS.append(test_Min)
# math:highest()
def test_Highest(tester):
sty = """\
2
100
12.0
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "x:bread"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:highest()')
return
TESTS.append(test_Highest)
# math:lowest()
def test_Lowest(tester):
sty = """\
2
100
12.0
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "x:spam"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:lowest()')
return
TESTS.append(test_Lowest)
# math:abs()
def test_Abs(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "1 1 0 0"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:abs()')
return
TESTS.append(test_Abs)
# math:sqrt()
def test_Sqrt(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "2 0 1"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:sqrt()')
return
TESTS.append(test_Sqrt)
# math:power()
def test_Power(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "4 0.5"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:power()')
return
TESTS.append(test_Power)
# math:constant()
def test_Constant(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "3.1416 2.7183 1.4142 0.6931 2.3026 1.4427 0.7071 NaN"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:constant()')
return
TESTS.append(test_Constant)
# math:log()
def test_Log(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "0.6932 2.3026"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:log()')
return
TESTS.append(test_Log)
# math:random()
def test_Random(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "true"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:random()')
return
TESTS.append(test_Random)
# math:sin()
def test_Sin(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "0 1 0 -1"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:sin()')
return
TESTS.append(test_Sin)
# math:cos()
def test_Cos(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "1 0 -1 0"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:cos()')
return
TESTS.append(test_Cos)
# math:tan()
def test_Tan(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "0 1 -1"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:tan()')
return
TESTS.append(test_Tan)
# math:asin()
def test_ASin(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "0 1.571 -1.571"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:asin()')
return
TESTS.append(test_ASin)
# math:acos()
def test_ACos(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "1.571 3.142"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:acos()')
return
TESTS.append(test_ACos)
# math:atan()
def test_ATan(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "0 0.785 -0.785"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:atan()')
return
TESTS.append(test_ATan)
# math:atan2()
def test_ATan2(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "0.785 -2.356 0.785 0.464 -2.356 -0.785"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:atan2()')
return
TESTS.append(test_ATan2)
# math:exp()
def test_Exp(tester):
sty = """\
"""
source = test_harness.FileInfo(string=SOURCE)
sheet = test_harness.FileInfo(string=sty)
expected = "2.718 0.368 148.413 22026.466"
test_harness.XsltTest(tester, source, [sheet], expected,
title='math:exp()')
return
TESTS.append(test_Exp)
def Test(tester):
tester.startGroup('Math')
for test in TESTS:
test(tester)
tester.groupDone()
return