@traqula/test-utils 0.0.23 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,91 +1,106 @@
1
1
  "use strict";
2
- var import_vitest = require("vitest");
3
- import_vitest.expect.extend({
4
- toEqualParsedQuery(received, expected) {
5
- const pass = objectsEqual(received, expected, () => false, []);
6
- const message = pass ? () => `${this.utils.matcherHint("toEqualParsedQuery")}
7
-
8
- Expected: ${this.utils.printExpected(expected)}
9
- Received: ${this.utils.printReceived(received)}` : () => {
10
- const diffString = this.utils.diff(expected, received, {
11
- expand: this.expand
12
- });
13
- return `${this.utils.matcherHint("toEqualParsedQuery")}
14
-
15
- ${diffString && diffString.includes("- Expect") ? `Difference:
16
-
17
- ${diffString}` : `Expected: ${this.utils.printExpected(expected)}
18
- Received: ${this.utils.printReceived(received)}`}`;
19
- };
20
- return { pass, message };
21
- },
22
- toEqualParsedQueryIgnoring(received, selector, ignoreKeys, expected) {
23
- const pass = objectsEqual(received, expected, selector, ignoreKeys);
24
- const message = pass ? () => `${this.utils.matcherHint("toEqualParsedQuery")}
25
-
26
- Expected: ${this.utils.printExpected(expected)}
27
- Received: ${this.utils.printReceived(received)}` : () => {
28
- const diffString = this.utils.diff(expected, received, {
29
- expand: this.expand
30
- });
31
- return `${this.utils.matcherHint("toEqualParsedQuery")}
32
-
33
- ${diffString && diffString.includes("- Expect") ? `Difference:
34
-
35
- ${diffString}` : `Expected: ${this.utils.printExpected(expected)}
36
- Received: ${this.utils.printReceived(received)}`}`;
37
- };
38
- return { pass, message };
39
- }
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ vitest_1.expect.extend({
5
+ toEqualParsedQuery(received, expected) {
6
+ const pass = objectsEqual(received, expected, () => false, []);
7
+ const message = pass ?
8
+ () => `${this.utils.matcherHint('toEqualParsedQuery')}\n\n` +
9
+ `Expected: ${this.utils.printExpected(expected)}\n` +
10
+ `Received: ${this.utils.printReceived(received)}` :
11
+ () => {
12
+ const diffString = this.utils.diff(expected, received, {
13
+ expand: this.expand,
14
+ });
15
+ return (`${this.utils.matcherHint('toEqualParsedQuery')}\n\n${diffString && diffString.includes('- Expect') ?
16
+ `Difference:\n\n${diffString}` :
17
+ `Expected: ${this.utils.printExpected(expected)}\n` +
18
+ `Received: ${this.utils.printReceived(received)}`}`);
19
+ };
20
+ return { pass, message };
21
+ },
22
+ toEqualParsedQueryIgnoring(received, selector, ignoreKeys, expected) {
23
+ const pass = objectsEqual(received, expected, selector, ignoreKeys);
24
+ const message = pass ?
25
+ () => `${this.utils.matcherHint('toEqualParsedQuery')}\n\n` +
26
+ `Expected: ${this.utils.printExpected(expected)}\n` +
27
+ `Received: ${this.utils.printReceived(received)}` :
28
+ () => {
29
+ const diffString = this.utils.diff(expected, received, {
30
+ expand: this.expand,
31
+ });
32
+ return (`${this.utils.matcherHint('toEqualParsedQuery')}\n\n${diffString && diffString.includes('- Expect') ?
33
+ `Difference:\n\n${diffString}` :
34
+ `Expected: ${this.utils.printExpected(expected)}\n` +
35
+ `Received: ${this.utils.printReceived(received)}`}`);
36
+ };
37
+ return { pass, message };
38
+ },
40
39
  });
40
+ // We cannot use native instanceOf to test whether expected is a Term!
41
41
  function objectsEqual(received, expected, selector, ignoreKeys) {
42
- if (received === void 0 || received === null || isPrimitive(received)) {
43
- return received === expected;
44
- }
45
- if (isTerm(received)) {
46
- return received.equals(expected);
47
- }
48
- if (isTerm(expected)) {
49
- return expected.equals(received);
50
- }
51
- if (Array.isArray(received)) {
52
- if (!Array.isArray(expected)) {
53
- return false;
42
+ if (received === undefined || received === null || isPrimitive(received)) {
43
+ return received === expected;
54
44
  }
55
- if (received.length !== expected.length) {
56
- return false;
45
+ if (isTerm(received)) {
46
+ // eslint-disable-next-line ts/ban-ts-comment
47
+ // @ts-expect-error TS2345
48
+ return received.equals(expected);
57
49
  }
58
- for (const [i, element] of received.entries()) {
59
- if (!objectsEqual(element, expected[i], selector, ignoreKeys)) {
60
- return false;
61
- }
50
+ if (isTerm(expected)) {
51
+ // eslint-disable-next-line ts/ban-ts-comment
52
+ // @ts-expect-error TS2345
53
+ return expected.equals(received);
62
54
  }
63
- } else {
64
- if (expected === void 0 || expected === null || isPrimitive(expected) || Array.isArray(expected)) {
65
- return false;
55
+ // York
56
+ // test
57
+ if (Array.isArray(received)) {
58
+ if (!Array.isArray(expected)) {
59
+ return false;
60
+ }
61
+ if (received.length !== expected.length) {
62
+ return false;
63
+ }
64
+ for (const [i, element] of received.entries()) {
65
+ if (!objectsEqual(element, expected[i], selector, ignoreKeys)) {
66
+ return false;
67
+ }
68
+ }
66
69
  }
67
- const keys_first = Object.keys(received);
68
- const receivedMatches = selector(received);
69
- for (const key of keys_first) {
70
- if (receivedMatches && ignoreKeys.includes(key)) {
71
- continue;
72
- }
73
- if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {
74
- return false;
75
- }
70
+ else {
71
+ // Received == object
72
+ if (expected === undefined || expected === null || isPrimitive(expected) || Array.isArray(expected)) {
73
+ return false;
74
+ }
75
+ const keys_first = Object.keys(received);
76
+ const receivedMatches = selector(received);
77
+ for (const key of keys_first) {
78
+ if (receivedMatches && ignoreKeys.includes(key)) {
79
+ continue;
80
+ }
81
+ // eslint-disable-next-line ts/ban-ts-comment
82
+ // @ts-expect-error TS7053
83
+ if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {
84
+ return false;
85
+ }
86
+ }
87
+ // We do this to make sure that we are not missing keys in the received object
88
+ const keys_second = Object.keys(expected);
89
+ for (const key of keys_second) {
90
+ // eslint-disable-next-line ts/ban-ts-comment
91
+ // @ts-expect-error TS7053
92
+ if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {
93
+ return false;
94
+ }
95
+ }
76
96
  }
77
- const keys_second = Object.keys(expected);
78
- for (const key of keys_second) {
79
- if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {
80
- return false;
81
- }
82
- }
83
- }
84
- return true;
97
+ return true;
85
98
  }
99
+ // If true, the value is a term. With ts annotation
86
100
  function isTerm(value) {
87
- return false;
101
+ return false;
88
102
  }
89
103
  function isPrimitive(value) {
90
- return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
104
+ return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
91
105
  }
106
+ //# sourceMappingURL=toEqualParsedQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toEqualParsedQuery.js","sourceRoot":"","sources":["../../../../lib/matchers/toEqualParsedQuery.ts"],"names":[],"mappings":";;AAAA,mCAAgC;AAEhC,eAAM,CAAC,MAAM,CAAC;IACZ,kBAAkB,CAAC,QAAiB,EAAE,QAAiB;QACrD,MAAM,IAAI,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC;YAClB,GAAG,EAAE,CACH,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,CAChD,MAAM;gBACN,aAAa,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI;gBACnD,aAAa,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACnD,GAAG,EAAE;gBACH,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE;oBACrD,MAAM,EAAE,IAAI,CAAC,MAAM;iBACpB,CAAC,CAAC;gBACH,OAAO,CACL,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,CAChD,OACA,UAAU,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;oBAC7C,kBAAkB,UAAU,EAAE,CAAC,CAAC;oBAChC,aAAa,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,IAA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,KAAK,CAAC;QACf,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,eAAe,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAE3C,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAC7B,IAAI,eAAe,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChD,SAAS;YACX,CAAC;YACD,6CAA6C;YAC7C,0BAA0B;YAC1B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;gBACtE,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,8EAA8E;QAC9E,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1C,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC9B,6CAA6C;YAC7C,0BAA0B;YAC1B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;gBACtE,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,mDAAmD;AACnD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,CAAC;AAC9F,CAAC","sourcesContent":["import { expect } from 'vitest';\n\nexpect.extend({\n toEqualParsedQuery(received: unknown, expected: unknown) {\n const pass = objectsEqual(received, expected, () => false, []);\n const message = pass ?\n () =>\n `${this.utils.matcherHint('toEqualParsedQuery')\n }\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(received)}` :\n () => {\n const diffString = this.utils.diff(expected, received, {\n expand: this.expand,\n });\n return (\n `${this.utils.matcherHint('toEqualParsedQuery')\n }\\n\\n${\n diffString && diffString.includes('- Expect') ?\n `Difference:\\n\\n${diffString}` :\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(received)}`}`\n );\n };\n\n return { pass, message };\n },\n toEqualParsedQueryIgnoring(\n received: unknown,\n selector: (obj: object) => boolean,\n ignoreKeys: string[],\n expected: unknown,\n ) {\n const pass = objectsEqual(received, expected, selector, ignoreKeys);\n const message = pass ?\n () =>\n `${this.utils.matcherHint('toEqualParsedQuery')\n }\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(received)}` :\n () => {\n const diffString = this.utils.diff(expected, received, {\n expand: this.expand,\n });\n return (\n `${this.utils.matcherHint('toEqualParsedQuery')\n }\\n\\n${\n diffString && diffString.includes('- Expect') ?\n `Difference:\\n\\n${diffString}` :\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(received)}`}`\n );\n };\n\n return { pass, message };\n },\n});\n\n// We cannot use native instanceOf to test whether expected is a Term!\nfunction objectsEqual(\n received: unknown,\n expected: unknown,\n selector: (obj: object) => boolean,\n ignoreKeys: string[],\n): boolean {\n if (received === undefined || received === null || isPrimitive(received)) {\n return received === expected;\n }\n\n if (isTerm(received)) {\n // eslint-disable-next-line ts/ban-ts-comment\n // @ts-expect-error TS2345\n return received.equals(expected);\n }\n if (isTerm(expected)) {\n // eslint-disable-next-line ts/ban-ts-comment\n // @ts-expect-error TS2345\n return expected.equals(received);\n }\n // York\n // test\n if (Array.isArray(received)) {\n if (!Array.isArray(expected)) {\n return false;\n }\n if (received.length !== expected.length) {\n return false;\n }\n for (const [ i, element ] of received.entries()) {\n if (!objectsEqual(element, expected[i], selector, ignoreKeys)) {\n return false;\n }\n }\n } else {\n // Received == object\n if (expected === undefined || expected === null || isPrimitive(expected) || Array.isArray(expected)) {\n return false;\n }\n const keys_first = Object.keys(received);\n const receivedMatches = selector(received);\n\n for (const key of keys_first) {\n if (receivedMatches && ignoreKeys.includes(key)) {\n continue;\n }\n // eslint-disable-next-line ts/ban-ts-comment\n // @ts-expect-error TS7053\n if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {\n return false;\n }\n }\n\n // We do this to make sure that we are not missing keys in the received object\n const keys_second = Object.keys(expected);\n for (const key of keys_second) {\n // eslint-disable-next-line ts/ban-ts-comment\n // @ts-expect-error TS7053\n if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {\n return false;\n }\n }\n }\n return true;\n}\n\n// If true, the value is a term. With ts annotation\nfunction isTerm(value: unknown): value is { equals: (other: { termType: unknown } | undefined | null) => boolean } {\n return false;\n}\n\nfunction isPrimitive(value: unknown): value is string | number | boolean {\n return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';\n}\n"]}
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
- var import_vitest = require("vitest");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("vitest");
4
+ //# sourceMappingURL=vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../../../lib/matchers/vitest.ts"],"names":[],"mappings":";;AAAA,kBAAgB","sourcesContent":["import 'vitest';\n\ninterface CustomMatchers<R = unknown> {\n toEqualParsedQuery: (expected: unknown) => R;\n toEqualParsedQueryIgnoring: (selector: (obj: object) => boolean, keys: string[], expected: unknown) => R;\n}\n\ndeclare module 'vitest' {\n interface Assertion<T = any> extends CustomMatchers<T> {}\n interface AsymmetricMatchersContaining extends CustomMatchers {}\n}\n"]}
@@ -6,5 +6,5 @@ interface Parser {
6
6
  baseIRI?: string;
7
7
  }) => unknown;
8
8
  }
9
- export declare function importSparql11NoteTests(parser: Parser, dataFactory: DataFactory<BaseQuad>): void;
9
+ export declare function importSparql11NoteTests(parser: Parser, DF: DataFactory<BaseQuad>): void;
10
10
  export {};
@@ -1,5 +1,5 @@
1
1
  import { describe, it } from 'vitest';
2
- export function importSparql11NoteTests(parser, dataFactory) {
2
+ export function importSparql11NoteTests(parser, DF) {
3
3
  function testErroneousQuery(query, _errorMsg) {
4
4
  return ({ expect }) => {
5
5
  let error;
@@ -50,9 +50,9 @@ export function importSparql11NoteTests(parser, dataFactory) {
50
50
  {
51
51
  triples: [
52
52
  {
53
- subject: dataFactory.namedNode('ex:abc#a'),
54
- predicate: dataFactory.namedNode('ex:def#b'),
55
- object: dataFactory.literal(''),
53
+ subject: DF.namedNode('ex:abc#a'),
54
+ predicate: DF.namedNode('ex:def#b'),
55
+ object: DF.literal(''),
56
56
  },
57
57
  ],
58
58
  },
@@ -64,9 +64,9 @@ export function importSparql11NoteTests(parser, dataFactory) {
64
64
  expect(parser.parse(query, { prefixes })).toMatchObject({
65
65
  where: [{
66
66
  triples: [{
67
- subject: dataFactory.namedNode('ex:xyz#a'),
68
- predicate: dataFactory.namedNode('ex:def#b'),
69
- object: dataFactory.literal(''),
67
+ subject: DF.namedNode('ex:xyz#a'),
68
+ predicate: DF.namedNode('ex:def#b'),
69
+ object: DF.literal(''),
70
70
  }],
71
71
  },
72
72
  ],
@@ -75,9 +75,9 @@ export function importSparql11NoteTests(parser, dataFactory) {
75
75
  expect(parser.parse(query2, { prefixes })).toMatchObject({
76
76
  where: [{
77
77
  triples: [{
78
- subject: dataFactory.namedNode('ex:abc#a'),
79
- predicate: dataFactory.namedNode('ex:def#b'),
80
- object: dataFactory.literal(''),
78
+ subject: DF.namedNode('ex:abc#a'),
79
+ predicate: DF.namedNode('ex:def#b'),
80
+ object: DF.literal(''),
81
81
  }],
82
82
  },
83
83
  ],
@@ -105,7 +105,7 @@ WHERE { ?s ?p ?o }
105
105
  expect(parser.parse(query, context)).toMatchObject({
106
106
  from: {
107
107
  default: [
108
- dataFactory.namedNode('http://ex.org/data.ttl'),
108
+ DF.namedNode('http://ex.org/data.ttl'),
109
109
  ],
110
110
  },
111
111
  });
@@ -113,9 +113,9 @@ WHERE { ?s ?p ?o }
113
113
  it.skip('should use the base IRI', ({ expect }) => {
114
114
  const query = 'SELECT * { <> <#b> "" }';
115
115
  const result = {
116
- subject: dataFactory.namedNode('http://ex.org/'),
117
- predicate: dataFactory.namedNode('http://ex.org/#b'),
118
- object: dataFactory.literal(''),
116
+ subject: DF.namedNode('http://ex.org/'),
117
+ predicate: DF.namedNode('http://ex.org/#b'),
118
+ object: DF.literal(''),
119
119
  };
120
120
  expect(parser.parse(query, context)).toMatchObject({
121
121
  where: [{ triples: [result] }],
@@ -127,9 +127,9 @@ WHERE { ?s ?p ?o }
127
127
  const goodQuery = 'SELECT * { <> <#b> "" }';
128
128
  const context = { baseIRI: 'http://ex2.org/' };
129
129
  const result = {
130
- subject: dataFactory.namedNode('http://ex2.org/'),
131
- predicate: dataFactory.namedNode('http://ex2.org/#b'),
132
- object: dataFactory.literal(''),
130
+ subject: DF.namedNode('http://ex2.org/'),
131
+ predicate: DF.namedNode('http://ex2.org/#b'),
132
+ object: DF.literal(''),
133
133
  };
134
134
  const data = parser.parse(goodQuery, context);
135
135
  expect(data).toMatchObject({
@@ -149,9 +149,9 @@ WHERE { ?s ?p ?o }
149
149
  type: 'bgp',
150
150
  triples: [
151
151
  {
152
- subject: dataFactory.variable('s'),
153
- predicate: dataFactory.variable('p'),
154
- object: dataFactory.variable('o'),
152
+ subject: DF.variable('s'),
153
+ predicate: DF.variable('p'),
154
+ object: DF.variable('o'),
155
155
  },
156
156
  ],
157
157
  },
@@ -161,9 +161,9 @@ WHERE { ?s ?p ?o }
161
161
  type: 'bgp',
162
162
  triples: [
163
163
  {
164
- subject: dataFactory.variable('a'),
165
- predicate: dataFactory.variable('b'),
166
- object: dataFactory.variable('c'),
164
+ subject: DF.variable('a'),
165
+ predicate: DF.variable('b'),
166
+ object: DF.variable('c'),
167
167
  },
168
168
  ],
169
169
  },
@@ -1 +1 @@
1
- {"version":3,"file":"Sparql11NotesTest.js","sourceRoot":"","sources":["../../../lib/Sparql11NotesTest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAOtC,MAAM,UAAU,uBAAuB,CAAC,MAAc,EAAE,WAAkC;IACxF,SAAS,kBAAkB,CAAC,KAAa,EAAE,SAAiB;QAC1D,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YACpB,IAAI,KAAU,CAAC;YACf,IAAI,CAAC;gBACH,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,KAAK,GAAG,CAAC,CAAC;YACZ,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;YAClC,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACpC,6CAA6C;QAC/C,CAAC,CAAC;IACJ,CAAC;IAED,EAAE,CAAC,2CAA2C,EAAE,kBAAkB,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAExG,EAAE,CAAC,IAAI,CAAC,6DAA6D,EAAE,kBAAkB,CACvF,6EAA6E,EAC7E,uCAAuC,CACxC,CAAC,CAAC;IAEH,EAAE,CAAC,wEAAwE,EAAE,kBAAkB,CAC7F,sDAAsD,EACtD,gFAAgF,CACjF,CAAC,CAAC;IAEH,EAAE,CAAC,wEAAwE,EAAE,kBAAkB,CAC7F,kDAAkD,EAClD,+EAA+E,CAChF,CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;QACpF,MAAM,KAAK,GAAG,+CAA+C,CAAC;QAC9D,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC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CAAC,sDAAsD,EAAE,kBAAkB,CAC3E,yEAAyE,EACzE,aAAa,CACd,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4FAA4F,EAAE,kBAAkB,CACjH,yCAAyC,EACzC,6EAA6E,CAC9E,CAAC,CAAC;IAEH,EAAE,CACA,iGAAiG,EACjG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;QACb,MAAM,KAAK,GAAG,+CAA+C,CAAC;QAC9D,wBAAwB;QACxB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type { BaseQuad } from '@rdfjs/types';\nimport type { DataFactory } from 'rdf-data-factory';\nimport { describe, it } from 'vitest';\nimport type { TestFunction } from 'vitest';\n\ninterface Parser {\n parse: (query: string, context?: { prefixes?: Record<string, string>; baseIRI?: string }) => unknown;\n}\n\nexport function importSparql11NoteTests(parser: Parser, dataFactory: DataFactory<BaseQuad>): void {\n function testErroneousQuery(query: string, _errorMsg: string): TestFunction<object> {\n return ({ expect }) => {\n let error: any;\n try {\n parser.parse(query);\n } catch (e) {\n error = e;\n }\n expect(error).not.toBeUndefined();\n expect(error).toBeInstanceOf(Error);\n // Expect(error.message).toContain(errorMsg);\n };\n }\n\n it('should throw an error on an invalid query', testErroneousQuery('invalid', 'Parse error on line 1'));\n\n it.skip('should throw an error on a projection of ungrouped variable', testErroneousQuery(\n 'PREFIX : <http://www.example.org/> SELECT ?o WHERE { ?s ?p ?o } GROUP BY ?s',\n 'Projection of ungrouped variable (?o)',\n ));\n\n it('should throw an error on a values class with LESS variables than value', testErroneousQuery(\n 'SELECT * WHERE { } VALUES ( ?S ) { ( true false ) }',\n 'Number of dataBlockValues does not match number of variables. Too much values.',\n ));\n\n it('should throw an error on a values class with MORE variables than value', testErroneousQuery(\n 'SELECT * WHERE { } VALUES ( ?S ?O ) { ( true ) }',\n 'Number of dataBlockValues does not match number of variables. Too few values.',\n ));\n\n it('should NOT throw on a values class with correct amount of values', ({ expect }) => {\n const query = 'SELECT * WHERE { } VALUES ( ?S ) { ( true ) }';\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it.skip('should throw an error on an invalid selectscope', testErroneousQuery(\n 'SELECT (1 AS ?X ) { SELECT (2 AS ?X ) {} }',\n 'Target id of \\'AS\\' (?X) already used in subquery',\n ));\n\n it.skip('should throw an error on bind to variable in scope', testErroneousQuery(\n 'SELECT * { ?s ?p ?o BIND(?o AS ?o) }',\n 'Target id of \\'AS\\' (?X) already used in subquery',\n ));\n\n it('should parse when not ending in newline', ({ expect }) => {\n const query = 'select?s{?s?p?o}#wow, what a query';\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should preserve BGP and filter pattern order', ({ expect }) => {\n const query = 'SELECT * { ?s ?p \"1\" . FILTER(true) . ?s ?p \"2\" }';\n expect(parser.parse(query)).toMatchObject({\n where: {\n patterns: [\n { subType: 'bgp' },\n { subType: 'filter' },\n { subType: 'bgp' },\n ],\n },\n });\n });\n\n it('should throw an error on an aggregate function within an aggregate function', testErroneousQuery(\n 'SELECT (SUM(COUNT(?lprice)) AS ?totalPrice) { }',\n 'An aggregate function is not allowed within an aggregate function',\n ));\n\n describe('with pre-defined prefixes', () => {\n const prefixes = { a: 'ex:abc#', b: 'ex:def#' };\n\n it.skip('should use those prefixes', ({ expect }) => {\n const query = 'SELECT * { a:a b:b \"\" }';\n expect(parser.parse(query, { prefixes })).toMatchObject({\n where: [\n {\n triples: [\n {\n subject: dataFactory.namedNode('ex:abc#a'),\n predicate: dataFactory.namedNode('ex:def#b'),\n object: dataFactory.literal(''),\n },\n ],\n },\n ],\n });\n });\n\n it.skip('should allow temporarily overriding prefixes', ({ expect }) => {\n const query = 'PREFIX a: <ex:xyz#> SELECT * { a:a b:b \"\" }';\n expect(parser.parse(query, { prefixes })).toMatchObject({\n where: [{\n triples: [{\n subject: dataFactory.namedNode('ex:xyz#a'),\n predicate: dataFactory.namedNode('ex:def#b'),\n object: dataFactory.literal(''),\n }],\n },\n ],\n });\n\n const query2 = 'SELECT * { a:a b:b \"\" }';\n expect(parser.parse(query2, { prefixes })).toMatchObject({\n where: [{\n triples: [{\n subject: dataFactory.namedNode('ex:abc#a'),\n predicate: dataFactory.namedNode('ex:def#b'),\n object: dataFactory.literal(''),\n }],\n },\n ],\n });\n });\n\n it('should not change the original prefixes', ({ expect }) => {\n expect(prefixes).toEqual({ a: 'ex:abc#', b: 'ex:def#' });\n });\n });\n\n describe('with pre-defined base IRI', () => {\n const context = { baseIRI: 'http://ex.org/' };\n\n it.skip('contains the base', ({ expect }) => {\n const query = 'SELECT * { ?s ?p ?o }';\n expect(parser.parse(query, context)).toMatchObject({\n base: 'http://ex.org/',\n });\n });\n\n it.skip('using prefixed as relative iri', ({ expect }) => {\n const context = { baseIRI: 'http://ex.org/apl' };\n const query = `\nCONSTRUCT\nFROM <data.ttl>\nWHERE { ?s ?p ?o }\n`;\n expect(parser.parse(query, context)).toMatchObject({\n from: {\n default: [\n dataFactory.namedNode('http://ex.org/data.ttl'),\n ],\n },\n });\n });\n\n it.skip('should use the base IRI', ({ expect }) => {\n const query = 'SELECT * { <> <#b> \"\" }';\n const result = {\n subject: dataFactory.namedNode('http://ex.org/'),\n predicate: dataFactory.namedNode('http://ex.org/#b'),\n object: dataFactory.literal(''),\n };\n\n expect(parser.parse(query, context)).toMatchObject({\n where: [{ triples: [ result ]}],\n });\n });\n\n it.skip('should work after a previous query failed', ({ expect }) => {\n const badQuery = 'SELECT * { <> <#b> \"\" } invalid!';\n expect(() => parser.parse(badQuery, context)).toThrow(Error);\n\n const goodQuery = 'SELECT * { <> <#b> \"\" }';\n\n const context = { baseIRI: 'http://ex2.org/' };\n const result = {\n subject: dataFactory.namedNode('http://ex2.org/'),\n predicate: dataFactory.namedNode('http://ex2.org/#b'),\n object: dataFactory.literal(''),\n };\n const data = parser.parse(goodQuery, context);\n expect(data).toMatchObject({\n where: [{ triples: [ result ]}],\n });\n });\n });\n\n it.skip('should throw an error on relative IRIs if no base IRI is specified', testErroneousQuery(\n 'SELECT * { <a> <b> <c> }',\n 'Cannot resolve relative IRI a because no base IRI was set.',\n ));\n\n describe('with group collapsing disabled', () => {\n it.skip('should keep explicit pattern group', ({ expect }) => {\n const query = 'SELECT * WHERE { { ?s ?p ?o } ?a ?b ?c }';\n const result = [\n {\n type: 'group',\n patterns: [\n {\n type: 'bgp',\n triples: [\n {\n subject: dataFactory.variable('s'),\n predicate: dataFactory.variable('p'),\n object: dataFactory.variable('o'),\n },\n ],\n },\n ],\n },\n {\n type: 'bgp',\n triples: [\n {\n subject: dataFactory.variable('a'),\n predicate: dataFactory.variable('b'),\n object: dataFactory.variable('c'),\n },\n ],\n },\n ];\n\n expect(parser.parse(query)).toMatchObject({ where: result });\n });\n\n it.skip('should still collapse immediate union groups', ({ expect }) => {\n const query = 'SELECT * WHERE { { ?s ?p ?o } UNION { ?a ?b ?c } }';\n\n const result = [\n {\n type: 'union',\n patterns: [{\n type: 'bgp',\n triples: [{\n subject: {\n termType: 'Variable',\n value: 's',\n },\n predicate: {\n termType: 'Variable',\n value: 'p',\n },\n object: {\n termType: 'Variable',\n value: 'o',\n },\n }],\n }, {\n type: 'bgp',\n triples: [{\n subject: {\n termType: 'Variable',\n value: 'a',\n },\n predicate: {\n termType: 'Variable',\n value: 'b',\n },\n object: {\n termType: 'Variable',\n value: 'c',\n },\n }],\n }],\n },\n ];\n\n expect(parser.parse(query)).toMatchObject({ where: result });\n });\n });\n\n describe('for update queries', () => {\n it('should throw an error on blank nodes in DELETE clause', testErroneousQuery(\n 'DELETE { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> \"Alan\" . }',\n 'Detected illegal blank node in BGP',\n ));\n\n it('should not throw on blank nodes in INSERT clause', ({ expect }) => {\n const query = 'INSERT { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> \"Alan\" . }';\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should throw an error on blank nodes in compact DELETE clause', testErroneousQuery(\n 'DELETE WHERE { _:a <ex:p> <ex:o> }',\n 'Detected illegal blank node in BGP',\n ));\n\n it('should throw an error on variables in DELETE DATA clause', testErroneousQuery(\n 'DELETE DATA { ?a <ex:p> <ex:o> }',\n 'Detected illegal variable in BGP',\n ));\n\n it('should throw an error on blank nodes in DELETE DATA clause', testErroneousQuery(\n 'DELETE DATA { _:a <ex:p> <ex:o> }',\n 'Detected illegal blank node in BGP',\n ));\n\n it('should throw an error on variables in DELETE DATA clause with GRAPH', testErroneousQuery(\n 'DELETE DATA { GRAPH ?a { <ex:s> <ex:p> <ex:o> } }',\n 'Detected illegal variable in GRAPH',\n ));\n\n it('should throw an error on variables in INSERT DATA clause', testErroneousQuery(\n 'INSERT DATA { ?a <ex:p> <ex:o> }',\n 'Detected illegal variable in BGP',\n ));\n\n it('should not throw on reused blank nodes in one INSERT DATA clause', ({ expect }) => {\n const query = 'INSERT DATA { _:a <ex:p> <ex:o> . _:a <ex:p> <ex:o> . }';\n // Todo: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it.skip('should throw an error on reused blank nodes across INSERT DATA clauses', testErroneousQuery(\n 'INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { _:a <ex:p> <ex:o> }',\n 'Detected reuse blank node across different INSERT DATA clauses',\n ));\n\n it.skip('should throw an error on reused blank nodes across INSERT DATA clauses with GRAPH', testErroneousQuery(\n 'INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { GRAPH <ex:g> { _:a <ex:p> <ex:o> } }',\n 'Detected reuse blank node across different INSERT DATA clauses',\n ));\n\n it('should not throw on comment between INSERT and DATA', ({ expect }) => {\n const query = `INSERT\n# Comment\nDATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }`;\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should not throw on comment after INSERT that could be confused with DATA', ({ expect }) => {\n const query = `INSERT # DATA\nDATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }`;\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should throw an error on commented DATA after INSERT', testErroneousQuery(\n 'INSERT # DATA { GRAPH <ex:G> { <ex:s> <ex:p> \\'o1\\', \\'o2\\', \\'o3\\' } }',\n 'Parse error',\n ));\n });\n\n it('should throw an error on unicode codepoint escaping in literal with partial surrogate pair', testErroneousQuery(\n 'SELECT * WHERE { ?s <ex:p> \\'\\uD800\\' }',\n 'Invalid unicode codepoint of surrogate pair without corresponding codepoint',\n ));\n\n it(\n 'should not throw an error on unicode codepoint escaping in literal with complete surrogate pair',\n ({ expect }) => {\n const query = 'SELECT * WHERE { ?s <ex:p> \\'\\uD800\\uDFFF\\' }';\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n },\n );\n}\n"]}
1
+ {"version":3,"file":"Sparql11NotesTest.js","sourceRoot":"","sources":["../../../lib/Sparql11NotesTest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAOtC,MAAM,UAAU,uBAAuB,CAAC,MAAc,EAAE,EAAyB;IAC/E,SAAS,kBAAkB,CAAC,KAAa,EAAE,SAAiB;QAC1D,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YACpB,IAAI,KAAU,CAAC;YACf,IAAI,CAAC;gBACH,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,KAAK,GAAG,CAAC,CAAC;YACZ,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;YAClC,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACpC,6CAA6C;QAC/C,CAAC,CAAC;IACJ,CAAC;IA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F,gEAAgE,CACjE,CAAC,CAAC;QAEH,EAAE,CAAC,qDAAqD,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YACvE,MAAM,KAAK,GAAG;;yDAEqC,CAAC;YACpD,wBAAwB;YACxB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,2EAA2E,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YAC7F,MAAM,KAAK,GAAG;yDACqC,CAAC;YACpD,wBAAwB;YACxB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sDAAsD,EAAE,kBAAkB,CAC3E,yEAAyE,EACzE,aAAa,CACd,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4FAA4F,EAAE,kBAAkB,CACjH,yCAAyC,EACzC,6EAA6E,CAC9E,CAAC,CAAC;IAEH,EAAE,CACA,iGAAiG,EACjG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;QACb,MAAM,KAAK,GAAG,+CAA+C,CAAC;QAC9D,wBAAwB;QACxB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type { BaseQuad } from '@rdfjs/types';\nimport type { DataFactory } from 'rdf-data-factory';\nimport { describe, it } from 'vitest';\nimport type { TestFunction } from 'vitest';\n\ninterface Parser {\n parse: (query: string, context?: { prefixes?: Record<string, string>; baseIRI?: string }) => unknown;\n}\n\nexport function importSparql11NoteTests(parser: Parser, DF: DataFactory<BaseQuad>): void {\n function testErroneousQuery(query: string, _errorMsg: string): TestFunction<object> {\n return ({ expect }) => {\n let error: any;\n try {\n parser.parse(query);\n } catch (e) {\n error = e;\n }\n expect(error).not.toBeUndefined();\n expect(error).toBeInstanceOf(Error);\n // Expect(error.message).toContain(errorMsg);\n };\n }\n\n it('should throw an error on an invalid query', testErroneousQuery('invalid', 'Parse error on line 1'));\n\n it.skip('should throw an error on a projection of ungrouped variable', testErroneousQuery(\n 'PREFIX : <http://www.example.org/> SELECT ?o WHERE { ?s ?p ?o } GROUP BY ?s',\n 'Projection of ungrouped variable (?o)',\n ));\n\n it('should throw an error on a values class with LESS variables than value', testErroneousQuery(\n 'SELECT * WHERE { } VALUES ( ?S ) { ( true false ) }',\n 'Number of dataBlockValues does not match number of variables. Too much values.',\n ));\n\n it('should throw an error on a values class with MORE variables than value', testErroneousQuery(\n 'SELECT * WHERE { } VALUES ( ?S ?O ) { ( true ) }',\n 'Number of dataBlockValues does not match number of variables. Too few values.',\n ));\n\n it('should NOT throw on a values class with correct amount of values', ({ expect }) => {\n const query = 'SELECT * WHERE { } VALUES ( ?S ) { ( true ) }';\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it.skip('should throw an error on an invalid selectscope', testErroneousQuery(\n 'SELECT (1 AS ?X ) { SELECT (2 AS ?X ) {} }',\n 'Target id of \\'AS\\' (?X) already used in subquery',\n ));\n\n it.skip('should throw an error on bind to variable in scope', testErroneousQuery(\n 'SELECT * { ?s ?p ?o BIND(?o AS ?o) }',\n 'Target id of \\'AS\\' (?X) already used in subquery',\n ));\n\n it('should parse when not ending in newline', ({ expect }) => {\n const query = 'select?s{?s?p?o}#wow, what a query';\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should preserve BGP and filter pattern order', ({ expect }) => {\n const query = 'SELECT * { ?s ?p \"1\" . FILTER(true) . ?s ?p \"2\" }';\n expect(parser.parse(query)).toMatchObject({\n where: {\n patterns: [\n { subType: 'bgp' },\n { subType: 'filter' },\n { subType: 'bgp' },\n ],\n },\n });\n });\n\n it('should throw an error on an aggregate function within an aggregate function', testErroneousQuery(\n 'SELECT (SUM(COUNT(?lprice)) AS ?totalPrice) { }',\n 'An aggregate function is not allowed within an aggregate function',\n ));\n\n describe('with pre-defined prefixes', () => {\n const prefixes = { a: 'ex:abc#', b: 'ex:def#' };\n\n it.skip('should use those prefixes', ({ expect }) => {\n const query = 'SELECT * { a:a b:b \"\" }';\n expect(parser.parse(query, { prefixes })).toMatchObject({\n where: [\n {\n triples: [\n {\n subject: DF.namedNode('ex:abc#a'),\n predicate: DF.namedNode('ex:def#b'),\n object: DF.literal(''),\n },\n ],\n },\n ],\n });\n });\n\n it.skip('should allow temporarily overriding prefixes', ({ expect }) => {\n const query = 'PREFIX a: <ex:xyz#> SELECT * { a:a b:b \"\" }';\n expect(parser.parse(query, { prefixes })).toMatchObject({\n where: [{\n triples: [{\n subject: DF.namedNode('ex:xyz#a'),\n predicate: DF.namedNode('ex:def#b'),\n object: DF.literal(''),\n }],\n },\n ],\n });\n\n const query2 = 'SELECT * { a:a b:b \"\" }';\n expect(parser.parse(query2, { prefixes })).toMatchObject({\n where: [{\n triples: [{\n subject: DF.namedNode('ex:abc#a'),\n predicate: DF.namedNode('ex:def#b'),\n object: DF.literal(''),\n }],\n },\n ],\n });\n });\n\n it('should not change the original prefixes', ({ expect }) => {\n expect(prefixes).toEqual({ a: 'ex:abc#', b: 'ex:def#' });\n });\n });\n\n describe('with pre-defined base IRI', () => {\n const context = { baseIRI: 'http://ex.org/' };\n\n it.skip('contains the base', ({ expect }) => {\n const query = 'SELECT * { ?s ?p ?o }';\n expect(parser.parse(query, context)).toMatchObject({\n base: 'http://ex.org/',\n });\n });\n\n it.skip('using prefixed as relative iri', ({ expect }) => {\n const context = { baseIRI: 'http://ex.org/apl' };\n const query = `\nCONSTRUCT\nFROM <data.ttl>\nWHERE { ?s ?p ?o }\n`;\n expect(parser.parse(query, context)).toMatchObject({\n from: {\n default: [\n DF.namedNode('http://ex.org/data.ttl'),\n ],\n },\n });\n });\n\n it.skip('should use the base IRI', ({ expect }) => {\n const query = 'SELECT * { <> <#b> \"\" }';\n const result = {\n subject: DF.namedNode('http://ex.org/'),\n predicate: DF.namedNode('http://ex.org/#b'),\n object: DF.literal(''),\n };\n\n expect(parser.parse(query, context)).toMatchObject({\n where: [{ triples: [ result ]}],\n });\n });\n\n it.skip('should work after a previous query failed', ({ expect }) => {\n const badQuery = 'SELECT * { <> <#b> \"\" } invalid!';\n expect(() => parser.parse(badQuery, context)).toThrow(Error);\n\n const goodQuery = 'SELECT * { <> <#b> \"\" }';\n\n const context = { baseIRI: 'http://ex2.org/' };\n const result = {\n subject: DF.namedNode('http://ex2.org/'),\n predicate: DF.namedNode('http://ex2.org/#b'),\n object: DF.literal(''),\n };\n const data = parser.parse(goodQuery, context);\n expect(data).toMatchObject({\n where: [{ triples: [ result ]}],\n });\n });\n });\n\n it.skip('should throw an error on relative IRIs if no base IRI is specified', testErroneousQuery(\n 'SELECT * { <a> <b> <c> }',\n 'Cannot resolve relative IRI a because no base IRI was set.',\n ));\n\n describe('with group collapsing disabled', () => {\n it.skip('should keep explicit pattern group', ({ expect }) => {\n const query = 'SELECT * WHERE { { ?s ?p ?o } ?a ?b ?c }';\n const result = [\n {\n type: 'group',\n patterns: [\n {\n type: 'bgp',\n triples: [\n {\n subject: DF.variable('s'),\n predicate: DF.variable('p'),\n object: DF.variable('o'),\n },\n ],\n },\n ],\n },\n {\n type: 'bgp',\n triples: [\n {\n subject: DF.variable('a'),\n predicate: DF.variable('b'),\n object: DF.variable('c'),\n },\n ],\n },\n ];\n\n expect(parser.parse(query)).toMatchObject({ where: result });\n });\n\n it.skip('should still collapse immediate union groups', ({ expect }) => {\n const query = 'SELECT * WHERE { { ?s ?p ?o } UNION { ?a ?b ?c } }';\n\n const result = [\n {\n type: 'union',\n patterns: [{\n type: 'bgp',\n triples: [{\n subject: {\n termType: 'Variable',\n value: 's',\n },\n predicate: {\n termType: 'Variable',\n value: 'p',\n },\n object: {\n termType: 'Variable',\n value: 'o',\n },\n }],\n }, {\n type: 'bgp',\n triples: [{\n subject: {\n termType: 'Variable',\n value: 'a',\n },\n predicate: {\n termType: 'Variable',\n value: 'b',\n },\n object: {\n termType: 'Variable',\n value: 'c',\n },\n }],\n }],\n },\n ];\n\n expect(parser.parse(query)).toMatchObject({ where: result });\n });\n });\n\n describe('for update queries', () => {\n it('should throw an error on blank nodes in DELETE clause', testErroneousQuery(\n 'DELETE { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> \"Alan\" . }',\n 'Detected illegal blank node in BGP',\n ));\n\n it('should not throw on blank nodes in INSERT clause', ({ expect }) => {\n const query = 'INSERT { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> \"Alan\" . }';\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should throw an error on blank nodes in compact DELETE clause', testErroneousQuery(\n 'DELETE WHERE { _:a <ex:p> <ex:o> }',\n 'Detected illegal blank node in BGP',\n ));\n\n it('should throw an error on variables in DELETE DATA clause', testErroneousQuery(\n 'DELETE DATA { ?a <ex:p> <ex:o> }',\n 'Detected illegal variable in BGP',\n ));\n\n it('should throw an error on blank nodes in DELETE DATA clause', testErroneousQuery(\n 'DELETE DATA { _:a <ex:p> <ex:o> }',\n 'Detected illegal blank node in BGP',\n ));\n\n it('should throw an error on variables in DELETE DATA clause with GRAPH', testErroneousQuery(\n 'DELETE DATA { GRAPH ?a { <ex:s> <ex:p> <ex:o> } }',\n 'Detected illegal variable in GRAPH',\n ));\n\n it('should throw an error on variables in INSERT DATA clause', testErroneousQuery(\n 'INSERT DATA { ?a <ex:p> <ex:o> }',\n 'Detected illegal variable in BGP',\n ));\n\n it('should not throw on reused blank nodes in one INSERT DATA clause', ({ expect }) => {\n const query = 'INSERT DATA { _:a <ex:p> <ex:o> . _:a <ex:p> <ex:o> . }';\n // Todo: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it.skip('should throw an error on reused blank nodes across INSERT DATA clauses', testErroneousQuery(\n 'INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { _:a <ex:p> <ex:o> }',\n 'Detected reuse blank node across different INSERT DATA clauses',\n ));\n\n it.skip('should throw an error on reused blank nodes across INSERT DATA clauses with GRAPH', testErroneousQuery(\n 'INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { GRAPH <ex:g> { _:a <ex:p> <ex:o> } }',\n 'Detected reuse blank node across different INSERT DATA clauses',\n ));\n\n it('should not throw on comment between INSERT and DATA', ({ expect }) => {\n const query = `INSERT\n# Comment\nDATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }`;\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should not throw on comment after INSERT that could be confused with DATA', ({ expect }) => {\n const query = `INSERT # DATA\nDATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }`;\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should throw an error on commented DATA after INSERT', testErroneousQuery(\n 'INSERT # DATA { GRAPH <ex:G> { <ex:s> <ex:p> \\'o1\\', \\'o2\\', \\'o3\\' } }',\n 'Parse error',\n ));\n });\n\n it('should throw an error on unicode codepoint escaping in literal with partial surrogate pair', testErroneousQuery(\n 'SELECT * WHERE { ?s <ex:p> \\'\\uD800\\' }',\n 'Invalid unicode codepoint of surrogate pair without corresponding codepoint',\n ));\n\n it(\n 'should not throw an error on unicode codepoint escaping in literal with complete surrogate pair',\n ({ expect }) => {\n const query = 'SELECT * WHERE { ?s <ex:p> \\'\\uD800\\uDFFF\\' }';\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n },\n );\n}\n"]}
@@ -1,25 +1,25 @@
1
- /* eslint-disable import/no-nodejs-modules,no-sync */
2
- import * as fs from 'node:fs';
3
- import * as path from 'node:path';
1
+ /* eslint-disable import/no-nodejs-modules */
2
+ import { lstatSync, readdirSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
4
  import { readFileSync } from '../fileUtils.js';
5
5
  import { getStaticFilePath } from './utils.js';
6
6
  const rootDir = getStaticFilePath('algebra');
7
- const rootSparql = path.join(rootDir, 'sparql');
8
- const rootJson = path.join(rootDir, 'algebra');
9
- const rootJsonBlankToVariable = path.join(rootDir, 'algebra-blank-to-var');
7
+ const rootSparql = join(rootDir, 'sparql');
8
+ const rootJson = join(rootDir, 'algebra');
9
+ const rootJsonBlankToVariable = join(rootDir, 'algebra-blank-to-var');
10
10
  export function* sparqlAlgebraTests(suite, blankToVariable, getSPARQL) {
11
11
  // Relative path starting from roots declared above.
12
12
  function* subGen(relativePath) {
13
- const absolutePath = path.join(blankToVariable ? rootJsonBlankToVariable : rootJson, relativePath);
14
- if (fs.lstatSync(absolutePath).isDirectory()) {
13
+ const absolutePath = join(blankToVariable ? rootJsonBlankToVariable : rootJson, relativePath);
14
+ if (lstatSync(absolutePath).isDirectory()) {
15
15
  // Recursion
16
- for (const sub of fs.readdirSync(absolutePath)) {
17
- yield* subGen(path.join(relativePath, sub));
16
+ for (const sub of readdirSync(absolutePath)) {
17
+ yield* subGen(join(relativePath, sub));
18
18
  }
19
19
  }
20
20
  else {
21
21
  const name = relativePath.replace(/\.json$/u, '');
22
- const sparqlPath = path.join(rootSparql, relativePath.replace(/\.json/u, '.sparql'));
22
+ const sparqlPath = join(rootSparql, relativePath.replace(/\.json/u, '.sparql'));
23
23
  yield {
24
24
  name,
25
25
  json: JSON.parse(readFileSync(absolutePath)),
@@ -28,30 +28,30 @@ export function* sparqlAlgebraTests(suite, blankToVariable, getSPARQL) {
28
28
  };
29
29
  }
30
30
  }
31
- const subfolders = fs.readdirSync(blankToVariable ? rootJsonBlankToVariable : rootJson);
31
+ const subfolders = readdirSync(blankToVariable ? rootJsonBlankToVariable : rootJson);
32
32
  if (subfolders.includes(suite)) {
33
33
  yield* subGen(suite);
34
34
  }
35
35
  }
36
36
  export function* sparqlQueries(suite) {
37
37
  function* subGen(relativePath) {
38
- const absolutePath = path.join(rootSparql, relativePath);
39
- if (fs.lstatSync(absolutePath).isDirectory()) {
38
+ const absolutePath = join(rootSparql, relativePath);
39
+ if (lstatSync(absolutePath).isDirectory()) {
40
40
  // Recursion
41
- for (const sub of fs.readdirSync(absolutePath)) {
42
- yield* subGen(path.join(relativePath, sub));
41
+ for (const sub of readdirSync(absolutePath)) {
42
+ yield* subGen(join(relativePath, sub));
43
43
  }
44
44
  }
45
45
  else {
46
46
  const name = relativePath.replace(/\.sparql$/u, '');
47
- const content = fs.readFileSync(absolutePath, 'utf-8');
47
+ const content = readFileSync(absolutePath, 'utf-8');
48
48
  yield {
49
49
  name,
50
50
  query: content.replaceAll(/\r?\n/gu, '\n'),
51
51
  };
52
52
  }
53
53
  }
54
- const subfolders = fs.readdirSync(rootSparql);
54
+ const subfolders = readdirSync(rootSparql);
55
55
  if (subfolders.includes(suite)) {
56
56
  yield* subGen(suite);
57
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"algebraGenerators.js","sourceRoot":"","sources":["../../../../lib/generators/algebraGenerators.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,OAAO,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAC/C,MAAM,uBAAuB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;AAe3E,MAAM,SAAS,CAAC,CAAC,kBAAkB,CAAC,KAAuB,EAAE,eAAwB,EAAE,SAAkB;IAEvG,oDAAoD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AGD,MAAM,SAAS,CAAC,CAAC,aAAa,CAAC,KAAuB;IACpD,QAAQ,CAAC,CAAC,MAAM,CAAC,YAAoB;QACnC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACzD,IAAI,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAC7C,YAAY;YACZ,KAAK,MAAM,GAAG,IAAI,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC/C,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;YACpD,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YACvD,MAAM;gBACJ,IAAI;gBACJ,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC;aAC3C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable import/no-nodejs-modules,no-sync */\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { readFileSync } from '../fileUtils.js';\nimport { getStaticFilePath } from './utils.js';\n\nconst rootDir = getStaticFilePath('algebra');\nconst rootSparql = path.join(rootDir, 'sparql');\nconst rootJson = path.join(rootDir, 'algebra');\nconst rootJsonBlankToVariable = path.join(rootDir, 'algebra-blank-to-var');\n\nexport interface algebraTestGen {\n name: string;\n json: unknown;\n quads: boolean;\n sparql: string | undefined;\n}\n\nexport type AlgebraTestSuite = 'dawg-syntax' | 'sparql-1.1' | 'sparql11-query' | 'sparql12';\n\nexport function sparqlAlgebraTests(suites: AlgebraTestSuite, blankToVariable: boolean, getSPARQL: true):\nGenerator<algebraTestGen & { sparql: string }>;\nexport function sparqlAlgebraTests(suites: AlgebraTestSuite, blankToVariable: boolean, getSPARQL: boolean):\nGenerator<algebraTestGen>;\nexport function* sparqlAlgebraTests(suite: AlgebraTestSuite, blankToVariable: boolean, getSPARQL: boolean):\nGenerator<algebraTestGen> {\n // Relative path starting from roots declared above.\n function* subGen(relativePath: string): Generator<algebraTestGen> {\n const absolutePath = path.join(blankToVariable ? rootJsonBlankToVariable : rootJson, relativePath);\n if (fs.lstatSync(absolutePath).isDirectory()) {\n // Recursion\n for (const sub of fs.readdirSync(absolutePath)) {\n yield* subGen(path.join(relativePath, sub));\n }\n } else {\n const name = relativePath.replace(/\\.json$/u, '');\n const sparqlPath = path.join(rootSparql, relativePath.replace(/\\.json/u, '.sparql'));\n yield {\n name,\n json: JSON.parse(readFileSync(absolutePath)),\n sparql: getSPARQL ? readFileSync(sparqlPath, 'utf8') : undefined,\n quads: name.endsWith('-quads'),\n };\n }\n }\n\n const subfolders = fs.readdirSync(blankToVariable ? rootJsonBlankToVariable : rootJson);\n if (subfolders.includes(suite)) {\n yield* subGen(suite);\n }\n}\n\ntype GenQuery = { query: string; name: string };\nexport function* sparqlQueries(suite: AlgebraTestSuite): Generator<GenQuery> {\n function* subGen(relativePath: string): Generator<GenQuery> {\n const absolutePath = path.join(rootSparql, relativePath);\n if (fs.lstatSync(absolutePath).isDirectory()) {\n // Recursion\n for (const sub of fs.readdirSync(absolutePath)) {\n yield* subGen(path.join(relativePath, sub));\n }\n } else {\n const name = relativePath.replace(/\\.sparql$/u, '');\n const content = fs.readFileSync(absolutePath, 'utf-8');\n yield {\n name,\n query: content.replaceAll(/\\r?\\n/gu, '\\n'),\n };\n }\n }\n\n const subfolders = fs.readdirSync(rootSparql);\n if (subfolders.includes(suite)) {\n yield* subGen(suite);\n }\n}\n"]}
1
+ {"version":3,"file":"algebraGenerators.js","sourceRoot":"","sources":["../../../../lib/generators/algebraGenerators.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,OAAO,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAC1C,MAAM,uBAAuB,GAAG,IAAI,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;AAetE,MAAM,SAAS,CAAC,CAAC,kBAAkB,CAAC,KAAuB,EAAE,eAAwB,EAAE,SAAkB;IAEvG,oDAAoD;IACpD,QAAQ,CAAC,CAAC,MAAM,CAAC,YAAoB;QACnC,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC9F,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAC1C,YAAY;YACZ,KAAK,MAAM,GAAG,IAAI,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC5C,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,GAAG,YAAY,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CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YACpD,MAAM;gBACJ,IAAI;gBACJ,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC;aAC3C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3C,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable import/no-nodejs-modules */\nimport { lstatSync, readdirSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { readFileSync } from '../fileUtils.js';\nimport { getStaticFilePath } from './utils.js';\n\nconst rootDir = getStaticFilePath('algebra');\nconst rootSparql = join(rootDir, 'sparql');\nconst rootJson = join(rootDir, 'algebra');\nconst rootJsonBlankToVariable = join(rootDir, 'algebra-blank-to-var');\n\nexport interface algebraTestGen {\n name: string;\n json: unknown;\n quads: boolean;\n sparql: string | undefined;\n}\n\nexport type AlgebraTestSuite = 'dawg-syntax' | 'sparql-1.1' | 'sparql11-query' | 'sparql12';\n\nexport function sparqlAlgebraTests(suites: AlgebraTestSuite, blankToVariable: boolean, getSPARQL: true):\nGenerator<algebraTestGen & { sparql: string }>;\nexport function sparqlAlgebraTests(suites: AlgebraTestSuite, blankToVariable: boolean, getSPARQL: boolean):\nGenerator<algebraTestGen>;\nexport function* sparqlAlgebraTests(suite: AlgebraTestSuite, blankToVariable: boolean, getSPARQL: boolean):\nGenerator<algebraTestGen> {\n // Relative path starting from roots declared above.\n function* subGen(relativePath: string): Generator<algebraTestGen> {\n const absolutePath = join(blankToVariable ? rootJsonBlankToVariable : rootJson, relativePath);\n if (lstatSync(absolutePath).isDirectory()) {\n // Recursion\n for (const sub of readdirSync(absolutePath)) {\n yield* subGen(join(relativePath, sub));\n }\n } else {\n const name = relativePath.replace(/\\.json$/u, '');\n const sparqlPath = join(rootSparql, relativePath.replace(/\\.json/u, '.sparql'));\n yield {\n name,\n json: JSON.parse(readFileSync(absolutePath)),\n sparql: getSPARQL ? readFileSync(sparqlPath, 'utf8') : undefined,\n quads: name.endsWith('-quads'),\n };\n }\n }\n\n const subfolders = readdirSync(blankToVariable ? rootJsonBlankToVariable : rootJson);\n if (subfolders.includes(suite)) {\n yield* subGen(suite);\n }\n}\n\ntype GenQuery = { query: string; name: string };\nexport function* sparqlQueries(suite: AlgebraTestSuite): Generator<GenQuery> {\n function* subGen(relativePath: string): Generator<GenQuery> {\n const absolutePath = join(rootSparql, relativePath);\n if (lstatSync(absolutePath).isDirectory()) {\n // Recursion\n for (const sub of readdirSync(absolutePath)) {\n yield* subGen(join(relativePath, sub));\n }\n } else {\n const name = relativePath.replace(/\\.sparql$/u, '');\n const content = readFileSync(absolutePath, 'utf-8');\n yield {\n name,\n query: content.replaceAll(/\\r?\\n/gu, '\\n'),\n };\n }\n }\n\n const subfolders = readdirSync(rootSparql);\n if (subfolders.includes(suite)) {\n yield* subGen(suite);\n }\n}\n"]}
@@ -2,7 +2,8 @@ interface PositiveTest {
2
2
  name: string;
3
3
  statics: () => Promise<{
4
4
  query: string;
5
- ast: unknown;
5
+ astWithSource: unknown;
6
+ astNoSource: unknown;
6
7
  autoGen: string;
7
8
  }>;
8
9
  }