From 4de189199678aa6aaae30aecda39bea6ecb5d7f3 Mon Sep 17 00:00:00 2001 From: Jitse De Smet Date: Tue, 3 Oct 2023 17:50:05 +0200 Subject: [PATCH] test: fix EE integration test --- ...ctorBindingsAggregatorFactoryCount-test.ts | 14 +-- .../lib/evaluators/ExpressionEvaluator.ts | 6 +- .../evaluators/ExpressionEvaluatorFactory.ts | 9 +- .../lib/expressions/Term.ts | 6 +- .../lib/transformers/TermTransformer.ts | 2 +- .../integration/evaluators/Evaluator-test.ts | 99 +++++---------- .../evaluators/RecursiveEvaluator-test.ts | 116 ++---------------- .../integration/functions/extension-test.ts | 38 +++--- .../integration/functions/onStrings-test.ts | 22 ++-- .../integration/functions/op.addition-test.ts | 7 +- .../integration/functions/op.bnode-test.ts | 11 +- .../integration/functions/op.bound-test.ts | 8 +- .../integration/functions/op.division-test.ts | 7 +- .../integration/functions/op.equality-test.ts | 14 +-- .../functions/op.lesserThan-test.ts | 7 +- .../functions/op.lesserThanEqual-test.ts | 7 +- .../test/integration/misc/Exists-test.ts | 25 +--- .../transformers/AlgebraTransformer-test.ts | 7 +- .../transformers/TermTransformer-test.ts | 2 +- .../test/integration/util/Ordering-test.ts | 16 ++- .../test/spec/iri01-spec-test.ts | 4 +- .../test/util/TestTable.ts | 14 ++- .../test/util/generalEvaluation.ts | 99 +++------------ .../expression-evaluator/test/util/utils.ts | 37 +++++- 24 files changed, 187 insertions(+), 390 deletions(-) diff --git a/packages/actor-bindings-aggregator-factory-count/test/ActorBindingsAggregatorFactoryCount-test.ts b/packages/actor-bindings-aggregator-factory-count/test/ActorBindingsAggregatorFactoryCount-test.ts index b1dbc984ab..5ea91f46a9 100644 --- a/packages/actor-bindings-aggregator-factory-count/test/ActorBindingsAggregatorFactoryCount-test.ts +++ b/packages/actor-bindings-aggregator-factory-count/test/ActorBindingsAggregatorFactoryCount-test.ts @@ -1,11 +1,10 @@ import { ActionContext, Bus } from '@comunica/core'; import { ExpressionEvaluatorFactory } from '@comunica/expression-evaluator'; import type { IExpressionEvaluatorFactory } from '@comunica/types'; -import { ArrayIterator } from 'asynciterator'; import { Algebra } from 'sparqlalgebrajs'; import { Wildcard } from 'sparqljs'; import { ActorBindingsAggregatorFactoryCount } from '../lib'; -import { BF, DF, makeAggregate } from './util'; +import { makeAggregate } from './util'; describe('ActorExpressionEvaluatorAggregateCount', () => { let bus: any; @@ -15,16 +14,7 @@ describe('ActorExpressionEvaluatorAggregateCount', () => { bus = new Bus({ name: 'bus' }); const mediatorQueryOperation: any = { - mediate: (arg: any) => Promise.resolve({ - bindingsStream: new ArrayIterator([ - BF.bindings([[ DF.variable('x'), DF.literal('1') ]]), - BF.bindings([[ DF.variable('x'), DF.literal('2') ]]), - BF.bindings([[ DF.variable('x'), DF.literal('3') ]]), - ], { autoStart: false }), - metadata: () => Promise.resolve({ cardinality: 3, canContainUndefs: false, variables: [ DF.variable('x') ]}), - operated: arg, - type: 'bindings', - }), + async mediate(arg: any) { return {}; }, }; expressionEvaluatorFactory = new ExpressionEvaluatorFactory({ diff --git a/packages/expression-evaluator/lib/evaluators/ExpressionEvaluator.ts b/packages/expression-evaluator/lib/evaluators/ExpressionEvaluator.ts index f0ca17a6f7..3dbe2dc27f 100644 --- a/packages/expression-evaluator/lib/evaluators/ExpressionEvaluator.ts +++ b/packages/expression-evaluator/lib/evaluators/ExpressionEvaluator.ts @@ -154,13 +154,11 @@ export class ExpressionEvaluator implements IExpressionEvaluator { return this.comparePrimitives(termA.value, termB.value); } - private orderLiteralTypes(litA: RDF.Literal, litB: RDF.Literal, context: IAsyncEvaluatorContext): -1 | 0 | 1 { + private orderLiteralTypes(litA: RDF.Literal, litB: RDF.Literal, context: ICompleteEEContext): -1 | 0 | 1 { const isGreater = regularFunctions[C.RegularOperator.GT]; const isEqual = regularFunctions[C.RegularOperator.EQUAL]; - const completeContext = ExpressionEvaluator.completeContext(context); - - const termTransformer = new TermTransformer(completeContext.superTypeProvider); + const termTransformer = new TermTransformer(context.superTypeProvider); const myLitA = termTransformer.transformLiteral(litA); const myLitB = termTransformer.transformLiteral(litB); diff --git a/packages/expression-evaluator/lib/evaluators/ExpressionEvaluatorFactory.ts b/packages/expression-evaluator/lib/evaluators/ExpressionEvaluatorFactory.ts index 410a289c53..bbced15fb9 100644 --- a/packages/expression-evaluator/lib/evaluators/ExpressionEvaluatorFactory.ts +++ b/packages/expression-evaluator/lib/evaluators/ExpressionEvaluatorFactory.ts @@ -5,6 +5,7 @@ import { KeysInitQuery } from '@comunica/context-entries'; import { BlankNodeBindingsScoped } from '@comunica/data-factory'; import type { IActionContext, IBindingAggregator, IExpressionEvaluatorFactory } from '@comunica/types'; import type { Algebra as Alg } from 'sparqlalgebrajs'; +import type { IAsyncEvaluatorContext } from './ExpressionEvaluator'; import { ExpressionEvaluator } from './ExpressionEvaluator'; /** @@ -24,17 +25,21 @@ export class ExpressionEvaluatorFactory implements IExpressionEvaluatorFactory { this.mediatorQueryOperation = args.mediatorQueryOperation; } - public createEvaluator(algExpr: Alg.Expression, context: IActionContext): ExpressionEvaluator { + // TODO: remove legacyContext in *final* update (probably when preparing the EE for function bussification) + public createEvaluator(algExpr: Alg.Expression, context: IActionContext, + legacyContext: Partial = {}): ExpressionEvaluator { return new ExpressionEvaluator(algExpr, { now: context.get(KeysInitQuery.queryTimestamp), baseIRI: context.get(KeysInitQuery.baseIRI), actionContext: context, bnode: (input?: string) => Promise.resolve(new BlankNodeBindingsScoped(input || `BNODE_${bnodeCounter++}`)), exists: ActorQueryOperation.createExistenceResolver(context, this.mediatorQueryOperation), + ...legacyContext, }, this); } - public async createAggregator(algExpr: Alg.AggregateExpression, context: IActionContext): Promise { + public async createAggregator(algExpr: Alg.AggregateExpression, context: IActionContext): + Promise { return (await this.mediatorBindingsAggregatorFactory.mediate({ expr: algExpr, factory: this, diff --git a/packages/expression-evaluator/lib/expressions/Term.ts b/packages/expression-evaluator/lib/expressions/Term.ts index 79a2ffb7b0..2b60c22a4a 100644 --- a/packages/expression-evaluator/lib/expressions/Term.ts +++ b/packages/expression-evaluator/lib/expressions/Term.ts @@ -117,15 +117,13 @@ export class Quad extends Term { export class DefaultGraph extends Term { public termType: TermType = 'defaultGraph'; - private readonly valueTerm: RDF.DefaultGraph; - public constructor(input: RDF.DefaultGraph) { + public constructor() { super(); - this.valueTerm = input; } public toRDF(): RDF.DefaultGraph { - return this.valueTerm; + return DF.defaultGraph(); } } diff --git a/packages/expression-evaluator/lib/transformers/TermTransformer.ts b/packages/expression-evaluator/lib/transformers/TermTransformer.ts index c308acfbbf..575c5249fd 100644 --- a/packages/expression-evaluator/lib/transformers/TermTransformer.ts +++ b/packages/expression-evaluator/lib/transformers/TermTransformer.ts @@ -58,7 +58,7 @@ export class TermTransformer implements ITermTransformer { case 'Quad': return new E.Quad(term.term, this.superTypeProvider); case 'DefaultGraph': - return new E.DefaultGraph(term.term); + return new E.DefaultGraph(); default: throw new Err.InvalidTermType(term); } diff --git a/packages/expression-evaluator/test/integration/evaluators/Evaluator-test.ts b/packages/expression-evaluator/test/integration/evaluators/Evaluator-test.ts index 0367157138..bec74bf7b4 100644 --- a/packages/expression-evaluator/test/integration/evaluators/Evaluator-test.ts +++ b/packages/expression-evaluator/test/integration/evaluators/Evaluator-test.ts @@ -1,93 +1,58 @@ import { BindingsFactory } from '@comunica/bindings-factory'; +import { ActionContext } from '@comunica/core'; import { DataFactory } from 'rdf-data-factory'; -import { translate } from 'sparqlalgebrajs'; -import { AsyncEvaluator, SyncEvaluator } from '../../../lib'; +import type { ExpressionEvaluatorFactory } from '../../../lib'; import { IntegerLiteral } from '../../../lib/expressions'; import { TypeURL as DT } from '../../../lib/util/Consts'; import * as Err from '../../../lib/util/Errors'; +import { getMockEEFactory, getMockExpression } from '../../util/utils'; const DF = new DataFactory(); const BF = new BindingsFactory(); const two = DF.literal('2', DF.namedNode(DT.XSD_INTEGER)); -function parse(expr: string) { - return translate(`SELECT * WHERE { ?s ?p ?o FILTER (${expr})}`).input.expression; -} - describe('evaluators', () => { - describe('SyncEvaluator', () => { - describe('evaluate', () => { - it('is able to evaluate', () => { - const evaluator = new SyncEvaluator(parse('1 + 1')); - expect(evaluator.evaluate(BF.bindings())).toEqual(two); - }); - - it('has proper default extended XSD type support', () => { - const evaluator = new SyncEvaluator(parse('1 + 1')); - expect(evaluator.evaluate(BF.bindings())).toEqual(two); - }); + let factory: ExpressionEvaluatorFactory; + let actionContext: ActionContext; + beforeEach(() => { + factory = getMockEEFactory(); + actionContext = new ActionContext({}); + }); - it('has proper extended XSD type support', () => { - const evaluator = new SyncEvaluator(parse('1 + "1"^^')); - expect(() => evaluator.evaluate(BF.bindings())).toThrow(Err.InvalidArgumentTypes); - }); + describe('evaluate', () => { + it('is able to evaluate', async() => { + const evaluator = factory.createEvaluator(getMockExpression('1 + 1'), actionContext); + expect(await evaluator.evaluate(BF.bindings())).toEqual(two); }); - describe('evaluateAsEBV', () => { - it('is able to evaluate to true', () => { - const evaluator = new SyncEvaluator(parse('1 + 1')); - expect(evaluator.evaluateAsEBV(BF.bindings())).toEqual(true); - }); - - it('is able to evaluate to false', () => { - const evaluator = new SyncEvaluator(parse('0')); - expect(evaluator.evaluateAsEBV(BF.bindings())).toEqual(false); - }); + it('has proper default extended XSD type support', async() => { + const evaluator = factory.createEvaluator(getMockExpression('1 + 1'), actionContext); + expect(await evaluator.evaluate(BF.bindings())).toEqual(two); }); - describe('evaluateAsInternal', () => { - it('is able to evaluate', () => { - const evaluator = new SyncEvaluator(parse('1 + 1')); - expect(evaluator.evaluateAsInternal(BF.bindings())).toEqual(new IntegerLiteral(2)); - }); + it('has proper extended XSD type support', async() => { + const evaluator = factory.createEvaluator(getMockExpression('1 + "1"^^'), + actionContext); + await expect(evaluator.evaluate(BF.bindings())).rejects.toThrow(Err.InvalidArgumentTypes); }); }); - describe('AsyncEvaluator', () => { - describe('evaluate', () => { - it('is able to evaluate', async() => { - const evaluator = new AsyncEvaluator(parse('1 + 1')); - expect(await evaluator.evaluate(BF.bindings())).toEqual(two); - }); - - it('has proper default extended XSD type support', async() => { - const evaluator = new AsyncEvaluator(parse('1 + 1')); - expect(await evaluator.evaluate(BF.bindings())).toEqual(two); - }); - - it('has proper extended XSD type support', async() => { - const evaluator = new AsyncEvaluator(parse('1 + "1"^^')); - await expect(evaluator.evaluate(BF.bindings())).rejects.toThrow(Err.InvalidArgumentTypes); - }); + describe('evaluateAsEBV', () => { + it('is able to evaluate to true', async() => { + const evaluator = factory.createEvaluator(getMockExpression('1 + 1'), actionContext); + expect(await evaluator.evaluateAsEBV(BF.bindings())).toEqual(true); }); - describe('evaluateAsEBV', () => { - it('is able to evaluate to true', async() => { - const evaluator = new AsyncEvaluator(parse('1 + 1')); - expect(await evaluator.evaluateAsEBV(BF.bindings())).toEqual(true); - }); - - it('is able to evaluate to false', async() => { - const evaluator = new AsyncEvaluator(parse('0')); - expect(await evaluator.evaluateAsEBV(BF.bindings())).toEqual(false); - }); + it('is able to evaluate to false', async() => { + const evaluator = factory.createEvaluator(getMockExpression('0'), actionContext); + expect(await evaluator.evaluateAsEBV(BF.bindings())).toEqual(false); }); + }); - describe('evaluateAsInternal', () => { - it('is able to evaluate', async() => { - const evaluator = new AsyncEvaluator(parse('1 + 1')); - expect(await evaluator.evaluateAsInternal(BF.bindings())).toEqual(new IntegerLiteral(2)); - }); + describe('evaluateAsInternal', () => { + it('is able to evaluate', async() => { + const evaluator = factory.createEvaluator(getMockExpression('1 + 1'), actionContext); + expect(await evaluator.evaluateAsInternal(BF.bindings())).toEqual(new IntegerLiteral(2)); }); }); }); diff --git a/packages/expression-evaluator/test/integration/evaluators/RecursiveEvaluator-test.ts b/packages/expression-evaluator/test/integration/evaluators/RecursiveEvaluator-test.ts index c160e6e005..a7a579a417 100644 --- a/packages/expression-evaluator/test/integration/evaluators/RecursiveEvaluator-test.ts +++ b/packages/expression-evaluator/test/integration/evaluators/RecursiveEvaluator-test.ts @@ -1,13 +1,14 @@ import { BindingsFactory } from '@comunica/bindings-factory'; import { LRUCache } from 'lru-cache'; import { DataFactory } from 'rdf-data-factory'; +import { translate } from 'sparqlalgebrajs'; import { expressionTypes, types } from 'sparqlalgebrajs/lib/algebra'; import { Wildcard } from 'sparqljs'; import { AsyncRecursiveEvaluator } from '../../../lib/evaluators/evaluatorHelpers/AsyncRecursiveEvaluator'; -import { SyncRecursiveEvaluator } from '../../../lib/evaluators/evaluatorHelpers/SyncRecursiveEvaluator'; import { ExpressionType } from '../../../lib/expressions'; import * as E from '../../../lib/expressions'; import * as Err from '../../../lib/util/Errors'; +import { getMockEEActionContext, getMockEEFactory } from '../../util/utils'; const BF = new BindingsFactory(); const DF = new DataFactory(); @@ -15,107 +16,6 @@ const DF = new DataFactory(); describe('recursive evaluators', () => { const defaultTimeZone = { zoneMinutes: 0, zoneHours: 0 }; - describe('SyncRecursiveEvaluator', () => { - const evaluator = new SyncRecursiveEvaluator({ - now: new Date(), - functionArgumentsCache: {}, - superTypeProvider: { - cache: new LRUCache({ max: 1_000 }), - discoverer: _ => 'term', - }, - defaultTimeZone, - }); - - it('is able to evaluate operator', () => { - expect(evaluator.evaluate(new E.IntegerLiteral(1), BF.bindings())).toEqual(new E.IntegerLiteral(1)); - }); - - it('is not able to evaluate existence by default', () => { - expect(() => evaluator.evaluate(new E.Existence({ - type: types.EXPRESSION, - expressionType: expressionTypes.EXISTENCE, - not: false, - input: { - type: types.VALUES, - variables: [], - bindings: [], - }, - }), BF.bindings())).toThrow(Err.NoExistenceHook); - }); - - it('is able to evaluate existence if configured', () => { - const customEvaluator = new SyncRecursiveEvaluator({ - now: new Date(), - functionArgumentsCache: {}, - superTypeProvider: { - cache: new LRUCache({ max: 1_000 }), - discoverer: _ => 'term', - }, - exists: _ => true, - defaultTimeZone, - }); - - expect(customEvaluator.evaluate(new E.Existence({ - type: types.EXPRESSION, - expressionType: expressionTypes.EXISTENCE, - not: false, - input: { - type: types.VALUES, - variables: [], - bindings: [], - }, - }), BF.bindings())).toEqual(new E.BooleanLiteral(true)); - }); - - it('is not able to evaluate aggregates by default', () => { - expect(() => evaluator.evaluate(new E.Aggregate('count', { - type: types.EXPRESSION, - expressionType: expressionTypes.AGGREGATE, - aggregator: 'count', - distinct: false, - expression: { - type: types.EXPRESSION, - expressionType: expressionTypes.WILDCARD, - wildcard: new Wildcard(), - }, - }), BF.bindings())).toThrow(Err.NoAggregator); - }); - - it('is able to evaluate aggregates if configured', () => { - const customEvaluator = new SyncRecursiveEvaluator({ - now: new Date(), - functionArgumentsCache: {}, - superTypeProvider: { - cache: new LRUCache({ max: 1_000 }), - discoverer: _ => 'term', - }, - aggregate: _ => DF.literal('42'), - defaultTimeZone, - }); - - expect(customEvaluator.evaluate(new E.Aggregate('count', { - type: types.EXPRESSION, - expressionType: expressionTypes.AGGREGATE, - aggregator: 'count', - distinct: false, - expression: { - type: types.EXPRESSION, - expressionType: expressionTypes.WILDCARD, - wildcard: new Wildcard(), - }, - }), BF.bindings())).toEqual(new E.StringLiteral('42')); - }); - - it('is not able to evaluate async extensions', () => { - expect(() => evaluator.evaluate({ - expressionType: ExpressionType.AsyncExtension, - name: DF.namedNode('http://example.com'), - async apply(_) { throw new Error('Error'); }, - args: [], - }, BF.bindings())).toThrow(Err.InvalidExpressionType); - }); - }); - describe('AsyncRecursiveEvaluator', () => { const evaluator = new AsyncRecursiveEvaluator({ now: new Date(), @@ -125,7 +25,9 @@ describe('recursive evaluators', () => { discoverer: _ => 'term', }, defaultTimeZone, - }); + actionContext: getMockEEActionContext(), + }, getMockEEFactory().createEvaluator(translate('SELECT * WHERE { ?s ?p ?o FILTER (1 + 1)}').input.expression, + getMockEEActionContext())); it('is able to evaluate operator', async() => { expect(await evaluator.evaluate(new E.IntegerLiteral(1), BF.bindings())).toEqual(new E.IntegerLiteral(1)); @@ -154,7 +56,9 @@ describe('recursive evaluators', () => { }, exists: async _ => true, defaultTimeZone, - }); + actionContext: getMockEEActionContext(), + }, getMockEEFactory().createEvaluator(translate('SELECT * WHERE { ?s ?p ?o FILTER (1 + 1)}').input.expression, + getMockEEActionContext())); expect(await customEvaluator.evaluate(new E.Existence({ type: types.EXPRESSION, @@ -192,7 +96,9 @@ describe('recursive evaluators', () => { }, aggregate: async _ => DF.literal('42'), defaultTimeZone, - }); + actionContext: getMockEEActionContext(), + }, getMockEEFactory().createEvaluator(translate('SELECT * WHERE { ?s ?p ?o FILTER (1 + 1)}').input.expression, + getMockEEActionContext())); expect(await customEvaluator.evaluate(new E.Aggregate('count', { type: types.EXPRESSION, diff --git a/packages/expression-evaluator/test/integration/functions/extension-test.ts b/packages/expression-evaluator/test/integration/functions/extension-test.ts index 0705a527eb..5f27f4bbeb 100644 --- a/packages/expression-evaluator/test/integration/functions/extension-test.ts +++ b/packages/expression-evaluator/test/integration/functions/extension-test.ts @@ -1,9 +1,11 @@ import { BindingsFactory } from '@comunica/bindings-factory'; import type * as RDF from '@rdfjs/types'; import { DataFactory } from 'rdf-data-factory'; -import type { SyncExtensionFunctionCreator } from '../../../lib/evaluators/SyncEvaluator'; +import type { + AsyncExtensionFunctionCreator, + IAsyncEvaluatorContext, +} from '../../../lib/evaluators/ExpressionEvaluator'; import { bool, merge, numeric } from '../../util/Aliases'; -import type { GeneralEvaluationConfig } from '../../util/generalEvaluation'; import { generalEvaluate } from '../../util/generalEvaluation'; import { Notation } from '../../util/TestTable'; import { runTestTable } from '../../util/utils'; @@ -12,9 +14,9 @@ const BF = new BindingsFactory(); describe('extension functions:', () => { describe('term-equal', () => { - const extensionFunctions: SyncExtensionFunctionCreator = (functionNamedNode: RDF.NamedNode) => { + const extensionFunctions: AsyncExtensionFunctionCreator = (functionNamedNode: RDF.NamedNode) => { if (functionNamedNode.value === 'https://example.org/functions#equal') { - return (args: RDF.Term[]) => { + return async(args: RDF.Term[]) => { const res = args[0].equals(args[1]); const DF = new DataFactory(); const booleanType = DF.namedNode('http://www.w3.org/2001/XMLSchema#boolean'); @@ -25,22 +27,20 @@ describe('extension functions:', () => { }; } if (functionNamedNode.value === 'https://example.org/functions#bad') { - return (args: RDF.Term[]) => { + return async(args: RDF.Term[]) => { throw new Error('error'); }; } }; describe('Can be evaluated', () => { - const generalEvaluationConfig: GeneralEvaluationConfig = { type: 'sync', - config: { - extensionFunctionCreator: extensionFunctions, - }}; runTestTable({ arity: 2, notation: Notation.Function, operation: '', - config: generalEvaluationConfig, + legacyContext: { + extensionFunctionCreator: extensionFunctions, + }, aliases: merge(numeric, bool), testTable: ` 3i 3i = true @@ -102,15 +102,14 @@ describe('extension functions:', () => { }); describe('throws error when providing a failing implementation', () => { - const generalEvaluationConfig: GeneralEvaluationConfig = { type: 'sync', - config: { - extensionFunctionCreator: extensionFunctions, - }}; + const legacyContext: Partial = { + extensionFunctionCreator: extensionFunctions, + }; runTestTable({ arity: 1, notation: Notation.Function, operation: '', - config: generalEvaluationConfig, + legacyContext, aliases: merge(numeric, bool), errorTable: ` 3i = 'Error thrown in https://example.org/functions#bad' @@ -126,7 +125,7 @@ describe('extension functions:', () => { }`; const DF = new DataFactory(); const stringType = DF.namedNode('http://www.w3.org/2001/XMLSchema#string'); - const creator = () => (args: RDF.Term[]) => { + const creator = () => async(args: RDF.Term[]) => { const arg = args[0]; if (arg.termType === 'Literal' && arg.datatype.equals(DF.literal('', stringType).datatype)) { return DF.literal(arg.value.toUpperCase(), stringType); @@ -136,12 +135,11 @@ describe('extension functions:', () => { const bindings = BF.bindings([ [ DF.variable('o'), DF.literal('AppLe', stringType) ], ]); - const generalEvaluationConfig: GeneralEvaluationConfig = { - type: 'sync', - config: { extensionFunctionCreator: creator }, + const legacyContext: Partial = { + extensionFunctionCreator: creator, }; const evaluated = await generalEvaluate({ - expression: complexQuery, expectEquality: true, generalEvaluationConfig, bindings, + expression: complexQuery, expectEquality: true, legacyContext, bindings, }); expect(evaluated.asyncResult).toEqual(DF.literal('APPLE', stringType)); }); diff --git a/packages/expression-evaluator/test/integration/functions/onStrings-test.ts b/packages/expression-evaluator/test/integration/functions/onStrings-test.ts index 996174080c..a7cca71eca 100644 --- a/packages/expression-evaluator/test/integration/functions/onStrings-test.ts +++ b/packages/expression-evaluator/test/integration/functions/onStrings-test.ts @@ -24,15 +24,12 @@ describe('string functions', () => { }); runTestTable({ ...baseConfig, - config: { - type: 'sync', - config: { - getSuperType(unknownType) { - if (unknownType.includes('specialString')) { - return 'https://example.org/string'; - } - return TypeURL.XSD_STRING; - }, + legacyContext: { + getSuperType(unknownType) { + if (unknownType.includes('specialString')) { + return 'https://example.org/string'; + } + return TypeURL.XSD_STRING; }, }, testTable: ` @@ -171,11 +168,8 @@ describe('string functions', () => { arity: 'vary', operation: 'substr', notation: Notation.Function, - config: { - type: 'sync', - config: { - getSuperType: unknownType => TypeURL.XSD_STRING, - }, + legacyContext: { + getSuperType: unknownType => TypeURL.XSD_STRING, }, testTable: ` "bar" 1 1 = "b" diff --git a/packages/expression-evaluator/test/integration/functions/op.addition-test.ts b/packages/expression-evaluator/test/integration/functions/op.addition-test.ts index 1a94300e5e..f4483b6f95 100644 --- a/packages/expression-evaluator/test/integration/functions/op.addition-test.ts +++ b/packages/expression-evaluator/test/integration/functions/op.addition-test.ts @@ -55,11 +55,8 @@ describe('evaluation of \'+\' like', () => { }); runTestTable({ ...baseConfig, - config: { - type: 'sync', - config: { - getSuperType: unknownType => TypeURL.XSD_INTEGER, - }, + legacyContext: { + getSuperType: unknownType => TypeURL.XSD_INTEGER, }, testTable: ` "2"^^example:int "3"^^example:int = ${int('5')} diff --git a/packages/expression-evaluator/test/integration/functions/op.bnode-test.ts b/packages/expression-evaluator/test/integration/functions/op.bnode-test.ts index 90eccd3dcb..c21e11a9f7 100644 --- a/packages/expression-evaluator/test/integration/functions/op.bnode-test.ts +++ b/packages/expression-evaluator/test/integration/functions/op.bnode-test.ts @@ -1,17 +1,18 @@ import { DataFactory } from 'rdf-data-factory'; -import type { ISyncEvaluatorContext } from '../../../lib/evaluators/SyncEvaluator'; +import type { IAsyncEvaluatorContext } from '../../../lib/evaluators/ExpressionEvaluator'; import { Notation } from '../../util/TestTable'; import { runTestTable } from '../../util/utils'; const DF = new DataFactory(); describe('evaluations of \'bnode\' with custom blank node generator function', () => { - const config: ISyncEvaluatorContext = { - bnode: (input?: string) => DF.blankNode(`${input || 'b'}cd`), + const legacyContext: Partial = { + bnode: async(input?: string) => DF.blankNode(`${input || 'b'}cd`), }; + runTestTable({ operation: 'BNODE', - config: { type: 'sync', config }, + legacyContext, arity: 1, notation: Notation.Function, testTable: ` @@ -26,7 +27,7 @@ describe('evaluations of \'bnode\' with custom blank node generator function', ( runTestTable({ operation: 'bnode', - config: { type: 'sync', config }, + legacyContext, arity: 1, notation: Notation.Function, testTable: ` diff --git a/packages/expression-evaluator/test/integration/functions/op.bound-test.ts b/packages/expression-evaluator/test/integration/functions/op.bound-test.ts index b5478494f2..dc4f784002 100644 --- a/packages/expression-evaluator/test/integration/functions/op.bound-test.ts +++ b/packages/expression-evaluator/test/integration/functions/op.bound-test.ts @@ -1,10 +1,10 @@ import { BindingsFactory } from '@comunica/bindings-factory'; import { DataFactory } from 'rdf-data-factory'; import { expressionTypes, types } from 'sparqlalgebrajs/lib/algebra'; -import { SyncEvaluator } from '../../../lib/evaluators/SyncEvaluator'; import { TypeURL as DT } from '../../../lib/util/Consts'; import * as Err from '../../../lib/util/Errors'; import { generalEvaluate } from '../../util/generalEvaluation'; +import { getMockEEActionContext, getMockEEFactory } from '../../util/utils'; const DF = new DataFactory(); const BF = new BindingsFactory(); @@ -29,7 +29,7 @@ describe('evaluation of \'bound\'', () => { }); it('\'bound\' on term returns error', async() => { - const evaluator = new SyncEvaluator({ + const evaluator = getMockEEFactory().createEvaluator({ type: types.EXPRESSION, expressionType: expressionTypes.OPERATOR, operator: 'bound', @@ -38,7 +38,7 @@ describe('evaluation of \'bound\'', () => { expressionType: expressionTypes.TERM, term: DF.namedNode('http://example.com'), }], - }); - expect(() => evaluator.evaluate(BF.bindings())).toThrow(Err.InvalidArgumentTypes); + }, getMockEEActionContext()); + await expect(evaluator.evaluate(BF.bindings())).rejects.toThrow(Err.InvalidArgumentTypes); }); }); diff --git a/packages/expression-evaluator/test/integration/functions/op.division-test.ts b/packages/expression-evaluator/test/integration/functions/op.division-test.ts index 799e078228..a6b98e11e6 100644 --- a/packages/expression-evaluator/test/integration/functions/op.division-test.ts +++ b/packages/expression-evaluator/test/integration/functions/op.division-test.ts @@ -41,11 +41,8 @@ describe('evaluation of \'/\' like', () => { }); runTestTable({ ...config, - config: { - type: 'sync', - config: { - getSuperType: unknownType => TypeURL.XSD_INTEGER, - }, + legacyContext: { + getSuperType: unknownType => TypeURL.XSD_INTEGER, }, testTable: ` "2"^^example:int "2"^^example:int = ${decimal('1')} diff --git a/packages/expression-evaluator/test/integration/functions/op.equality-test.ts b/packages/expression-evaluator/test/integration/functions/op.equality-test.ts index aff12d0992..a3a5518283 100644 --- a/packages/expression-evaluator/test/integration/functions/op.equality-test.ts +++ b/packages/expression-evaluator/test/integration/functions/op.equality-test.ts @@ -40,18 +40,18 @@ describe('evaluation of \'=\'', () => { 3f NaN = false `, }); - runTestTable({ - ...config, - config: { - type: 'sync', - config: { + + describe('with numeric and type discovery like', () => { + runTestTable({ + ...config, + legacyContext: { getSuperType: unknownType => TypeURL.XSD_INTEGER, }, - }, - testTable: ` + testTable: ` "2"^^example:int "2"^^example:int = true "2"^^example:int "3"^^example:int = false `, + }); }); }); diff --git a/packages/expression-evaluator/test/integration/functions/op.lesserThan-test.ts b/packages/expression-evaluator/test/integration/functions/op.lesserThan-test.ts index b73446bd4c..d6183b6712 100644 --- a/packages/expression-evaluator/test/integration/functions/op.lesserThan-test.ts +++ b/packages/expression-evaluator/test/integration/functions/op.lesserThan-test.ts @@ -121,11 +121,8 @@ describe('evaluation of \'<\'', () => { arity: 2, notation: Notation.Infix, aliases: bool, - config: { - config: { - defaultTimeZone: { zoneHours: -5, zoneMinutes: 0 }, - }, - type: 'sync', + legacyContext: { + defaultTimeZone: { zoneHours: -5, zoneMinutes: 0 }, }, testTable: ` '${timeTyped('12:00:00')}' '${timeTyped('23:00:00+06:00')}' = false diff --git a/packages/expression-evaluator/test/integration/functions/op.lesserThanEqual-test.ts b/packages/expression-evaluator/test/integration/functions/op.lesserThanEqual-test.ts index a1fb2d0bfe..74645578f5 100644 --- a/packages/expression-evaluator/test/integration/functions/op.lesserThanEqual-test.ts +++ b/packages/expression-evaluator/test/integration/functions/op.lesserThanEqual-test.ts @@ -143,11 +143,8 @@ describe('evaluation of \'<=\'', () => { arity: 2, notation: Notation.Infix, aliases: bool, - config: { - config: { - defaultTimeZone: { zoneHours: -5, zoneMinutes: 0 }, - }, - type: 'sync', + legacyContext: { + defaultTimeZone: { zoneHours: -5, zoneMinutes: 0 }, }, testTable: ` '${timeTyped('12:00:00')}' '${timeTyped('23:00:00+06:00')}' = true diff --git a/packages/expression-evaluator/test/integration/misc/Exists-test.ts b/packages/expression-evaluator/test/integration/misc/Exists-test.ts index 6860e47f9d..960455c9a1 100644 --- a/packages/expression-evaluator/test/integration/misc/Exists-test.ts +++ b/packages/expression-evaluator/test/integration/misc/Exists-test.ts @@ -6,34 +6,13 @@ import fn = jest.fn; const DF = new DataFactory(); describe('exists', () => { - it('runs with mock existence hooks', async() => { - const hookMock = fn(() => true); - const evaluated = await generalEvaluate({ - expression: template('EXISTS {?s ?p ?o}'), - expectEquality: true, - generalEvaluationConfig: { - type: 'sync', - config: { - exists: hookMock, - }, - }, - }); - // Called 2 times (once by sync and once by async) - // We will check if async truly cals only once. - // We need to double this because of the type system tests - expect(hookMock).toBeCalledTimes(2); - expect(evaluated.asyncResult).toEqual(DF.literal('true', DF.namedNode('http://www.w3.org/2001/XMLSchema#boolean'))); - }); it('rus with mock existence hooks and async calls but once', async() => { const hookMock = fn(() => Promise.resolve(true)); const evaluated = await generalEvaluate({ expression: template('EXISTS {?s ?p ?o}'), expectEquality: true, - generalEvaluationConfig: { - type: 'async', - config: { - exists: hookMock, - }, + legacyContext: { + exists: hookMock, }, }); // We need to double this because of the type system tests diff --git a/packages/expression-evaluator/test/integration/transformers/AlgebraTransformer-test.ts b/packages/expression-evaluator/test/integration/transformers/AlgebraTransformer-test.ts index 608eae8778..03b9e227d0 100644 --- a/packages/expression-evaluator/test/integration/transformers/AlgebraTransformer-test.ts +++ b/packages/expression-evaluator/test/integration/transformers/AlgebraTransformer-test.ts @@ -4,7 +4,7 @@ import { Wildcard } from 'sparqljs'; import * as E from '../../../lib/expressions'; import { AlgebraTransformer } from '../../../lib/transformers/AlgebraTransformer'; import * as Err from '../../../lib/util/Errors'; -import { getDefaultSharedContext } from '../../util/utils'; +import { getDefaultSharedContext, getMockEEActionContext, getMockEEFactory, getMockExpression } from '../../util/utils'; const DF = new DataFactory(); @@ -12,10 +12,9 @@ describe('AlgebraTransformer', () => { let algebraTransformer: AlgebraTransformer; beforeEach(() => { algebraTransformer = new AlgebraTransformer({ - creator: _ => args => DF.namedNode('http://example.com'), - type: 'sync', + creator: _ => async args => DF.namedNode('http://example.com'), ...getDefaultSharedContext(), - }); + }, getMockEEFactory().createEvaluator(getMockExpression('1+1'), getMockEEActionContext())); }); it('transform term', () => { diff --git a/packages/expression-evaluator/test/integration/transformers/TermTransformer-test.ts b/packages/expression-evaluator/test/integration/transformers/TermTransformer-test.ts index f40c106972..043e49f651 100644 --- a/packages/expression-evaluator/test/integration/transformers/TermTransformer-test.ts +++ b/packages/expression-evaluator/test/integration/transformers/TermTransformer-test.ts @@ -83,7 +83,7 @@ describe('TermTransformer', () => { }); it('default graph', () => { - expect(() => termTransformer.transformRDFTermUnsafe(DF.defaultGraph())).toThrow(Err.InvalidTermType); + expect(termTransformer.transformRDFTermUnsafe(DF.defaultGraph())).toEqual(new E.DefaultGraph()); }); it('null', () => { diff --git a/packages/expression-evaluator/test/integration/util/Ordering-test.ts b/packages/expression-evaluator/test/integration/util/Ordering-test.ts index 1a1857f0c6..06bafd50da 100644 --- a/packages/expression-evaluator/test/integration/util/Ordering-test.ts +++ b/packages/expression-evaluator/test/integration/util/Ordering-test.ts @@ -1,9 +1,9 @@ import type * as RDF from '@rdfjs/types'; import { DataFactory } from 'rdf-data-factory'; -import { orderTypes } from '../../../lib'; import { TypeURL, TypeURL as DT } from '../../../lib/util/Consts'; import type { SuperTypeCallback } from '../../../lib/util/TypeHandling'; +import { getMockEEActionContext, getMockEEFactory, getMockExpression } from '../../util/utils'; const DF = new DataFactory(); @@ -33,8 +33,12 @@ function dateTime(value: string): RDF.Literal { function orderTestIsLower(litA: RDF.Term | undefined, litB: RDF.Term | undefined, typeDiscoveryCallback?: SuperTypeCallback) { - expect(orderTypes(litA, litB, false, typeDiscoveryCallback)).toEqual(-1); - expect(orderTypes(litB, litA, false, typeDiscoveryCallback)).toEqual(1); + const evaluator = getMockEEFactory() + .createEvaluator(getMockExpression('1+1'), getMockEEActionContext(), { + getSuperType: typeDiscoveryCallback, + }); + expect(evaluator.orderTypes(litA, litB, false)).toEqual(-1); + expect(evaluator.orderTypes(litB, litA, false)).toEqual(1); } function genericOrderTestLower(litA: RDF.Term | undefined, litB: RDF.Term | undefined, @@ -43,8 +47,10 @@ function genericOrderTestLower(litA: RDF.Term | undefined, litB: RDF.Term | unde } function orderTestIsEqual(litA: RDF.Term | undefined, litB: RDF.Term | undefined) { - expect(orderTypes(litA, litB)).toEqual(0); - expect(orderTypes(litB, litA)).toEqual(0); + const evaluator = getMockEEFactory() + .createEvaluator(getMockExpression('1+1'), getMockEEActionContext()); + expect(evaluator.orderTypes(litA, litB)).toEqual(0); + expect(evaluator.orderTypes(litB, litA)).toEqual(0); } describe('terms order', () => { diff --git a/packages/expression-evaluator/test/spec/iri01-spec-test.ts b/packages/expression-evaluator/test/spec/iri01-spec-test.ts index e8843b1819..9621228122 100644 --- a/packages/expression-evaluator/test/spec/iri01-spec-test.ts +++ b/packages/expression-evaluator/test/spec/iri01-spec-test.ts @@ -1,10 +1,12 @@ +import { KeysInitQuery } from '@comunica/context-entries'; +import { ActionContext } from '@comunica/core'; import { Notation } from '../util/TestTable'; import type { ITestTableConfigBase } from '../util/utils'; import { runTestTable } from '../util/utils'; describe('We should respect the iri01 spec', () => { const config: ITestTableConfigBase = { - config: { type: 'sync', config: { baseIRI: 'http://example.org' }}, + config: new ActionContext().set(KeysInitQuery.baseIRI, 'http://example.org'), arity: 1, operation: '', notation: Notation.Function, diff --git a/packages/expression-evaluator/test/util/TestTable.ts b/packages/expression-evaluator/test/util/TestTable.ts index b5c3856422..ea10c84620 100644 --- a/packages/expression-evaluator/test/util/TestTable.ts +++ b/packages/expression-evaluator/test/util/TestTable.ts @@ -36,19 +36,25 @@ abstract class Table { public abstract test(): void; protected async testExpression(expr: string, result: string) { - const { config, additionalPrefixes } = this.def; + const { config, additionalPrefixes, legacyContext } = this.def; const aliases = this.def.aliases || {}; result = aliases[result] || result; const evaluated = await generalEvaluate({ - expression: template(expr, additionalPrefixes), expectEquality: true, generalEvaluationConfig: config, + expression: template(expr, additionalPrefixes), + expectEquality: true, + generalEvaluationConfig: config, + legacyContext, }); expect(evaluated.asyncResult).toEqual(stringToTermPrefix(result, additionalPrefixes)); } protected async testErrorExpression(expr: string, error: string) { - const { config, additionalPrefixes } = this.def; + const { config, additionalPrefixes, legacyContext } = this.def; const result = await generalErrorEvaluation({ - expression: template(expr, additionalPrefixes), expectEquality: false, generalEvaluationConfig: config, + expression: template(expr, additionalPrefixes), + expectEquality: false, + generalEvaluationConfig: config, + legacyContext, }); expect(result).not.toBeUndefined(); expect(() => { throw result?.asyncError; }).toThrow(error); diff --git a/packages/expression-evaluator/test/util/generalEvaluation.ts b/packages/expression-evaluator/test/util/generalEvaluation.ts index a9e5bbddcb..6318b8980f 100644 --- a/packages/expression-evaluator/test/util/generalEvaluation.ts +++ b/packages/expression-evaluator/test/util/generalEvaluation.ts @@ -1,115 +1,52 @@ import { BindingsFactory } from '@comunica/bindings-factory'; +import type { IActionContext } from '@comunica/types'; import type * as RDF from '@rdfjs/types'; -import { termToString } from 'rdf-string'; -import type { Algebra as Alg } from 'sparqlalgebrajs'; import { translate } from 'sparqlalgebrajs'; -import { AsyncEvaluator, SyncEvaluator } from '../../lib'; -import type { IAsyncEvaluatorContext, AsyncExtensionFunctionCreator } from '../../lib/evaluators/ExpressionEvaluator'; -import type { ISyncEvaluatorContext, SyncExtensionFunctionCreator } from '../../lib/evaluators/SyncEvaluator'; +import type { IAsyncEvaluatorContext } from '../../lib/evaluators/ExpressionEvaluator'; +import { getMockEEActionContext, getMockEEFactory } from './utils'; const BF = new BindingsFactory(); -export type GeneralEvaluationConfig = { type: 'sync'; config: ISyncEvaluatorContext } | -{ type: 'async'; config: IAsyncEvaluatorContext }; - export interface IGeneralEvaluationArg { bindings?: RDF.Bindings; expression: string; - generalEvaluationConfig?: GeneralEvaluationConfig; + generalEvaluationConfig?: IActionContext; /** * Boolean pointing out if the result of async and sync evaluation should be the same. * Default: Check / true */ expectEquality?: boolean; + + // TODO: remove legacyContext in *final* update (probably when preparing the EE for function bussification) + legacyContext?: Partial; } export async function generalEvaluate(arg: IGeneralEvaluationArg): Promise<{ asyncResult: RDF.Term; syncResult?: RDF.Term }> { const bindings: RDF.Bindings = arg.bindings ? arg.bindings : BF.bindings(); - if (arg.generalEvaluationConfig?.type === 'async') { - const asyncResult = await evaluateAsync(arg.expression, bindings, arg.generalEvaluationConfig.config); - return { asyncResult }; - } - const syncConfig = arg.generalEvaluationConfig?.config; - const convertedConfig = syncConfigToAsyncConfig(syncConfig); const asyncResult = await evaluateAsync( arg.expression, bindings, - convertedConfig, + arg.generalEvaluationConfig || getMockEEActionContext(), + arg.legacyContext, ); - const syncResult = evaluateSync(arg.expression, bindings, syncConfig); - if (arg.expectEquality || arg.expectEquality === undefined) { - expect(termToString(asyncResult)).toEqual(termToString(syncResult)); - } - return { asyncResult, syncResult }; + return { asyncResult }; } export async function generalErrorEvaluation(arg: IGeneralEvaluationArg): Promise<{ asyncError: unknown; syncError?: unknown } | undefined > { const bindings: RDF.Bindings = arg.bindings ? arg.bindings : BF.bindings(); - if (arg.generalEvaluationConfig?.type === 'async') { - try { - await evaluateAsync(arg.expression, bindings, arg.generalEvaluationConfig.config); - return undefined; - } catch (error: unknown) { - return { asyncError: error }; - } - } - const res: { asyncError: unknown; syncError?: unknown } = Object.create(null); - const syncConfig = arg.generalEvaluationConfig?.config; try { await evaluateAsync( arg.expression, bindings, - syncConfigToAsyncConfig(syncConfig), + arg.generalEvaluationConfig || getMockEEActionContext(), + arg.legacyContext, ); return undefined; } catch (error: unknown) { - res.asyncError = error; - } - try { - evaluateSync(arg.expression, bindings, syncConfig); - return undefined; - } catch (error: unknown) { - res.syncError = error; - } - if (arg.expectEquality || arg.expectEquality === undefined) { - expect(res.asyncError).toEqual(res.syncError); + return { asyncError: error }; } - return res; -} - -function syncConfigToAsyncConfig(config: ISyncEvaluatorContext | undefined): IAsyncEvaluatorContext | undefined { - if (!config) { - return undefined; - } - const asyncExists = config.exists ? - async(e: Alg.ExistenceExpression, m: RDF.Bindings) => config.exists!(e, m) : - undefined; - const asyncAggregate = config.aggregate ? - async(expression: Alg.AggregateExpression) => config.aggregate!(expression) : - undefined; - const asyncBnode = config.bnode ? async(input?: string) => config.bnode!(input) : undefined; - const asyncExtensionFunctionCreator = syncCallbackWrapper(config.extensionFunctionCreator); - return { - ...config, - exists: asyncExists, - aggregate: asyncAggregate, - bnode: asyncBnode, - extensionFunctionCreator: asyncExtensionFunctionCreator, - }; -} - -function syncCallbackWrapper(f: SyncExtensionFunctionCreator | undefined): AsyncExtensionFunctionCreator | undefined { - if (!f) - { return undefined; } - return (namedNode: RDF.NamedNode) => { - const func = f(namedNode); - if (!func) { - return; - } - return (args: RDF.Term[]) => Promise.resolve(func(args)); - }; } function parse(query: string) { @@ -118,12 +55,8 @@ function parse(query: string) { return sparqlQuery.input.expression; } -function evaluateAsync(expr: string, bindings: RDF.Bindings, config?: IAsyncEvaluatorContext): Promise { - const evaluator = new AsyncEvaluator(parse(expr), config); - return evaluator.evaluate(bindings); -} - -function evaluateSync(expr: string, bindings: RDF.Bindings, config?: ISyncEvaluatorContext): RDF.Term { - const evaluator = new SyncEvaluator(parse(expr), config); +function evaluateAsync(expr: string, bindings: RDF.Bindings, actionContext: IActionContext, + legacyContext?: Partial): Promise { + const evaluator = getMockEEFactory().createEvaluator(parse(expr), actionContext, legacyContext); return evaluator.evaluate(bindings); } diff --git a/packages/expression-evaluator/test/util/utils.ts b/packages/expression-evaluator/test/util/utils.ts index fac318249b..8be9334bac 100644 --- a/packages/expression-evaluator/test/util/utils.ts +++ b/packages/expression-evaluator/test/util/utils.ts @@ -1,10 +1,36 @@ +import { ActionContext, Bus } from '@comunica/core'; +import type { IActionContext } from '@comunica/types'; import { LRUCache } from 'lru-cache'; -import type { ICompleteSharedContext } from '../../lib/evaluators/evaluatorHelpers/BaseExpressionEvaluator'; +import type { Algebra as Alg } from 'sparqlalgebrajs'; +import { translate } from 'sparqlalgebrajs'; +import { ExpressionEvaluatorFactory } from '../../lib'; +import type { ICompleteEEContext } from '../../lib/evaluators/evaluatorHelpers/AsyncRecursiveEvaluator'; +import type { IAsyncEvaluatorContext } from '../../lib/evaluators/ExpressionEvaluator'; import type { AliasMap } from './Aliases'; -import type { GeneralEvaluationConfig } from './generalEvaluation'; import type { Notation } from './TestTable'; import { ArrayTable, BinaryTable, UnaryTable, VariableTable } from './TestTable'; +export function getMockEEActionContext(): IActionContext { + return new ActionContext({}); +} + +export function getMockEEFactory(): ExpressionEvaluatorFactory { + const bus: any = new Bus({ name: 'bus' }); + + const mediatorQueryOperation: any = { + async mediate(arg: any) { return {}; }, + }; + + return new ExpressionEvaluatorFactory({ + mediatorQueryOperation, + mediatorBindingsAggregatorFactory: mediatorQueryOperation, + }); +} + +export function getMockExpression(expr: string): Alg.Expression { + return translate(`SELECT * WHERE { ?s ?p ?o FILTER (${expr})}`).input.expression; +} + export interface ITestTableConfigBase { /** * Operation / function that needs to be called on the arguments provided in the TestTable. @@ -20,7 +46,9 @@ export interface ITestTableConfigBase { * Configuration that'll we provided to the Evaluator. * If the type is sync, the test will be preformed both sync and async. */ - config?: GeneralEvaluationConfig; + config?: IActionContext; + // TODO: remove legacyContext in *final* update (probably when preparing the EE for function bussification) + legacyContext?: Partial; aliases?: AliasMap; /** * Additional prefixes can be provided if the defaultPrefixes in ./Aliases.ts are not enough. @@ -68,8 +96,9 @@ export function runTestTable(arg: TestTableConfig): void { testTable.test(); } -export function getDefaultSharedContext(): ICompleteSharedContext { +export function getDefaultSharedContext(actionContext?: IActionContext): ICompleteEEContext { return { + actionContext: actionContext || getMockEEActionContext(), now: new Date(), superTypeProvider: { cache: new LRUCache({ max: 1_000 }),