@traqula/test-utils 0.0.13 → 0.0.14
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.
- package/lib/index.cjs +26 -80
- package/lib/index.d.ts +6 -6
- package/lib/index.js +6 -6
- package/lib/index.js.map +1 -1
- package/lib/statics/algebraGenerators.js +1 -1
- package/lib/statics/algebraGenerators.js.map +1 -1
- package/lib/statics/algebraGenerators.ts +1 -1
- package/lib/statics/generators.js +1 -1
- package/lib/statics/generators.js.map +1 -1
- package/lib/statics/generators.ts +1 -1
- package/package.json +3 -2
package/lib/index.cjs
CHANGED
|
@@ -8240,11 +8240,11 @@ function createTestHook(name, handler) {
|
|
|
8240
8240
|
// ../../node_modules/vitest/dist/index.js
|
|
8241
8241
|
var import_expect_type = __toESM(require_dist(), 1);
|
|
8242
8242
|
|
|
8243
|
-
// lib/statics/generators.
|
|
8243
|
+
// lib/statics/generators.js
|
|
8244
8244
|
var fs2 = __toESM(require("node:fs"), 1);
|
|
8245
8245
|
var path = __toESM(require("node:path"), 1);
|
|
8246
8246
|
|
|
8247
|
-
// lib/fileUtils.
|
|
8247
|
+
// lib/fileUtils.js
|
|
8248
8248
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
8249
8249
|
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
8250
8250
|
async function readFile(path3, encoding = "utf-8") {
|
|
@@ -8256,7 +8256,7 @@ function readFileSync(path3, encoding = "utf-8") {
|
|
|
8256
8256
|
return content.replaceAll(/\r?\n/gu, "\n");
|
|
8257
8257
|
}
|
|
8258
8258
|
|
|
8259
|
-
// lib/statics/generators.
|
|
8259
|
+
// lib/statics/generators.js
|
|
8260
8260
|
function* positiveTest(type3, filter) {
|
|
8261
8261
|
const dir = path.join(__dirname, type3);
|
|
8262
8262
|
const statics = fs2.readdirSync(dir);
|
|
@@ -8308,7 +8308,7 @@ function* negativeTest(type3, filter) {
|
|
|
8308
8308
|
}
|
|
8309
8309
|
}
|
|
8310
8310
|
|
|
8311
|
-
// lib/statics/algebraGenerators.
|
|
8311
|
+
// lib/statics/algebraGenerators.js
|
|
8312
8312
|
var fs3 = __toESM(require("node:fs"), 1);
|
|
8313
8313
|
var path2 = __toESM(require("node:path"), 1);
|
|
8314
8314
|
var rootDir = path2.join(__dirname, "algebra");
|
|
@@ -8360,7 +8360,7 @@ function* sparqlQueries(suite2) {
|
|
|
8360
8360
|
}
|
|
8361
8361
|
}
|
|
8362
8362
|
|
|
8363
|
-
// lib/Sparql11NotesTest.
|
|
8363
|
+
// lib/Sparql11NotesTest.js
|
|
8364
8364
|
function importSparql11NoteTests(parser, dataFactory) {
|
|
8365
8365
|
function testErroneousQuery(query, _errorMsg) {
|
|
8366
8366
|
return ({ expect: expect2 }) => {
|
|
@@ -8375,30 +8375,15 @@ function importSparql11NoteTests(parser, dataFactory) {
|
|
|
8375
8375
|
};
|
|
8376
8376
|
}
|
|
8377
8377
|
it("should throw an error on an invalid query", testErroneousQuery("invalid", "Parse error on line 1"));
|
|
8378
|
-
it.skip("should throw an error on a projection of ungrouped variable", testErroneousQuery(
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
));
|
|
8382
|
-
it("should throw an error on a values class with LESS variables than value", testErroneousQuery(
|
|
8383
|
-
"SELECT * WHERE { } VALUES ( ?S ) { ( true false ) }",
|
|
8384
|
-
"Number of dataBlockValues does not match number of variables. Too much values."
|
|
8385
|
-
));
|
|
8386
|
-
it("should throw an error on a values class with MORE variables than value", testErroneousQuery(
|
|
8387
|
-
"SELECT * WHERE { } VALUES ( ?S ?O ) { ( true ) }",
|
|
8388
|
-
"Number of dataBlockValues does not match number of variables. Too few values."
|
|
8389
|
-
));
|
|
8378
|
+
it.skip("should throw an error on a projection of ungrouped variable", testErroneousQuery("PREFIX : <http://www.example.org/> SELECT ?o WHERE { ?s ?p ?o } GROUP BY ?s", "Projection of ungrouped variable (?o)"));
|
|
8379
|
+
it("should throw an error on a values class with LESS variables than value", testErroneousQuery("SELECT * WHERE { } VALUES ( ?S ) { ( true false ) }", "Number of dataBlockValues does not match number of variables. Too much values."));
|
|
8380
|
+
it("should throw an error on a values class with MORE variables than value", testErroneousQuery("SELECT * WHERE { } VALUES ( ?S ?O ) { ( true ) }", "Number of dataBlockValues does not match number of variables. Too few values."));
|
|
8390
8381
|
it("should NOT throw on a values class with correct amount of values", ({ expect: expect2 }) => {
|
|
8391
8382
|
const query = "SELECT * WHERE { } VALUES ( ?S ) { ( true ) }";
|
|
8392
8383
|
expect2(parser.parse(query)).toMatchObject({});
|
|
8393
8384
|
});
|
|
8394
|
-
it.skip("should throw an error on an invalid selectscope", testErroneousQuery(
|
|
8395
|
-
|
|
8396
|
-
"Target id of 'AS' (?X) already used in subquery"
|
|
8397
|
-
));
|
|
8398
|
-
it.skip("should throw an error on bind to variable in scope", testErroneousQuery(
|
|
8399
|
-
"SELECT * { ?s ?p ?o BIND(?o AS ?o) }",
|
|
8400
|
-
"Target id of 'AS' (?X) already used in subquery"
|
|
8401
|
-
));
|
|
8385
|
+
it.skip("should throw an error on an invalid selectscope", testErroneousQuery("SELECT (1 AS ?X ) { SELECT (2 AS ?X ) {} }", "Target id of 'AS' (?X) already used in subquery"));
|
|
8386
|
+
it.skip("should throw an error on bind to variable in scope", testErroneousQuery("SELECT * { ?s ?p ?o BIND(?o AS ?o) }", "Target id of 'AS' (?X) already used in subquery"));
|
|
8402
8387
|
it("should preserve BGP and filter pattern order", ({ expect: expect2 }) => {
|
|
8403
8388
|
const query = 'SELECT * { ?s ?p "1" . FILTER(true) . ?s ?p "2" }';
|
|
8404
8389
|
expect2(parser.parse(query)).toMatchObject({
|
|
@@ -8411,10 +8396,7 @@ function importSparql11NoteTests(parser, dataFactory) {
|
|
|
8411
8396
|
}
|
|
8412
8397
|
});
|
|
8413
8398
|
});
|
|
8414
|
-
it("should throw an error on an aggregate function within an aggregate function", testErroneousQuery(
|
|
8415
|
-
"SELECT (SUM(COUNT(?lprice)) AS ?totalPrice) { }",
|
|
8416
|
-
"An aggregate function is not allowed within an aggregate function"
|
|
8417
|
-
));
|
|
8399
|
+
it("should throw an error on an aggregate function within an aggregate function", testErroneousQuery("SELECT (SUM(COUNT(?lprice)) AS ?totalPrice) { }", "An aggregate function is not allowed within an aggregate function"));
|
|
8418
8400
|
describe("with pre-defined prefixes", () => {
|
|
8419
8401
|
const prefixes = { a: "ex:abc#", b: "ex:def#" };
|
|
8420
8402
|
it.skip("should use those prefixes", ({ expect: expect2 }) => {
|
|
@@ -8513,10 +8495,7 @@ WHERE { ?s ?p ?o }
|
|
|
8513
8495
|
});
|
|
8514
8496
|
});
|
|
8515
8497
|
});
|
|
8516
|
-
it.skip("should throw an error on relative IRIs if no base IRI is specified", testErroneousQuery(
|
|
8517
|
-
"SELECT * { <a> <b> <c> }",
|
|
8518
|
-
"Cannot resolve relative IRI a because no base IRI was set."
|
|
8519
|
-
));
|
|
8498
|
+
it.skip("should throw an error on relative IRIs if no base IRI is specified", testErroneousQuery("SELECT * { <a> <b> <c> }", "Cannot resolve relative IRI a because no base IRI was set."));
|
|
8520
8499
|
describe("with group collapsing disabled", () => {
|
|
8521
8500
|
it.skip("should keep explicit pattern group", ({ expect: expect2 }) => {
|
|
8522
8501
|
const query = "SELECT * WHERE { { ?s ?p ?o } ?a ?b ?c }";
|
|
@@ -8593,46 +8572,22 @@ WHERE { ?s ?p ?o }
|
|
|
8593
8572
|
});
|
|
8594
8573
|
});
|
|
8595
8574
|
describe("for update queries", () => {
|
|
8596
|
-
it("should throw an error on blank nodes in DELETE clause", testErroneousQuery(
|
|
8597
|
-
'DELETE { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> "Alan" . }',
|
|
8598
|
-
"Detected illegal blank node in BGP"
|
|
8599
|
-
));
|
|
8575
|
+
it("should throw an error on blank nodes in DELETE clause", testErroneousQuery('DELETE { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> "Alan" . }', "Detected illegal blank node in BGP"));
|
|
8600
8576
|
it("should not throw on blank nodes in INSERT clause", ({ expect: expect2 }) => {
|
|
8601
8577
|
const query = 'INSERT { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> "Alan" . }';
|
|
8602
8578
|
expect2(parser.parse(query)).toMatchObject({});
|
|
8603
8579
|
});
|
|
8604
|
-
it("should throw an error on blank nodes in compact DELETE clause", testErroneousQuery(
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
));
|
|
8608
|
-
it("should throw an error on variables in
|
|
8609
|
-
"DELETE DATA { ?a <ex:p> <ex:o> }",
|
|
8610
|
-
"Detected illegal variable in BGP"
|
|
8611
|
-
));
|
|
8612
|
-
it("should throw an error on blank nodes in DELETE DATA clause", testErroneousQuery(
|
|
8613
|
-
"DELETE DATA { _:a <ex:p> <ex:o> }",
|
|
8614
|
-
"Detected illegal blank node in BGP"
|
|
8615
|
-
));
|
|
8616
|
-
it("should throw an error on variables in DELETE DATA clause with GRAPH", testErroneousQuery(
|
|
8617
|
-
"DELETE DATA { GRAPH ?a { <ex:s> <ex:p> <ex:o> } }",
|
|
8618
|
-
"Detected illegal variable in GRAPH"
|
|
8619
|
-
));
|
|
8620
|
-
it("should throw an error on variables in INSERT DATA clause", testErroneousQuery(
|
|
8621
|
-
"INSERT DATA { ?a <ex:p> <ex:o> }",
|
|
8622
|
-
"Detected illegal variable in BGP"
|
|
8623
|
-
));
|
|
8580
|
+
it("should throw an error on blank nodes in compact DELETE clause", testErroneousQuery("DELETE WHERE { _:a <ex:p> <ex:o> }", "Detected illegal blank node in BGP"));
|
|
8581
|
+
it("should throw an error on variables in DELETE DATA clause", testErroneousQuery("DELETE DATA { ?a <ex:p> <ex:o> }", "Detected illegal variable in BGP"));
|
|
8582
|
+
it("should throw an error on blank nodes in DELETE DATA clause", testErroneousQuery("DELETE DATA { _:a <ex:p> <ex:o> }", "Detected illegal blank node in BGP"));
|
|
8583
|
+
it("should throw an error on variables in DELETE DATA clause with GRAPH", testErroneousQuery("DELETE DATA { GRAPH ?a { <ex:s> <ex:p> <ex:o> } }", "Detected illegal variable in GRAPH"));
|
|
8584
|
+
it("should throw an error on variables in INSERT DATA clause", testErroneousQuery("INSERT DATA { ?a <ex:p> <ex:o> }", "Detected illegal variable in BGP"));
|
|
8624
8585
|
it("should not throw on reused blank nodes in one INSERT DATA clause", ({ expect: expect2 }) => {
|
|
8625
8586
|
const query = "INSERT DATA { _:a <ex:p> <ex:o> . _:a <ex:p> <ex:o> . }";
|
|
8626
8587
|
expect2(parser.parse(query)).toMatchObject({});
|
|
8627
8588
|
});
|
|
8628
|
-
it.skip("should throw an error on reused blank nodes across INSERT DATA clauses", testErroneousQuery(
|
|
8629
|
-
|
|
8630
|
-
"Detected reuse blank node across different INSERT DATA clauses"
|
|
8631
|
-
));
|
|
8632
|
-
it.skip("should throw an error on reused blank nodes across INSERT DATA clauses with GRAPH", testErroneousQuery(
|
|
8633
|
-
"INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { GRAPH <ex:g> { _:a <ex:p> <ex:o> } }",
|
|
8634
|
-
"Detected reuse blank node across different INSERT DATA clauses"
|
|
8635
|
-
));
|
|
8589
|
+
it.skip("should throw an error on reused blank nodes across INSERT DATA clauses", testErroneousQuery("INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { _:a <ex:p> <ex:o> }", "Detected reuse blank node across different INSERT DATA clauses"));
|
|
8590
|
+
it.skip("should throw an error on reused blank nodes across INSERT DATA clauses with GRAPH", testErroneousQuery("INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { GRAPH <ex:g> { _:a <ex:p> <ex:o> } }", "Detected reuse blank node across different INSERT DATA clauses"));
|
|
8636
8591
|
it("should not throw on comment between INSERT and DATA", ({ expect: expect2 }) => {
|
|
8637
8592
|
const query = `INSERT
|
|
8638
8593
|
# Comment
|
|
@@ -8644,22 +8599,13 @@ DATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }`;
|
|
|
8644
8599
|
DATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }`;
|
|
8645
8600
|
expect2(parser.parse(query)).toMatchObject({});
|
|
8646
8601
|
});
|
|
8647
|
-
it("should throw an error on commented DATA after INSERT", testErroneousQuery(
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8602
|
+
it("should throw an error on commented DATA after INSERT", testErroneousQuery("INSERT # DATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }", "Parse error"));
|
|
8603
|
+
});
|
|
8604
|
+
it("should throw an error on unicode codepoint escaping in literal with partial surrogate pair", testErroneousQuery("SELECT * WHERE { ?s <ex:p> '\uD800' }", "Invalid unicode codepoint of surrogate pair without corresponding codepoint"));
|
|
8605
|
+
it("should not throw an error on unicode codepoint escaping in literal with complete surrogate pair", ({ expect: expect2 }) => {
|
|
8606
|
+
const query = "SELECT * WHERE { ?s <ex:p> '\u{103FF}' }";
|
|
8607
|
+
expect2(parser.parse(query)).toMatchObject({});
|
|
8651
8608
|
});
|
|
8652
|
-
it("should throw an error on unicode codepoint escaping in literal with partial surrogate pair", testErroneousQuery(
|
|
8653
|
-
"SELECT * WHERE { ?s <ex:p> '\uD800' }",
|
|
8654
|
-
"Invalid unicode codepoint of surrogate pair without corresponding codepoint"
|
|
8655
|
-
));
|
|
8656
|
-
it(
|
|
8657
|
-
"should not throw an error on unicode codepoint escaping in literal with complete surrogate pair",
|
|
8658
|
-
({ expect: expect2 }) => {
|
|
8659
|
-
const query = "SELECT * WHERE { ?s <ex:p> '\u{103FF}' }";
|
|
8660
|
-
expect2(parser.parse(query)).toMatchObject({});
|
|
8661
|
-
}
|
|
8662
|
-
);
|
|
8663
8609
|
}
|
|
8664
8610
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8665
8611
|
0 && (module.exports = {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './matchers/toEqualParsedQuery';
|
|
2
|
-
export * from './matchers/vitest';
|
|
3
|
-
export * from './statics/generators';
|
|
4
|
-
export * from './statics/algebraGenerators';
|
|
5
|
-
export * from './Sparql11NotesTest';
|
|
6
|
-
export * from './fileUtils';
|
|
1
|
+
export * from './matchers/toEqualParsedQuery.js';
|
|
2
|
+
export * from './matchers/vitest.js';
|
|
3
|
+
export * from './statics/generators.js';
|
|
4
|
+
export * from './statics/algebraGenerators.js';
|
|
5
|
+
export * from './Sparql11NotesTest.js';
|
|
6
|
+
export * from './fileUtils.js';
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './matchers/toEqualParsedQuery';
|
|
2
|
-
export * from './matchers/vitest';
|
|
3
|
-
export * from './statics/generators';
|
|
4
|
-
export * from './statics/algebraGenerators';
|
|
5
|
-
export * from './Sparql11NotesTest';
|
|
6
|
-
export * from './fileUtils';
|
|
1
|
+
export * from './matchers/toEqualParsedQuery.js';
|
|
2
|
+
export * from './matchers/vitest.js';
|
|
3
|
+
export * from './statics/generators.js';
|
|
4
|
+
export * from './statics/algebraGenerators.js';
|
|
5
|
+
export * from './Sparql11NotesTest.js';
|
|
6
|
+
export * from './fileUtils.js';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './matchers/toEqualParsedQuery.js';\nexport * from './matchers/vitest.js';\nexport * from './statics/generators.js';\nexport * from './statics/algebraGenerators.js';\nexport * from './Sparql11NotesTest.js';\nexport * from './fileUtils.js';\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable import/no-nodejs-modules,no-sync */
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
-
import { readFileSync } from '../fileUtils';
|
|
4
|
+
import { readFileSync } from '../fileUtils.js';
|
|
5
5
|
const rootDir = path.join(__dirname, 'algebra');
|
|
6
6
|
const rootSparql = path.join(rootDir, 'sparql');
|
|
7
7
|
const rootJson = path.join(rootDir, 'algebra');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algebraGenerators.js","sourceRoot":"","sources":["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,
|
|
1
|
+
{"version":3,"file":"algebraGenerators.js","sourceRoot":"","sources":["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;AAE/C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAChD,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;IACpD,QAAQ,CAAC,CAAC,MAAM,CAAC,YAAoB;QACnC,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D,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';\n\nconst rootDir = path.join(__dirname, '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,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable import/no-nodejs-modules,no-sync */
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
-
import { readFileSync } from '../fileUtils';
|
|
4
|
+
import { readFileSync } from '../fileUtils.js';
|
|
5
5
|
|
|
6
6
|
const rootDir = path.join(__dirname, 'algebra');
|
|
7
7
|
const rootSparql = path.join(rootDir, 'sparql');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable import/no-nodejs-modules,no-sync */
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
-
import { readFile } from '../fileUtils';
|
|
4
|
+
import { readFile } from '../fileUtils.js';
|
|
5
5
|
export function* positiveTest(type, filter) {
|
|
6
6
|
const dir = path.join(__dirname, type);
|
|
7
7
|
const statics = fs.readdirSync(dir);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators.js","sourceRoot":"","sources":["generators.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"generators.js","sourceRoot":"","sources":["generators.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAW3C,MAAM,SAAS,CAAC,CAAC,YAAY,CAC3B,IAA2C,EAC3C,MAAkC;IAElC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CA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AG,CAAC,CAAC;IACpC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;gBACnD,SAAS;YACX,CAAC;YACD,MAAM;gBACJ,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;gBACpC,OAAO,EAAE,KAAK,IAAG,EAAE;oBACjB,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC;oBAC/C,OAAO;wBACL,KAAK;qBACN,CAAC;gBACJ,CAAC;aACF,CAAC;QACJ,CAAC;IACH,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 { readFile } from '../fileUtils.js';\n\ninterface PositiveTest {\n name: string;\n statics: () => Promise<{\n query: string;\n ast: unknown;\n autoGen: string;\n }>;\n}\n\nexport function* positiveTest(\n type: 'paths' | 'sparql-1-1' | 'sparql-1-2',\n filter?: (name: string) => boolean,\n): Generator<PositiveTest> {\n const dir = path.join(__dirname, type);\n const statics = fs.readdirSync(dir);\n for (const file of statics) {\n if (file.endsWith('.json')) {\n if (filter && !filter(file.replace('.json', ''))) {\n continue;\n }\n yield {\n name: file.replace(/\\.json$/u, ''),\n statics: async() => {\n const query = await readFile(`${dir}/${file.replace('.json', '.sparql')}`);\n const result = await readFile(`${dir}/${file}`);\n let autoGen: string;\n try {\n autoGen = await readFile(`${dir}/${file.replace('.json', '-generated.sparql')}`);\n } catch {\n autoGen = query;\n }\n const json: unknown = JSON.parse(result);\n return {\n query,\n ast: json,\n autoGen,\n };\n },\n };\n }\n }\n}\n\ninterface NegativeTest {\n name: string;\n statics: () => Promise<{\n query: string;\n }>;\n}\n\nexport function* negativeTest(\n type: 'sparql-1-2-invalid',\n filter?: (name: string) => boolean,\n): Generator<NegativeTest> {\n const dir = path.join(__dirname, type);\n const statics = fs.readdirSync(dir);\n for (const file of statics) {\n if (file.endsWith('.sparql')) {\n if (filter && !filter(file.replace('.sparql', ''))) {\n continue;\n }\n yield {\n name: file.replace(/\\.sparql$/u, ''),\n statics: async() => {\n const query = await readFile(`${dir}/${file}`);\n return {\n query,\n };\n },\n };\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@traqula/test-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.14",
|
|
5
5
|
"description": "Test utils used by the Traqula monorepo",
|
|
6
6
|
"lsd:module": true,
|
|
7
7
|
"license": "MIT",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"exports": {
|
|
21
21
|
"./package.json": "./package.json",
|
|
22
22
|
".": {
|
|
23
|
+
"types": "./lib/index.d.ts",
|
|
23
24
|
"import": "./lib/index.js",
|
|
24
25
|
"require": "./lib/index.cjs"
|
|
25
26
|
}
|
|
@@ -48,5 +49,5 @@
|
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@rdfjs/types": "^2.0.0"
|
|
50
51
|
},
|
|
51
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "566bff376654ddba79225e631bad5a5544605006"
|
|
52
53
|
}
|