Bug #4976

Inadequate bytecode testing: unfolded option on empty sequence

Added by Michael Kay 6 months ago. Updated 5 months ago.

In Progress
Start date:
Due date:
% Done:


Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:


Many of the W3C test cases can be defeated by an optimiser that does early evaluation: for example all the starts-with tests in which one of the operands is an empty sequence actually write the operand as "()", which means there are no tests for the case where the operand value is found to be an empty sequence at run-time. We compensate for this with the -unfolded option in the test driver, which modifies the query so that literals are replaced by expressions that return the relevant value at run-time but cannot be eagerly evaluated.

But the -unfolded option has no effect on the literal value "()", because the mechanism relies on trace code injection, and the trace code injector is not called when we generate this expression. This means that the dynamic-empty-sequence case is often untested. This particularly affects tests for byte code generation.


#1 Updated by Michael Kay 6 months ago

I've fixed this on the 11.x branch, but it still leaves the relevant paths untested, because when we use -unfolded, the effect is that the collation passed to a function like starts-with is itself "unfolded", which means that the collation is not statically known, and we do not generate bytecode for the rare case of a function call whose collation parameter is evaluated dynamically.

#2 Updated by Michael Kay 5 months ago

  • Status changed from New to In Progress

Starting with the fn-contains-token and fn-contains test sets in QT4, I've added some new tests (suffixed -dyn) that modify existing tests by using external variables in place of literals in the query.

Please register to edit this issue

Also available in: Atom PDF