-
Notifications
You must be signed in to change notification settings - Fork 20
Implement otherwise and combinating tests from XQ4 #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DrRataplan
wants to merge
6
commits into
master
Choose a base branch
from
xquery-next
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fd3c191
Implement otherwise and combinating tests from XQ4
DrRataplan 342dd0b
Make CI not run tests in parallel
DrRataplan acc9511
Improve union node tests
DrRataplan 89397b6
Fix import in functioncall tests
DrRataplan 50e4cfe
Fix language for XQUTS tests
DrRataplan b520bac
Improve test coverage
DrRataplan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import Value from '../dataTypes/Value'; | ||
| import DynamicContext from '../DynamicContext'; | ||
| import ExecutionParameters from '../ExecutionParameters'; | ||
| import Specificity from '../Specificity'; | ||
| import StaticContext from '../StaticContext'; | ||
| import { Bucket, unionBucket } from '../util/Bucket'; | ||
| import TestAbstractExpression from './TestAbstractExpression'; | ||
|
|
||
| /** | ||
| * Union node test, used to process `descendant::(a|b|c)` selectors | ||
| */ | ||
| class UnionNodeTest extends TestAbstractExpression { | ||
| private _subTests: TestAbstractExpression[]; | ||
| private _bucket: Bucket; | ||
| constructor(subTests: TestAbstractExpression[]) { | ||
| const maxSpecificity = subTests.reduce<Specificity>((currentMaxSpecificity, selector) => { | ||
| if (currentMaxSpecificity.compareTo(selector.specificity) > 0) { | ||
| return currentMaxSpecificity; | ||
| } | ||
| return selector.specificity; | ||
| }, new Specificity({})); | ||
|
|
||
| super(maxSpecificity); | ||
|
|
||
| // If all subExpressions define the same bucket: use that one, else, use no bucket. | ||
| let bucket: Bucket | null; | ||
| for (let i = 0; i < subTests.length; ++i) { | ||
| const subTestBucket = subTests[i].getBucket(); | ||
| if (bucket === undefined) { | ||
| bucket = subTestBucket; | ||
| } | ||
| if (bucket === null) { | ||
| // Not applicable buckets | ||
| break; | ||
| } | ||
|
|
||
| bucket = unionBucket(bucket, subTestBucket); | ||
| } | ||
|
|
||
| this._bucket = bucket; | ||
| this._subTests = subTests; | ||
| } | ||
|
|
||
| public evaluateToBoolean( | ||
| dynamicContext: DynamicContext, | ||
| value: Value, | ||
| executionParameters: ExecutionParameters, | ||
| ) { | ||
| return this._subTests.some((test) => { | ||
| const result = test.evaluateToBoolean(dynamicContext, value, executionParameters); | ||
| return result; | ||
| }); | ||
| } | ||
|
|
||
| public override getBucket(): Bucket { | ||
| return this._bucket; | ||
| } | ||
|
|
||
| public performStaticEvaluation(staticContext: StaticContext) { | ||
| this._subTests.forEach((test) => test.performStaticEvaluation(staticContext)); | ||
| } | ||
| } | ||
|
|
||
| export default UnionNodeTest; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import ISequence from '../dataTypes/ISequence'; | ||
| import sequenceFactory from '../dataTypes/sequenceFactory'; | ||
| import { SequenceType, ValueType } from '../dataTypes/Value'; | ||
| import DynamicContext from '../DynamicContext'; | ||
| import ExecutionParameters from '../ExecutionParameters'; | ||
| import Expression, { RESULT_ORDERINGS } from '../Expression'; | ||
| import PossiblyUpdatingExpression, { SequenceCallbacks } from '../PossiblyUpdatingExpression'; | ||
| import Specificity from '../Specificity'; | ||
|
|
||
| /** | ||
| * The 'otherwise' expression: returns the first operand that's not empty | ||
| */ | ||
| class Otherwise extends PossiblyUpdatingExpression { | ||
| constructor(expressions: Expression[], type: SequenceType) { | ||
| const maxSpecificity = expressions.reduce((maxSpecificitySoFar, expression) => { | ||
| if (maxSpecificitySoFar.compareTo(expression.specificity) > 0) { | ||
| return maxSpecificitySoFar; | ||
| } | ||
| return expression.specificity; | ||
| }, new Specificity({})); | ||
| super( | ||
| maxSpecificity, | ||
| expressions, | ||
| { | ||
| canBeStaticallyEvaluated: expressions.every( | ||
| (expression) => expression.canBeStaticallyEvaluated, | ||
| ), | ||
| }, | ||
| type, | ||
| ); | ||
| } | ||
|
|
||
| public override performFunctionalEvaluation( | ||
| dynamicContext: DynamicContext, | ||
| _executionParameters: ExecutionParameters, | ||
| sequenceCallbacks: SequenceCallbacks, | ||
| ): ISequence { | ||
| for (const cb of sequenceCallbacks) { | ||
| const sequence = cb(dynamicContext); | ||
| if (!sequence.isEmpty()) { | ||
| return sequence; | ||
| } | ||
| } | ||
| return sequenceFactory.empty(); | ||
| } | ||
| } | ||
| export default Otherwise; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,7 +85,7 @@ function parseXPath(xpathExpression: EvaluableExpression): Expression { | |
|
|
||
| const ast = | ||
| typeof xpathExpression === 'string' | ||
| ? parseExpression(xpathExpression, { allowXQuery: false }) | ||
| ? parseExpression(xpathExpression, { allowXQuery: false, version: 4 }) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this depend on the options? In that case we'd probably also need separate caches for the 3.1 vs 4 expressions. |
||
| : // AST is an element: convert to jsonml | ||
| convertXmlToAst(xpathExpression); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this intentional or removed for debugging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional. the parallel hides easy to fix errors behind confusing errors. It's CI, so a bit slower is fine