>Eclipse: PsychoPath XPath 2.0 Processor Update

>It’s been a little while since I gave an update on where the PsychoPath XPath 2.0 processor stands from a W3C Test Suite compliance point. Mukul Gandhi (note: nudge him to get his blog on Planet Eclipse since he is an Eclipse committer now) and I have been working our way steadily through the entire test suite. Here are the current results:

Tests: 8137
Failures: 988
Errors: 42

Code Coverage according to ECLEmma:

The test suite now covers about 76% of the PsychoPath. I suspect that we will be close to 80% to 85% code coverage by the time we complete the test suite. When we started we had about 30 or 40 tests that covered about 20% of the code. Unless you run the coverage analysis with a tool like ECLEmma you really do not know how much of your code is actually being executed by your tests. Trying to get to 100% coverage is not worth doing, getting to above 75% is worth doing and should be worked toward.

XPath 2.0 Castable, Durations, and Date/Times:

This has been the bane of my existance for the last several weeks. Reading the W3C specifications on when something can be cast and when something shouldn’t be cast can give one a headache pretty quickly. Luckily the XPath 2.0 and XQuery 1.0 Functions Specification has this nice handy table:

The SeqCastableTest test suite covers about 648 test cases for the core specification. PschyoPath now passes all of these tests. With out the above table, trying to figure out the wording of the specification can be difficult at best, and just plain maddening at worst.

The Natives Will Byte You!

One thing that constantly was biting me was the imprecision that the Java primitive types have. PsychoPath in it’s original implementation used the Integer, Double, and Float classes exclusively. The problem was that in many cases, especially during IntegerLiteral and DecimalLiteral parsing or creation, these were either too small to hold the numbers the tests wanted, or their precision was not accurate enough. A good explanation of the reason can be found in “Double Precision Numbers“. Switching where need to BigInteger and BigDecimal solved many of these issues.

Dates are still another pain to deal with especially calculations. Again you start to run into a precision issue, where some numbers are stored too low. I did some experimentation and both the com.ibm.icu.util.GregorianCalendar and the built in Java GregorianCalendar have precision issues, some in the same place others not. I had thought about trying to leverage Joda Time but that was previously turned down by Eclipse IP team due to pedigree concerns.

I dread debugging these issues. Dates and Time calculations give me a headache.

What’s left:

Lots. There are several core functions that are not working or are missing. Some logic expression errors to correct, and a few more lexer/parser issues to address. Overall though, PsychoPath passes about 88% of the W3C Test Suite, so is much more compliant than it started out. Credit still has to be given to Andrea Bittau, the original author, for a well designed implementation, and some very clean and easy to maintain code. Compared to some of the code I’ve worked on at Eclipse, this is just a pleasure to work with.

All current changes are in the WTP Source Editing CVS Repository.

This entry was posted in eclipse, testing, xml, xpath. Bookmark the permalink.

One Response to >Eclipse: PsychoPath XPath 2.0 Processor Update

  1. Chris says:

    >Nice reference to the wonderful EclEmma plugin and good code coverage rate for such a number of LoC, well done!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s