diff --git a/__test_utils__/util.ts b/__test_utils__/util.ts index a2047ff2..80604a39 100644 --- a/__test_utils__/util.ts +++ b/__test_utils__/util.ts @@ -3,6 +3,7 @@ import type { Quad } from '@rdfjs/types'; import 'jest-rdf'; import { DataFactory, Parser, Store } from 'n3'; import { data, dataStar, query, queryAll, result } from '../data/socrates'; +import { querySemantics, dataSemantics, resultSemantics } from '../data/semantics'; import { n3reasoner } from '../dist'; import { data as blogicData, result as blogicResult } from '../data/blogic'; import { data as regexData, result as regexResult } from '../data/regex'; @@ -18,6 +19,9 @@ export const dataQuads = parser.parse(data); export const dataStarQuads = parser.parse(dataStar); export const resultQuads = parser.parse(result); export const resultBlogicQuads = parser.parse(blogicResult); +export const querySemanticsQuads = parser.parse(querySemantics); +export const dataSemanticsQuads = parser.parse(dataSemantics); +export const resultSemanticsQuads = parser.parse(resultSemantics); export function mockFetch(...args: Parameters): ReturnType { switch (args[0]) { @@ -85,6 +89,10 @@ export function universalTests() { n3reasoner(dataQuads, queryQuads, { output: undefined }), ).resolves.toBeRdfIsomorphic(resultQuads)); + it('should execute the n3reasoner with log:semantics [quad input quad output] [output: undefined]', () => expect>( + n3reasoner(dataSemanticsQuads, querySemanticsQuads, { output: undefined }), + ).resolves.toBeRdfIsomorphic(resultSemanticsQuads)); + it('should execute the built-in "log:uuid".', async () => { const queryString = `@prefix : . @prefix log: . @@ -100,10 +108,9 @@ export function universalTests() { const outputQuads = parser.parse(output); expect(outputQuads.length).toBe(1); const createdUUID = outputQuads[0].object.value; - const uuidRegexMatch = createdUUID.match(/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gm) - expect(uuidRegexMatch).not.toBe(null) - expect(uuidRegexMatch![0]).toBe(createdUUID) - + const uuidRegexMatch = createdUUID.match(/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gm); + expect(uuidRegexMatch).not.toBe(null); + expect(uuidRegexMatch![0]).toBe(createdUUID); }) it('should execute the n3reasoner [quad input quad output] [output: deductive_closure]', () => expect>( diff --git a/data/semantics.ts b/data/semantics.ts new file mode 100644 index 00000000..71d2d646 --- /dev/null +++ b/data/semantics.ts @@ -0,0 +1,32 @@ +export const querySemantics = ` +@prefix : . +@prefix log: . + +{ :test :people ?people } => { :test :people ?people } . +`; + +export const dataSemantics = ` +@prefix : . +@prefix log: . + +{ + log:semantics ?people . +} +=> +{ + :test :people ?people +} +. +`; + +export const resultSemantics = ` +@prefix : . +@prefix log: . +@prefix ns1: . + +:test :people { + ns1:william a ns1:Person. + ns1:doerthe a ns1:Person. + ns1:gregg a ns1:Person. +}. +`;