Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/expressions/operators/types/InstanceOfOperator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class InstanceOfOperator extends Expression {
) {
super(
expression.specificity,
[expression],
[expression, typeTest],
{ canBeStaticallyEvaluated: false },
false,
type,
Expand Down
18 changes: 15 additions & 3 deletions test/specs/parsing/operators/types/InstanceOfOperator.tests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as chai from 'chai';
import * as slimdom from 'slimdom';
import { Document } from 'slimdom';

import { evaluateXPathToBoolean } from 'fontoxpath';
import evaluateXPathToAsyncSingleton from 'test-helpers/evaluateXPathToAsyncSingleton';
import { Language, evaluateXPathToBoolean } from 'fontoxpath';

describe('instance of operator', () => {
it('returns true for a valid instance of xs:boolean', () =>
Expand Down Expand Up @@ -38,4 +37,17 @@ describe('instance of operator', () => {

it('returns false for an invalid instance of node()', () =>
chai.assert.isFalse(evaluateXPathToBoolean('1 instance of node()')));

it('keeps namespaces into account', () => {
chai.assert.isTrue(
evaluateXPathToBoolean(
`declare namespace x='x';
<x:ele/> instance of element(x:ele)`,
new Document(),
null,
null,
{ language: Language.XQUERY_3_1_LANGUAGE },
),
);
});
});
Loading