01: package JSci.tests;
02:
03: import JSci.io.*;
04:
05: public class MathMLTest extends junit.framework.TestCase {
06: public static void main(String arg[]) {
07: junit.textui.TestRunner.run(MathMLTest.class);
08: }
09:
10: public MathMLTest(String name) {
11: super (name);
12: }
13:
14: protected void setUp() {
15: JSci.GlobalSettings.ZERO_TOL = 1.0e-9;
16: }
17:
18: public void testParse() throws Exception {
19: MathMLParser parser = new MathMLParser();
20: parser.parse(getClass().getResource("test.mml").toString());
21:
22: Object[] list = parser.translateToJSciObjects();
23: for (int i = 0; i < list.length; i += 2) {
24: Object actual = list[i];
25: Object expected = list[i + 1];
26: if (actual instanceof MathMLExpression)
27: actual = ((MathMLExpression) actual).evaluate();
28: if (expected instanceof MathMLExpression)
29: expected = ((MathMLExpression) expected).evaluate();
30: assertEquals(expected, actual);
31: }
32: }
33: }
|