Package com.singularsys.exttests
Class MathMLTest
- java.lang.Object
-
- com.singularsys.exttests.MathMLTest
-
public class MathMLTest extends java.lang.ObjectGeneral testing suite for mathml parser builder.- Author:
- Richard Morris
-
-
Field Summary
Fields Modifier and Type Field Description static booleanPRINT_ALLPrints detail information about tests carried outstatic booleanRUN_KNOWN_FAILURESSome tests depend on existence of a local style-sheet, set to null to disable testsstatic booleanRUN_NETWORK_TESTSWhether to run slow tests which need network access
-
Constructor Summary
Constructors Constructor Description MathMLTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertEqNodes(java.lang.String s, Node expected, Node actual)voidbiDirectionalTest(java.lang.String eqn, Node node, java.lang.String xml)voidbiDirectionalTest(java.lang.String eqn, java.lang.String xml)booleancompareRecursive(Node node1, Node node2)java.lang.StringdocToString(org.w3c.dom.Document doc, javax.xml.transform.Transformer t)java.lang.StringfixLineEndings(java.lang.String s)voidjepToXmlTest(java.lang.String eqn, Node node, java.lang.String xml)voidjepToXmlTest(java.lang.String eqn, java.lang.String xml)java.lang.StringremoveEmptySpace(java.lang.String s)voidsetUp()static voidsetUpBeforeClass()voidsimpleBuilderTest(java.lang.String eqn, Node node, java.lang.String xml, javax.xml.transform.Transformer t)voidtestCN()Test <cn> numbers elements.voidtestCNbase8XJ()voidtestCNbaseXJ()voidtestCNcomplex()voidtestCNcomplexPolarXJ()voidtestCNconstantPi()Support for Entities is currently broken.voidtestCNe_notation()voidtestCNinteger()voidtestCNrationalXJ()voidtestCNrealXJ()voidtestDeclare()Tests a declare elementvoidtestDeclareVector()Tests parsing of <vector> element.voidtestExponent()voidtestFunctionsExists()Tests that every jep function will be converted to mathml.voidtestInfinity()voidtestList()Converts "[1,[2,3]]" to/from nested <list> elements.voidtestLog()voidtestLog2()voidtestMath()voidtestMathDTD()Tests using the MathML 2.0 DTD.voidtestMathNS()Convert to/from mathml with a namespace (xmlns) attribute specified.voidtestMathNSP()Convert to/from mathml with a namespace (xmlns) attribute specified and a '"m" prefix for MathML elements.voidtestMatrix()Tests >matrix< element.voidtestMinus()voidtestMultipleDeclerations()Tests conversion of multiple <declare> elements.voidtestNaN()voidtestNegInfinityJX()voidtestNegInfinityXJ()voidtestOperatorsExists()Tests that every jep operator will be converted to mathml.voidtestPi()voidtestQuadratic()Conversions of "x^2+4*x+4==0"voidtestQuadraticRoot()Converts "x==(-b-sqrt(b^2.0-4.0*a*c))/(2.0*a)" to-from mathml.voidtestQuadraticToPresentation()This test is only run if LOCAL_STYLESHEETS_DIR is not null and the mmlctop2_0.xsl style sheet from http://www.orcca.on.ca/MathML/software/mmlctop2_0.zip stylesheet is installed there.voidtestRelnXJ()Tests parsing of deprecated <reln> element.voidtestRoot()"sqrt(x)" is converted to from <apply><root/><ci>x</ci></apply>voidtestSelector()Tests a selector element for array indexingvoidtestSemantics()Tests parsing of mathml inside a <semantics> element.voidtestSetXJ()Tests parsing of >set< element.voidtestSin()voidtestSqrt()voidtestUminus()voidtestVector()Tests >vector< element.voidtestXHTML()Parses mathml embedded in an xhtml document.voidtestXHTML2()Parses mathml embedded in an xhtml document.voidxmlToJepTest(java.lang.String eqn, Node expected, java.lang.String xml)voidxmlToJepTest(java.lang.String eqn, java.lang.String xml)
-
-
-
Field Detail
-
PRINT_ALL
public static final boolean PRINT_ALL
Prints detail information about tests carried out- See Also:
- Constant Field Values
-
RUN_NETWORK_TESTS
public static final boolean RUN_NETWORK_TESTS
Whether to run slow tests which need network access- See Also:
- Constant Field Values
-
RUN_KNOWN_FAILURES
public static final boolean RUN_KNOWN_FAILURES
Some tests depend on existence of a local style-sheet, set to null to disable tests- See Also:
- Constant Field Values
-
-
Method Detail
-
setUpBeforeClass
public static void setUpBeforeClass() throws java.lang.Exception- Throws:
java.lang.Exception
-
setUp
public void setUp() throws java.lang.Exception- Throws:
java.lang.Exception
-
fixLineEndings
public java.lang.String fixLineEndings(java.lang.String s)
-
removeEmptySpace
public java.lang.String removeEmptySpace(java.lang.String s)
-
docToString
public java.lang.String docToString(org.w3c.dom.Document doc, javax.xml.transform.Transformer t) throws javax.xml.transform.TransformerException- Throws:
javax.xml.transform.TransformerException
-
simpleBuilderTest
public void simpleBuilderTest(java.lang.String eqn, Node node, java.lang.String xml, javax.xml.transform.Transformer t) throws javax.xml.transform.TransformerException, JepException- Throws:
javax.xml.transform.TransformerExceptionJepException
-
jepToXmlTest
public void jepToXmlTest(java.lang.String eqn, Node node, java.lang.String xml) throws javax.xml.transform.TransformerException, JepException- Throws:
javax.xml.transform.TransformerExceptionJepException
-
jepToXmlTest
public void jepToXmlTest(java.lang.String eqn, java.lang.String xml) throws javax.xml.transform.TransformerException, JepException- Throws:
javax.xml.transform.TransformerExceptionJepException
-
xmlToJepTest
public void xmlToJepTest(java.lang.String eqn, java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException, ParseException- Throws:
javax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionjava.io.IOExceptionParseException
-
xmlToJepTest
public void xmlToJepTest(java.lang.String eqn, Node expected, java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException- Parameters:
eqn-- Throws:
javax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionjava.io.IOException
-
biDirectionalTest
public void biDirectionalTest(java.lang.String eqn, java.lang.String xml) throws javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException, JepException- Throws:
javax.xml.transform.TransformerExceptionjavax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionjava.io.IOExceptionJepException
-
biDirectionalTest
public void biDirectionalTest(java.lang.String eqn, Node node, java.lang.String xml) throws javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException, JepException- Throws:
javax.xml.transform.TransformerExceptionjavax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionjava.io.IOExceptionJepException
-
testCN
public final void testCN() throws java.lang.ExceptionTest <cn> numbers elements.- Throws:
java.lang.Exception
-
testCNbaseXJ
public final void testCNbaseXJ() throws java.lang.Exception- Throws:
java.lang.Exception
-
testCNbase8XJ
public final void testCNbase8XJ() throws java.lang.Exception- Throws:
java.lang.Exception
-
testCNrealXJ
public final void testCNrealXJ() throws java.lang.Exception- Throws:
java.lang.Exception
-
testCNe_notation
public final void testCNe_notation() throws java.lang.Exception- Throws:
java.lang.Exception
-
testCNinteger
public final void testCNinteger() throws java.lang.Exception- Throws:
java.lang.Exception
-
testCNrationalXJ
public final void testCNrationalXJ() throws java.lang.Exception- Throws:
java.lang.Exception
-
testCNcomplex
public final void testCNcomplex() throws java.lang.Exception- Throws:
java.lang.Exception
-
testCNcomplexPolarXJ
public final void testCNcomplexPolarXJ() throws java.lang.Exception- Throws:
java.lang.Exception
-
testCNconstantPi
public final void testCNconstantPi() throws java.lang.ExceptionSupport for Entities is currently broken.- Throws:
java.lang.Exception
-
testNaN
public final void testNaN() throws java.lang.Exception- Throws:
java.lang.Exception
-
testInfinity
public final void testInfinity() throws java.lang.Exception- Throws:
java.lang.Exception
-
testNegInfinityJX
public final void testNegInfinityJX() throws java.lang.Exception- Throws:
java.lang.Exception
-
testNegInfinityXJ
public final void testNegInfinityXJ() throws java.lang.Exception- Throws:
java.lang.Exception
-
testPi
public final void testPi() throws java.lang.Exception- Throws:
java.lang.Exception
-
testUminus
public final void testUminus() throws java.lang.Exception- Throws:
java.lang.Exception
-
testMinus
public final void testMinus() throws java.lang.Exception- Throws:
java.lang.Exception
-
testLog
public final void testLog() throws java.lang.Exception- Throws:
java.lang.Exception
-
testLog2
public final void testLog2() throws java.lang.Exception- Throws:
java.lang.Exception
-
testSin
public final void testSin() throws java.lang.Exception- Throws:
java.lang.Exception
-
testSqrt
public final void testSqrt() throws java.lang.Exception- Throws:
java.lang.Exception
-
testQuadratic
public final void testQuadratic() throws java.lang.ExceptionConversions of "x^2+4*x+4==0"- Throws:
java.lang.Exception
-
testQuadraticToPresentation
public final void testQuadraticToPresentation() throws java.lang.ExceptionThis test is only run if LOCAL_STYLESHEETS_DIR is not null and the mmlctop2_0.xsl style sheet from http://www.orcca.on.ca/MathML/software/mmlctop2_0.zip stylesheet is installed there.- Throws:
java.lang.Exception
-
testQuadraticRoot
public final void testQuadraticRoot() throws java.lang.ExceptionConverts "x==(-b-sqrt(b^2.0-4.0*a*c))/(2.0*a)" to-from mathml. Note no ± equivalent in jep, jep will parse 4*a*c as (4*a)*c.- Throws:
java.lang.Exception
-
testRoot
public final void testRoot() throws java.lang.Exception"sqrt(x)" is converted to from <apply><root/><ci>x</ci></apply>- Throws:
java.lang.Exception
-
testMatrix
public final void testMatrix() throws java.lang.ExceptionTests >matrix< element.- Throws:
java.lang.Exception
-
testVector
public final void testVector() throws java.lang.ExceptionTests >vector< element.- Throws:
java.lang.Exception
-
testList
public final void testList() throws java.lang.ExceptionConverts "[1,[2,3]]" to/from nested <list> elements.- Throws:
java.lang.Exception
-
testSetXJ
public final void testSetXJ() throws java.lang.ExceptionTests parsing of >set< element.- Throws:
java.lang.Exception
-
testSelector
public final void testSelector() throws java.lang.ExceptionTests a selector element for array indexing- Throws:
java.lang.Exception
-
testDeclare
public final void testDeclare() throws java.lang.ExceptionTests a declare element- Throws:
java.lang.Exception
-
testDeclareVector
public final void testDeclareVector() throws java.lang.ExceptionTests parsing of <vector> element. Reverse fails as it misses the type="vector" attribute of the declare tag.- Throws:
java.lang.Exception
-
testRelnXJ
public final void testRelnXJ() throws java.lang.ExceptionTests parsing of deprecated <reln> element. In reverse relations are children of apply elements as per v2.0 .- Throws:
java.lang.Exception
-
testXHTML
public final void testXHTML() throws java.lang.ExceptionParses mathml embedded in an xhtml document.- Throws:
java.lang.Exception
-
testXHTML2
public final void testXHTML2() throws java.lang.ExceptionParses mathml embedded in an xhtml document.- Throws:
java.lang.Exception
-
testMath
public final void testMath() throws java.lang.Exception- Throws:
java.lang.Exception
-
testMathNS
public final void testMathNS() throws java.lang.ExceptionConvert to/from mathml with a namespace (xmlns) attribute specified.- Throws:
java.lang.Exception
-
testMathNSP
public final void testMathNSP() throws java.lang.ExceptionConvert to/from mathml with a namespace (xmlns) attribute specified and a '"m" prefix for MathML elements.- Throws:
java.lang.Exception
-
testSemantics
public final void testSemantics() throws java.lang.ExceptionTests parsing of mathml inside a <semantics> element.- Throws:
java.lang.Exception
-
testExponent
public final void testExponent() throws java.lang.Exception- Throws:
java.lang.Exception
-
testMultipleDeclerations
public final void testMultipleDeclerations() throws java.lang.ExceptionTests conversion of multiple <declare> elements.- Throws:
java.lang.Exception
-
testMathDTD
public final void testMathDTD() throws java.lang.ExceptionTests using the MathML 2.0 DTD. This needs to download the mathml dtd to run the parsing part which is only run if RUN_NETWORK_TESTS is true.- Throws:
java.lang.Exception
-
testFunctionsExists
public final void testFunctionsExists() throws java.lang.ExceptionTests that every jep function will be converted to mathml. If RUN_KNOWN_FAILURES is true it will fail otherwise prints list of unknown functions.- Throws:
java.lang.Exception
-
testOperatorsExists
public final void testOperatorsExists() throws java.lang.ExceptionTests that every jep operator will be converted to mathml. If RUN_KNOWN_FAILURES is true it will fail otherwise prints list of unknown operators.- Throws:
java.lang.Exception
-
-